TopoDS_Shape的拷贝
TopoDS_Shape的拷贝有两种方式
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();
两者的不同在于shape数据的拷贝深度,
TopoDS_Shape newShape = oldShape;
这个是浅拷贝,及新图形与老图形共享相同的几何数据,如果修改了新图形,老图形也随之修改,因为它们的数据是通过智能指针Handle(TopoDS_TShape)进行共享,而TopLoc_Location和TopAbs_Orientation拥有各自的参数,不进行共享。
BRepBuilderAPI_Copy tool; tool.perform(oldShape, true, false); // "false" since I'm not interested in copying the triangulation newShape = tool.Shape();
通过类BRepBuilderAPI_Copy 创建一个原始图形的深拷贝,这意味着新图形的几何信息与老图形是相互对立的,第二个参数是控制Location是否拷贝(True为拷贝,False为共享),第三个参数为是否拷贝三角化数据(True为拷贝,False为不拷贝)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).