VS创建空项目,使用OCCT库,读取STEP文件

创建VS空项目使用OCCT库,读取STEP文件,获得TopoDS_Shape对象

前提:完成构建OpenCascade,可以查看在windows上构建OpenCascade


首先创建引入OCCT库的空项目

  1. 创建项目
    image
  2. 配置项目属性
    设置环境,添加dll文件夹路径
    image
    设置库目录
    image
    设置附加包含目录
    image
    设置附加库目录
    image
    设置附加依赖项
    这里的lib可以写全也可以用哪个写哪个,使用Far.exe,根据vs的报错查询lib信息,再进行配置
    image

读取STEP文件代码来自对官方Example

#include "STEPUtil.h"
#include <iostream>
#include <STEPControl_Reader.hxx> 
#include <BRepTools.hxx> 
using namespace std;
TopoDS_Shape STEPUtil::ReadingSTEP()
{
	cout << "-----ReadingSTEP START-----" << endl;
	STEPControl_Reader reader;
	//reader.ReadFile("C:\\Users\\Rick\\Desktop\\RL\\assm.step");
	reader.ReadFile("C:\\Users\\Rick\\Desktop\\RL\\OCC-7_6_3\\OCCT-7_6_3-install\\data\\step\\linkrods.step");
	// Loads file MyFile.stp 
	Standard_Integer NbRoots = reader.NbRootsForTransfer();
	// gets the number of transferable roots 
	cout << "Number of roots in STEP file :" << NbRoots << endl;
	Standard_Integer NbTrans = reader.TransferRoots();
	// translates all transferable roots, and returns the number of    //successful translations 
	cout << "STEP roots transferred :" << NbTrans << endl;
	cout << "Number of resulting shapes is :" << reader.NbShapes() << endl;
	TopoDS_Shape result = reader.OneShape();
	// obtain the results of translation in one OCCT shape 
	cout << "-----ReadingSTEP END-----" << endl;
	return result;
}
posted @   SpringBreath  阅读(1474)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示