#include <GC_MakeArcOfCircle.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepPrimAPI_MakeRevol.hxx>
#include"Viewer.h"
int main(int argc, char* argv[])
{
Standard_Real radius = 5;
Standard_Real length = 75;
gp_Pnt oPnt(0, 0, 0); //回转环的关键点
gp_Vec v(1, 0, 0);
gp_Pnt ePnt(radius, 0, radius);
gp_Pnt linPnt1(radius, 0, length);
gp_Pnt linPnt2(0, 0, length);
Handle(Geom_TrimmedCurve) anArcOfCircle = GC_MakeArcOfCircle(oPnt, v, ePnt); //绘制回转体
TopoDS_Edge anArc = BRepBuilderAPI_MakeEdge(anArcOfCircle);
TopoDS_Edge topo_line1 = BRepBuilderAPI_MakeEdge(ePnt, linPnt1);
TopoDS_Edge topo_line2 = BRepBuilderAPI_MakeEdge(linPnt1, linPnt2);
TopoDS_Edge topo_line3 = BRepBuilderAPI_MakeEdge(linPnt2, oPnt);
TopoDS_Wire topo_tool_wire = BRepBuilderAPI_MakeWire(anArc, topo_line1, topo_line2, topo_line3);
TopoDS_Face topo_tool_face = BRepBuilderAPI_MakeFace(topo_tool_wire, Standard_True);
TopoDS_Shape topo_tool_solid = BRepPrimAPI_MakeRevol(topo_tool_face, gp_Ax1()); //生成刀具回转体
Viewer vout(50, 50, 500, 500);
vout << topo_tool_solid;
vout.StartMessageLoop();
return 0;
}
Open CASCADE学习| 建立刀具实体
最新推荐文章于 2024-04-06 21:28:43 发布
本文展示了如何在SolidWorks或类似软件中,通过C++代码利用OpenCASCADE库中的函数,如GC_MakeArcOfCircle和BRepPrimAPI_MakeRevol,创建一个圆弧旋转体,并使用Viewer进行可视化。
摘要由CSDN通过智能技术生成