
Wed, 04/26/2023 - 10:35
Forums:
Hello Forum,
the TopoDS_Shape oldShape has been build, in some way.
Now, consider:
1) TopoDS_Shape newShape = oldShape;
2) BRepBuilderAPI_Copy tool;
tool.perform(oldShape,true,false); //! "false" since I'm not interested in copying the triangulation
newShape = tool.Shape();
Questions:
I) what is exactly the difference between 1) and 2), if any?
II) how the operator = of 1) is defined for TopoDS_Shape?
Grazie mille
Giovanni
Wed, 04/26/2023 - 12:20
Hello,
The difference between the two methods for copying a TopoDS_Shape lies in the level of deepness in copying the shape's data.
TopoDS_Shape newShape = oldShape;
This method uses the assignment operator (=) to create a shallow copy of the original shape (oldShape). This means that the new shape (newShape) will reference the same underlying geometric data as the old shape. If you modify the new shape, the old shape will also be affected, since they share the same data by smart pointer Handle(TopoDS_TShape). TopLoc_Location and TopAbs_Orientation are own parameter that not shared.
BRepBuilderAPI_Copy tool; tool.perform(oldShape, true, false); // "false" since I'm not interested in copying the triangulation newShape = tool.Shape();
This method uses the BRepBuilderAPI_Copy class to create a deep copy of the original shape. This means that a completely new geometric representation is created for the new shape, independent of the old shape. This allows you to modify the new shape without affecting the original one. The second parameter in the perform() function controls the copying of locations (True for copying, False for sharing). The third parameter controls the copying of the triangulation (True for copying, False for not copying).
Best regards, Dmitrii.
Wed, 04/26/2023 - 14:07
Thank you Dmitrii,
this is really an answer.
Actually It confirms what I experienced in my code.
A few words only to justify my answer.
I use the triangulation of a shape as a starting point for creating a FEM mesh,
through a mesh refinement algorithm.
So, I retrieve the TopoDS_Shape S from an AIS_Shape, then:
case 1)
I use TopoDS_Shape newShape = S, remesh newShape with
new, suitable parameters, and obtain the FEM mesh.
As a consequence the AIS_Shape visualization is changed!
case 2)
I use
BRepBuilderAPI_Copy tool;
tool.perform(oldShape, true, false);
TopoDS_Shape newShape = tool.Shape();
and I obtain my FEM mesh with my algo.
In this case the AIS_Shape visualization is not changed.
Thank you again
Giovanni