]> OCCT Git - occt-copy.git/commitdiff
0030873: Make ReShape tool resistant to replacement loops CR30873
authordrazmyslovich <razmyslovich@volumegraphics.com>
Wed, 7 Aug 2019 11:25:15 +0000 (13:25 +0200)
committerdrazmyslovich <razmyslovich@volumegraphics.com>
Wed, 7 Aug 2019 11:25:15 +0000 (13:25 +0200)
src/BRepTools/BRepTools_ReShape.cxx

index fbfa18a8b871d202cd42288d6def2f437a892ed0..e5128ee3631af543982ec81da5848fa366733bd9 100644 (file)
@@ -156,6 +156,13 @@ void BRepTools_ReShape::replace (const TopoDS_Shape& ashape,
   TopoDS_Shape shape = ashape;
   TopoDS_Shape newshape = anewshape;
   if ( shape.IsNull() || shape == newshape ) return;
+  if (Apply (newshape) == shape) 
+  {
+#ifdef OCCT_DEBUG
+    cout << "Warning: BRepTools_ReShape::Replace: recording the shape will lead to a loop" << endl;
+#endif
+    return;
+  }
 
   if (shape.Orientation() == TopAbs_REVERSED)
   {
@@ -181,7 +188,9 @@ void BRepTools_ReShape::replace (const TopoDS_Shape& ashape,
 #ifdef OCCT_DEBUG
   if ( IsRecorded ( shape ) && ((myConsiderLocation && ! Value ( shape ).IsPartner ( newshape )) ||
                                  (!myConsiderLocation && ! Value ( shape ).IsSame ( newshape )))) 
+  {
     cout << "Warning: BRepTools_ReShape::Replace: shape already recorded" << endl;
+  }
 #endif
 
   myShapeToReplacement.Bind(shape, TReplacement(newshape, theKind));