]> OCCT Git - occt.git/commitdiff
0033806: Shape Healing - ShapeCustom optimization while rebuilding compounds
authoroan <oan@opencascade.com>
Mon, 26 Aug 2024 18:39:42 +0000 (19:39 +0100)
committerdpasukhi <dpasukhi@opencascade.com>
Sat, 14 Sep 2024 20:26:41 +0000 (20:26 +0000)
Avoid double binding of shapes to context.
Take all changes into account by reshape

src/ShapeCustom/ShapeCustom.cxx

index a5e8dd29d87a4861d52de860f6c276b4c06a7c52..61309e419f77b0526bccd624c5d28351d031dfd0 100644 (file)
@@ -142,11 +142,7 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
         res = ApplyModifier (shape, M, context, MD, aRange, aReShape);
       }
 
-      if ( !res.IsSame (shape) )
-      {
-        context.Bind (aShapeNoLoc, res.Located (TopLoc_Location()));
-        locModified = Standard_True;
-      }
+      locModified |= !res.IsSame (shape);
 
       B.Add (C, res);
     }
@@ -162,10 +158,18 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
       return S;
     }
 
-    context.Bind ( SF, C );
+    SF.Orientation (S.Orientation());
+    C .Orientation (S.Orientation());
+
+    context.Bind (SF, C);
+
+    C.Location (S.Location(), Standard_False);
+    
+    if (!aReShape.IsNull())
+    {
+      aReShape->Replace (S, C);
+    }
 
-    C.Orientation (S.Orientation());
-    C.Location    (S.Location(), Standard_False);
     return C;
   }
 
@@ -175,12 +179,21 @@ TopoDS_Shape ShapeCustom::ApplyModifier (const TopoDS_Shape &S,
   MD.Perform(M, aPS.Next());
   
   if ( !aPS.More() || !MD.IsDone() ) return S;
+
+  TopoDS_Shape aResult = MD.ModifiedShape (SF);
+  aResult.Orientation (S.Orientation());
+
+  if (!SF.IsSame (aResult))
+  {
+    context.Bind (S.Located (TopLoc_Location()), aResult.Located (TopLoc_Location()));
+  }
+
   if ( !aReShape.IsNull() )
   {
     UpdateShapeBuild ( SF, MD, aReShape );
   }
 
-  return MD.ModifiedShape(SF).Oriented(S.Orientation());
+  return aResult;
 }