vs+qt实现OCC读取IGS模型和STEP模型并显示

前几天找了IGS的读取的简单实现,找到了一个能按博客操作步骤做了一定修改后勉强能实现的,具体实现参考我上一个博客。
后来发现有个occQt的例子,是一个大神几年前根据occ在qt下写的,看了源码,感觉做基本造型例子很不错,我就结合occ提供的IGS和STEP的读写接口,实现了一下igs和step两种格式模型的载入。其效果如下图;
在这里插入图片描述
1、编译OCC
这个网上教程很多,不赘述。
2、下载occQt源码,CSDN上有,github上也有。
3、具体实现:

//读取step
void occQt::readStep()
{
STEPControl_Reader reader;
reader.ReadFile(“E:\P3.step”);
// Loads file MyFile.stp
Standard_Integer NbRoots = reader.NbRootsForTransfer();
// gets the number of transferable roots
Standard_Integer NbTrans = reader.TransferRoots();
// translates all transferable roots, and returns the number of //successful translations
TopoDS_Shape aShape = reader.OneShape();
Handle(AIS_Shape) anAisModel = new AIS_Shape(aShape);
anAisModel->SetColor(Quantity_NOC_CHOCOLATE);
anAisModel->SetTransparency(0.9);
myOccView->getContext()->Display(anAisModel, Standard_True);
}

//读取igs
void occQt::readIgs()
{
IGESControl_Reader myIgesReader;
Standard_Integer nIgesFaces, nTransFaces;
myIgesReader.ReadFile("./p3.iges");
Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList(“iges-faces”);
//selects all IGES faces in the file and puts them into a list called //MyList,
nIgesFaces = myList->Length();
nTransFaces = myIgesReader.TransferList(myList);
//translates MyList,
cout << “IGES Faces: " << nIgesFaces << " Transferred:” << nTransFaces << endl;
TopoDS_Shape aShape = myIgesReader.OneShape();
Handle(AIS_Shape) anAisModel = new AIS_Shape(aShape);
anAisModel->SetColor(Quantity_NOC_BLUE1);
anAisModel->SetTransparency(0.9);
myOccView->getContext()->Display(anAisModel, Standard_True);
}

代码很少,需要完整的工程的可以到我的资料中下载:https://download.csdn.net/download/jiashou2471/11042752

  • 5
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 26
    评论
评论 26
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值