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

标签 c++ geometry cad opencascade

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

  • 在 OpenCASCADE 中是否有执行此操作的标准方法?
  • 是否可以在不创建新形状的情况下更新几何图形?

我已经尝试改用 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 创建 Original and modified geometry

最佳答案

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

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

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

Modify shape

Replacing a face with X faces

Edit topology

关于c++ - 如何在 OpenCASCADE 中更改 TopoDS_Shape 的底层几何形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41592413/

相关文章:

algorithm - 对一组 3D 点进行三角测量

python - 在 Python 中使用 geoJSON 指向多边形

algorithm - 在二维 View 上选择几何对象

algorithm - 寻找一种有效的算法来找到扫描二维形状的边界

c++ - 如何在 Windows NT 中获取线程的动态优先级?

c++ - 递归构建可变参数函数的返回类型时的奇怪行为

c++ - 使用比例+旋转矩阵在OpenGL中的两点之间绘制一个矩形

parsing - Verilog 门级解析器

c++ - 如何在 Switch 语句中使用 IF

c++ - openMP 缺乏 yield 递减与更高的线程数