如何在 OpenCASCADE 中更改 TopoDS_Shape 的底层几何形状

How can I change the underlying geometry of a TopoDS_Shape in OpenCASCADE

我正在尝试更改 OpenCASCADE 中现有 TopoDS_Shape 的几何结构。一种可能的应用是修改 body 的边缘而不需要重建整个 body(例如,改变圆柱体的一个帽盖的半径,移动 B 样条中的控制点 curve/surface).

我已经尝试使用 BRepAdaptor_HCurve,但这并没有真正帮助。

Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), 5); // create a circle in the xy plane, origin (0,0,0) radius 5;
TopoDS_Edge circ = BRepBuilderAPI_MakeEdge(aCircle); // switch to topological description;

STEPControl_Writer writer;

writer.Transfer(circ,STEPControl_AsIs); // access topology for output   

BRepAdaptor_Curve theAdaptor = BRepAdaptor_Curve(circ); // create an adaptor    
gp_Circ mod_circ = theAdaptor.Circle();
mod_circ.SetRadius(1); // change radius to 1

// I dont want to create a new circle, but reuse the old one with the updated geometry:
// writer.Transfer(circ, STEPControl_AsIs); // access topology for output

// in order to output the updated geometry, we also have to create a new edge
TopoDS_Edge another_circ = BRepBuilderAPI_MakeEdge(mod_circ);

writer.Transfer(another_circ, STEPControl_AsIs); // access topology for output
writer.Write("debug.stp");

原始和修改后的几何图形,通过编写 circanother_circ 创建

正如我从 OpenCASCADE 论坛和文档中了解到的,您不能直接更改形状的子形状。但是你可以创建一个新的子形状并替换旧的。

请参阅下面的 OpenCASCADE 论坛主题。希望对你有帮助。

How to modify sub-shapes of a given shape without copy

Modify shape

Replacing a face with X faces

Edit topology