]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #626: No warning appears during attempt splitting not intersected polylines
authorabk <abk@opencascade.com>
Wed, 5 Aug 2015 13:32:49 +0000 (16:32 +0300)
committerabk <abk@opencascade.com>
Wed, 5 Aug 2015 13:34:30 +0000 (16:34 +0300)
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'.

src/HYDROData/HYDROData_PolylineOperator.cxx
src/HYDROData/HYDROData_PolylineOperator.h
src/HYDROData/HYDROData_TopoCurve.cxx
src/HYDROData/HYDROData_TopoCurve.h
src/HYDROGUI/HYDROGUI_SplitPolylinesOp.cxx

index c8bc099f76d36f74f36574a11ef2743d82072f3b..3a4183e8db3fd7b46fa85cdff3508f6b64225d73 100644 (file)
@@ -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<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 =
index 7740bf5ed3977d3a7f13ffa842df76c93a1b73d8..8e27796cea78a6f98165bbf531534985fc482ca3 100644 (file)
@@ -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,
index abe49f37865a10e5c4d88a03a67c2cb828485c1b..1d69ddb2e58e1322d0781564c7e3969e8b9faf4b 100644 (file)
@@ -469,11 +469,13 @@ TopoDS_Wire HYDROData_TopoCurve::Wire() const
   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;
@@ -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<TopoDS_Edge>::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<TopoDS_Edge>* 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<std::list<double> >& theParameters,
   std::deque<HYDROData_TopoCurve>& 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(
index f7439467086a4a39a294bc60e69b75848e28545b..a145b5f65b084300f9964622e0ce42a4daac8b04 100644 (file)
@@ -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<TopoDS_Edge>::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<std::list<double> >& theParameters,
     std::deque<HYDROData_TopoCurve>& theCurves) const;
 
index c81b1c6b76375ecf06be8d8869a19bb0b30f84b0..5adf7730de1f0e76b172adeaacf7416327407807 100644 (file)
@@ -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 );