bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
const Handle( HYDROData_PolylineXY )& thePolyline,
const Handle( HYDROData_PolylineXY )& theTool,
- double theTolerance ) const
+ double theTolerance,
+ bool& theIsIntersected) const
{
if (thePolyline.IsNull() || theTool.IsNull())
{
HYDROData_SequenceOfObjects aSeq;
aSeq.Append( theTool );
- return split( theDoc, thePolyline, aSeq, theTolerance, -1 );
+ return split( theDoc, thePolyline, aSeq, theTolerance, -1, theIsIntersected);
}
bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
for( int i=f; i<=l; i++ )
{
Handle( HYDROData_PolylineXY ) aPolyline = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
- if( !split( theDoc, aPolyline, thePolylines, theTolerance, i ) )
+ bool isIntersected;
+ if( !split( theDoc, aPolyline, thePolylines, theTolerance, i, isIntersected) )
return false;
}
return true;
const Handle( HYDROData_PolylineXY )& thePolyline,
const HYDROData_SequenceOfObjects& theTools,
double theTolerance,
- int theIgnoreIndex ) const
+ int theIgnoreIndex,
+ bool& theIsIntersected) const
{
+ theIsIntersected = false;
+
if (thePolyline.IsNull())
{
return false;
}
std::deque<HYDROData_TopoCurve> aSplittedCurves;
- aCurve.Cut(aParams, aSplittedCurves);
+ theIsIntersected |= aCurve.Cut(aParams, aSplittedCurves);
std::deque<HYDROData_TopoCurve>::const_iterator aCIt =
aSplittedCurves.begin();
std::deque<HYDROData_TopoCurve>::const_iterator aLastCIt =
bool Split( const Handle( HYDROData_Document )& theDoc,
const Handle( HYDROData_PolylineXY )& thePolyline,
const Handle( HYDROData_PolylineXY )& theTool,
- double theTolerance ) const;
+ double theTolerance,
+ bool& theIsIntersected) const;
bool Split( const Handle( HYDROData_Document )& theDoc,
const HYDROData_SequenceOfObjects& thePolylines,
double theTolerance );
const Handle( HYDROData_PolylineXY )& thePolyline,
const HYDROData_SequenceOfObjects& theTools,
double theTolerance,
- int theIgnoreIndex ) const;
+ int theIgnoreIndex,
+ bool& theIsIntersected) const;
static void Split(
const TopoDS_Wire& theWire,
return aWire;
}
-void HYDROData_TopoCurve::Cut(
+bool HYDROData_TopoCurve::Cut(
const std::list<TopoDS_Edge>::iterator& theEdgePosition,
const double theParameter,
HYDROData_TopoCurve& theCurve)
{
+ bool aResult = false;
+
// Locate the edge.
std::list<TopoDS_Edge>::iterator aFirstEIt = myEdges.begin();
std::list<TopoDS_Edge>::iterator aEIt = aFirstEIt;
*aEIt = aEParts[aFirstPI];
InsertAfter(aEIt, aEParts[1 - aFirstPI], myEdges);
++aEIt;
+
+ aResult = true;
}
else
{
if (aParamI > 0)
{
++aEIt;
+
+ std::list<TopoDS_Edge>::iterator aEdgePosition = theEdgePosition;
+ if (isClosed || ++aEdgePosition != myEdges.end())
+ {
+ aResult = true;
+ }
+ }
+ else
+ {
+ if (isClosed || theEdgePosition != aFirstEIt)
+ {
+ aResult = true;
+ }
}
}
std::list<TopoDS_Edge>* aEdges = !isClosed ? &theCurve.myEdges : &myEdges;
aEdges->splice(aEdges->begin(), myEdges, aEIt, aLastEIt);
}
+
+ return aResult;
}
void HYDROData_TopoCurve::Cut(
theCurve1.Cut(aEPos1, theParameter, theCurve2);
}
-void HYDROData_TopoCurve::Cut(
+bool HYDROData_TopoCurve::Cut(
const std::deque<std::list<double> >& theParameters,
std::deque<HYDROData_TopoCurve>& theCurves) const
{
+ bool aResult = false;
HYDROData_TopoCurve aCurves[2];
aCurves[0] = *this;
int aCI = 0;
*aPLIt, (aEIt->Orientation() != TopAbs_REVERSED)); aPIt.More(); ++aPIt)
{
const int aCI1 = 1 - aCI;
- aCurves[aCI].Cut(aEIt, **aPIt, aCurves[aCI1]);
+ aResult |= aCurves[aCI].Cut(aEIt, **aPIt, aCurves[aCI1]);
if (!aCurves[aCI1].IsEmpty())
{
theCurves.push_back(HYDROData_TopoCurve());
}
}
theCurves.push_back(aCurves[aCI]);
+ return aResult;
}
double HYDROData_TopoCurve::Project(
//! Cuts the curve in the given parameter of the given edge and
//! fills the cut part.
- HYDRODATA_EXPORT void Cut(
+ //! Returns 'true' if:
+ //! - the curve is open and was splitted into two parts or
+ //! - the curve is closed and was cut into an open curve.
+ HYDRODATA_EXPORT bool Cut(
const std::list<TopoDS_Edge>::iterator& theEdgePosition,
const double theParameter,
HYDROData_TopoCurve& theCurve);
//! Cuts the curve at the parameters.
//! Each parameter vector list corresponds to the curve edge and
//! is ordered in the ascending order.
- HYDRODATA_EXPORT void Cut(
+ HYDRODATA_EXPORT bool Cut(
const std::deque<std::list<double> >& theParameters,
std::deque<HYDROData_TopoCurve>& theCurves) const;
double aTolerance = 1E-2; //TODO
HYDROData_PolylineOperator anOp;
+ bool isIntersected = false;
switch( aPanel->GetMode() )
{
case HYDROGUI_SplitPolylinesDlg::ByPoint:
anOp.Split( doc(), aMainPolyline, aPoint, aTolerance );
break;
case HYDROGUI_SplitPolylinesDlg::ByTool:
- anOp.Split( doc(), aMainPolyline, aToolPolyline, aTolerance );
+ anOp.Split( doc(), aMainPolyline, aToolPolyline, aTolerance, isIntersected);
break;
case HYDROGUI_SplitPolylinesDlg::Split:
anOp.Split( doc(), aPolylinesList, aTolerance );