Open CASCADE学习| 建立刀具实体

本文展示了如何在SolidWorks或类似软件中,通过C++代码利用OpenCASCADE库中的函数,如GC_MakeArcOfCircle和BRepPrimAPI_MakeRevol,创建一个圆弧旋转体,并使用Viewer进行可视化。
摘要由CSDN通过智能技术生成

#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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值