Opencascade基础教程(5):创建点、线、面、实体并显示

1、创建点、线、面、实体并显示

#include <BRepBuilderAPI_MakeVertex.hxx>
void COCCDemoDoc::OnButtonCreatepnt()
{
	//创建点并显示
	gp_Pnt aPnt(10,10,10);
	TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex(aPnt);
	Handle(AIS_Shape) aisShpae = new AIS_Shape(aShape);
	GetAISContext()->Display(aisShpae,true);
}
#include <gce_MakeLin.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
void COCCDemoDoc::OnButtonCereatlin()
{
	//创建线并显示
	gp_Pnt aPnt1(10, 10, 10);
	gp_Pnt aPnt2(100, 100, 100);
	gp_Lin aLine = gce_MakeLin(aPnt1, aPnt2);
	TopoDS_Shape aShape = BRepBuilderAPI_MakeEdge(aLine,0,100);
	Handle(AIS_Shape) aisShpae = new AIS_Shape(aShape);
	GetAISContext()->Display(aisShpae, true);
}
#include <gce_MakePln.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
void COCCDemoDoc::OnButtonCereatface()
{
	//创建面并显示
	gp_Pnt aPnt1(0, 0, 0);
	gp_Pnt aPnt2(100, 0, 0);
	gp_Pnt aPnt3(0, 100, 0);
	gp_Pln aPln = gce_MakePln(aPnt1, aPnt2, aPnt3);
	TopoDS_Shape aShape = BRepBuilderAPI_MakeFace(aPln, 0, 100,0,100);
	Handle(AIS_Shape) aisShpae = new AIS_Shape(aShape);
	GetAISContext()->Display(aisShpae, true);
}
#include <BRepPrimAPI_MakeBox.hxx>
void COCCDemoDoc::OnButtonCreatecube()
{
	//创建box并显示
	TopoDS_Shape aShape = BRepPrimAPI_MakeBox(100, 100, 100);
	Handle(AIS_Shape) aisShpae = new AIS_Shape(aShape);
	GetAISContext()->Display(aisShpae, true);
}

2、效果如图:

在这里插入图片描述

ps:复杂曲线曲面的创建,可参考sample下面的Geometry和Modeling项目;

链接: 源代码下载地址

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值