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).

posted @   unicornsir  阅读(57)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
历史上的今天:
2021-07-23 Sketchup 汉化后怎么切换到英文版本
2021-07-23 JSON遇到的坑
点击右上角即可分享
微信分享提示