]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #628: Fatal error as result of splitting polyline without tool object
authorabk <abk@opencascade.com>
Fri, 10 Jul 2015 11:00:28 +0000 (14:00 +0300)
committerabk <abk@opencascade.com>
Fri, 10 Jul 2015 11:00:28 +0000 (14:00 +0300)
The split algorithms were changed to do not perform the splitting if:
- the polyline is absent during the split by a point;
- one of the polylines is absent during the split of a polyline by a tool;
- less than two polylines are present during the split of polylines by each other.

src/HYDROData/HYDROData_PolylineOperator.cxx

index 612d24f985e09c6dc764661df0e5ce9cfe4b2ada..c8bc099f76d36f74f36574a11ef2743d82072f3b 100644 (file)
@@ -64,6 +64,11 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD
                                         const gp_Pnt2d& thePoint,
                                         double theTolerance ) const
 {
+  if (thePolyline.IsNull())
+  {
+    return false;
+  }
+
   std::vector<gp_Pnt2d> aPointsList( 1 );
   aPointsList[0] = thePoint;
   std::vector<TopoDS_Wire> aCurves;
@@ -84,6 +89,11 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD
               const Handle( HYDROData_PolylineXY )& theTool,
               double theTolerance ) const
 {
+  if (thePolyline.IsNull() || theTool.IsNull())
+  {
+    return false;
+  }
+
   HYDROData_SequenceOfObjects aSeq;
   aSeq.Append( theTool );
   return split( theDoc, thePolyline, aSeq, theTolerance, -1 );
@@ -155,6 +165,11 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD
                                         double theTolerance,
                                         int theIgnoreIndex ) const
 {
+  if (thePolyline.IsNull())
+  {
+    return false;
+  }
+
   std::vector<TopoDS_Wire> aCurves;
   GetWires(thePolyline, aCurves);
   std::vector<TopoDS_Wire> aToolCurves;
@@ -163,11 +178,19 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD
     {
       Handle( HYDROData_PolylineXY ) aToolPolyline = 
         Handle( HYDROData_PolylineXY )::DownCast( theTools.Value( i ) );
-      std::vector<TopoDS_Wire> aTCurves;
-      GetWires(aToolPolyline, aTCurves);
-      append( aToolCurves, aTCurves);
+      if (!aToolPolyline.IsNull())
+      {
+        std::vector<TopoDS_Wire> aTCurves;
+        GetWires(aToolPolyline, aTCurves);
+        append( aToolCurves, aTCurves);
+      }
     }
 
+  if (aToolCurves.empty())
+  {
+    return false;
+  }
+
   const int aPSCount = aCurves.size();
   const int aTSCount = aToolCurves.size();
   std::vector<TopoDS_Shape> aResult;