]> OCCT Git - occt.git/commitdiff
0033710: Canonical Recognition - Add ShapeBuild_ReShape optional parameter to retriev...
authorFtpSantos <francisco.santos@opencascade.com>
Mon, 15 Jul 2024 18:13:28 +0000 (19:13 +0100)
committeroan <oan@opencascade.com>
Mon, 15 Jul 2024 18:13:28 +0000 (19:13 +0100)
ShapeBuild_ReShape is now update recursively in ShapeCustom::ApplyModifier

src/ShapeCustom/ShapeCustom.cxx

index 5e4ab7f82eeceefc3fe3e232c0522b75ae292543..ca906bd4bcd6454d0794045fea96b5042f38c1ba 100644 (file)
 
 #include <Message_ProgressScope.hxx>
 
+namespace
+{
+  //=======================================================================
+  //function : UpdateShapeBuild
+  //purpose  : Recursively updates ShapeBuild_ReShape to add information of all sub-shapes
+  //=======================================================================
+
+  void UpdateShapeBuild(const TopoDS_Shape & SF,
+                        const BRepTools_Modifier & MD,
+                        const Handle(ShapeBuild_ReShape) & aReShape)
+  {
+    for ( TopoDS_Iterator theIterator ( SF, Standard_False ); theIterator.More(); theIterator.Next() )
+    {
+      const TopoDS_Shape & current = theIterator.Value();
+      TopoDS_Shape result;
+      try
+      {
+        OCC_CATCH_SIGNALS
+        result = MD.ModifiedShape ( current );
+      }
+      catch ( Standard_NoSuchObject const & )
+      {
+        // the sub shape isn't in the map
+        result.Nullify();
+      }
+
+      if ( !result.IsNull() && !current.IsSame ( result ) )
+      {
+        aReShape->Replace ( current, result );
+        UpdateShapeBuild ( current, MD, aReShape );
+      }
+    }
+  }
+}
+
 //=======================================================================
 //function : ApplyModifier
 //purpose  : static
@@ -69,7 +104,7 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
       if ( context.IsBound ( shape ) )
         res = context.Find ( shape ).Oriented ( shape.Orientation() );
       else
-        res = ApplyModifier ( shape, M, context ,MD, aRange);
+        res = ApplyModifier ( shape, M, context ,MD, aRange, aReShape );
 
       if ( ! res.IsSame ( shape ) ) {
         context.Bind ( shape, res );
@@ -98,26 +133,7 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
   if ( !aPS.More() || !MD.IsDone() ) return S;
   if ( !aReShape.IsNull() )
   {
-    for(TopoDS_Iterator theIterator(SF,Standard_False);theIterator.More();theIterator.Next())
-    {
-      const TopoDS_Shape & current = theIterator.Value();
-      TopoDS_Shape result;
-      try
-      {
-        OCC_CATCH_SIGNALS
-        result = MD.ModifiedShape( current );
-      }
-      catch (Standard_NoSuchObject const&)
-      {
-        // the sub shape isn't in the map
-        result.Nullify();
-      }
-
-      if (!result.IsNull() && !current.IsSame(result))
-      {
-        aReShape->Replace(current, result);
-      }
-    }
+    UpdateShapeBuild ( SF, MD, aReShape );
   }
 
   return MD.ModifiedShape(SF).Oriented(S.Orientation());