Reputation: 322
I am trying to change the geometry of an existing TopoDS_Shape in OpenCASCADE. A possible application is for modifying an edge of a body without the need to reconstruct the whole body (e.g. change the radius of one cap of a cylinder, shift a control point in a Bspline curve/surface).
I already tried to use BRepAdaptor_HCurve
instead, but this did not really help.
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");
Original and modified geometry, created by writing circ
and another_circ
Upvotes: 2
Views: 2503
Reputation: 504
As i understood from the OpenCASCADE forum and the documentation you can not to change the subshapes of a shape directly. But you can create a new subshape and replace the old.
See OpenCASCADE forum topics below. Hope it helps.
How to modify sub-shapes of a given shape without copy
Upvotes: 4