From: abk Date: Wed, 5 Aug 2015 13:32:49 +0000 (+0300) Subject: refs #626: No warning appears during attempt splitting not intersected polylines X-Git-Tag: BR_quadtree_20150925~2^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=19ae50f3858a077a34385debc9e08de1d8fc42b9;p=modules%2Fhydro.git refs #626: No warning appears during attempt splitting not intersected polylines The functionality to split a polyline by a tool was extended to determine whether to display the warning about the intersection absence. Now method 'HYDROGUI_SplitPolylinesOp::processApply' calculates corresponding flag 'isIntersected'. --- diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index c8bc099f..3a4183e8 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -87,7 +87,8 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD 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()) { @@ -96,7 +97,7 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD 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, @@ -107,7 +108,8 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD 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; @@ -163,8 +165,11 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD 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; @@ -209,7 +214,7 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD } std::deque aSplittedCurves; - aCurve.Cut(aParams, aSplittedCurves); + theIsIntersected |= aCurve.Cut(aParams, aSplittedCurves); std::deque::const_iterator aCIt = aSplittedCurves.begin(); std::deque::const_iterator aLastCIt = diff --git a/src/HYDROData/HYDROData_PolylineOperator.h b/src/HYDROData/HYDROData_PolylineOperator.h index 7740bf5e..8e27796c 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.h +++ b/src/HYDROData/HYDROData_PolylineOperator.h @@ -37,7 +37,8 @@ public: 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 ); @@ -68,7 +69,8 @@ protected: 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, diff --git a/src/HYDROData/HYDROData_TopoCurve.cxx b/src/HYDROData/HYDROData_TopoCurve.cxx index abe49f37..1d69ddb2 100644 --- a/src/HYDROData/HYDROData_TopoCurve.cxx +++ b/src/HYDROData/HYDROData_TopoCurve.cxx @@ -469,11 +469,13 @@ TopoDS_Wire HYDROData_TopoCurve::Wire() const return aWire; } -void HYDROData_TopoCurve::Cut( +bool HYDROData_TopoCurve::Cut( const std::list::iterator& theEdgePosition, const double theParameter, HYDROData_TopoCurve& theCurve) { + bool aResult = false; + // Locate the edge. std::list::iterator aFirstEIt = myEdges.begin(); std::list::iterator aEIt = aFirstEIt; @@ -530,6 +532,8 @@ void HYDROData_TopoCurve::Cut( *aEIt = aEParts[aFirstPI]; InsertAfter(aEIt, aEParts[1 - aFirstPI], myEdges); ++aEIt; + + aResult = true; } else { @@ -538,6 +542,19 @@ void HYDROData_TopoCurve::Cut( if (aParamI > 0) { ++aEIt; + + std::list::iterator aEdgePosition = theEdgePosition; + if (isClosed || ++aEdgePosition != myEdges.end()) + { + aResult = true; + } + } + else + { + if (isClosed || theEdgePosition != aFirstEIt) + { + aResult = true; + } } } @@ -548,6 +565,8 @@ void HYDROData_TopoCurve::Cut( std::list* aEdges = !isClosed ? &theCurve.myEdges : &myEdges; aEdges->splice(aEdges->begin(), myEdges, aEIt, aLastEIt); } + + return aResult; } void HYDROData_TopoCurve::Cut( @@ -563,10 +582,11 @@ void HYDROData_TopoCurve::Cut( theCurve1.Cut(aEPos1, theParameter, theCurve2); } -void HYDROData_TopoCurve::Cut( +bool HYDROData_TopoCurve::Cut( const std::deque >& theParameters, std::deque& theCurves) const { + bool aResult = false; HYDROData_TopoCurve aCurves[2]; aCurves[0] = *this; int aCI = 0; @@ -589,7 +609,7 @@ void HYDROData_TopoCurve::Cut( *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()); @@ -609,6 +629,7 @@ void HYDROData_TopoCurve::Cut( } } theCurves.push_back(aCurves[aCI]); + return aResult; } double HYDROData_TopoCurve::Project( diff --git a/src/HYDROData/HYDROData_TopoCurve.h b/src/HYDROData/HYDROData_TopoCurve.h index f7439467..a145b5f6 100644 --- a/src/HYDROData/HYDROData_TopoCurve.h +++ b/src/HYDROData/HYDROData_TopoCurve.h @@ -71,7 +71,10 @@ public: //! 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::iterator& theEdgePosition, const double theParameter, HYDROData_TopoCurve& theCurve); @@ -87,7 +90,7 @@ public: //! 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 >& theParameters, std::deque& theCurves) const; diff --git a/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx b/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx index c81b1c6b..5adf7730 100644 --- a/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx @@ -87,13 +87,14 @@ bool HYDROGUI_SplitPolylinesOp::processApply( int& theUpdateFlags, 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 );