title: How can I change the underlying geometry of a TopoDS_Shape in OpenCASCADE
body: <p>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).</p>
  
  <ul>
  <li>Is there a standard approach to do this in OpenCASCADE?</li>
  <li>Is it possible to update geometry without creating a new shape?</li>
  </ul>
  
  <p>I already tried to use <code>BRepAdaptor_HCurve</code> instead, but this did not really help.</p>
  
  <pre><code>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");
  </code></pre>
  
  <p>Original and modified geometry, created by writing <code>circ</code> and <code>another_circ</code>
  <a href="https://i.stack.imgur.com/bZwEa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bZwEa.png" alt="Original and modified geometry"></a></p>