说明:
- VS版本:Visual Studio Community 2022
- 系统:Windows 11 专业版23H2
- Open CASCADE:v7.7.0(链接:https://pan.baidu.com/s/1-o1s4z3cjpYf5XkwhSDspQ?pwd=p9i5提取码:p9i5)
下载和安装OCC
Download - Open CASCADE Technology
安装MSVC
打开文件夹"C:\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\adm\msvc"
单个组件
设置VS环境变量
cs
setx DEvEnvDir "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE"
编译OCC
CMD运行
cs
cd C:\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0
msvc.bat vc142
改【Debug】为【Release】,【x64】保持不变,【解决方案】右键【重新生成】
生成的dll的文件夹位置为"C:\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\win64\vc14\bin"
等待编译完成
验证编译结果
在文件夹"C:\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\win64\vc14\bin"创建DRAWEXE_RUN.bat
cs
@echo off
set "ffmpeg=C:\OpenCASCADE-7.7.0-vc14-64\ffmpeg-3.3.4-64\bin"
set "freeimage=C:\OpenCASCADE-7.7.0-vc14-64\freeimage-3.17.0-vc14-64\bin"
set "freetype=C:\OpenCASCADE-7.7.0-vc14-64\freetype-2.5.5-vc14-64\bin"
set "openvr=C:\OpenCASCADE-7.7.0-vc14-64\openvr-1.14.15-64\bin\win64"
set "qt=C:\OpenCASCADE-7.7.0-vc14-64\qt5.11.2-vc14-64\bin"
set "tbb=C:\OpenCASCADE-7.7.0-vc14-64\tbb-2021.5-vc14-64\bin"
set "tcltk=C:\OpenCASCADE-7.7.0-vc14-64\tcltk-86-64\bin"
set "vtk=C:\OpenCASCADE-7.7.0-vc14-64\vtk-6.1.0-vc14-64\bin"
set path=%path%;%ffmpeg%;%freeimage%;%freetype%;%openvr%;%qt%;%tbb%;%tcltk%;%vtk%
call DRAWEXE.exe
pause
双击"DRAWEXE_RUN.bat"
如果报错提示
cs
---------------------------
DRAWEXE.exe - 系统错误
---------------------------
由于找不到 tbb12.dll,无法继续执行代码。重新安装程序可能会解决此问题。
---------------------------
确定
---------------------------
cs
---------------------------
DRAWEXE.exe - 系统错误
---------------------------
由于找不到 tbbmalloc.dll,无法继续执行代码。重新安装程序可能会解决此问题。
---------------------------
确定
---------------------------
打开文件夹"C:\OpenCASCADE-7.7.0-vc14-64\tbb_2021.5-vc14-64\bin"复制提示缺失的"tbb12.dll"和"tbbmalloc.dll"到"DRAWEXE_RUN.bat"所在文件夹
【Samples】【Modeling】【ANC101...】【Run sample】
C#使用OCC进行开发
下载源代码:https://github.com/Open-Cascade-SAS/OCCT-samples-csharp.git
打开"CSharp.sln",打开【OCCTProxy属性页】,【VC++目录】
【外部包含目录】设置为
cs
C:\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\inc
【库目录】设置为
cs
C:\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\win64\vc14\lib
【链接器】【输入】【附加依赖项】设置为
plaintext
TKBin.lib
TKBinL.lib
TKBinTObj.lib
TKBinXCAF.lib
TKBO.lib
TKBool.lib
TKBRep.lib
TKCAF.lib
TKCDF.lib
TKD3DHost.lib
TKD3DHostTest.lib
TKDCAF.lib
TKDFBrowser.lib
TKDraw.lib
TKernel.lib
TKExpress.lib
TKFeat.lib
TKFillet.lib
TKG2d.lib
TKG3d.lib
TKGeomAlgo.lib
TKGeomBase.lib
TKHLR.lib
TKIGES.lib
TKIVtk.lib
TKIVtkDraw.lib
TKLCAF.lib
TKMath.lib
TKMesh.lib
TKMeshVS.lib
TKMessageModel.lib
TKMessageView.lib
TKOffset.lib
TKOpenGl.lib
TKOpenGles.lib
TKOpenGlesTest.lib
TKOpenGlTest.lib
TKPrim.lib
TKQADraw.lib
TKRWMesh.lib
TKService.lib
TKShapeView.lib
TKShHealing.lib
TKStd.lib
TKStdL.lib
TKSTEP.lib
TKSTEP209.lib
TKSTEPAttr.lib
TKSTEPBase.lib
TKSTL.lib
TKTInspector.lib
TKTInspectorAPI.lib
TKTObj.lib
TKTObjDRAW.lib
TKToolsDraw.lib
TKTopAlgo.lib
TKTopTest.lib
TKTreeModel.lib
TKV3d.lib
TKVCAF.lib
TKView.lib
TKViewerTest.lib
TKVInspector.lib
TKVRML.lib
TKXCAF.lib
TKXDE.lib
TKXDECascade.lib
TKXDEDRAW.lib
TKXDEIGES.lib
TKXDESTEP.lib
TKXMesh.lib
TKXml.lib
TKXmlL.lib
TKXmlTObj.lib
TKXmlXCAF.lib
TKXSBase.lib
TKXSDRAW.lib
【Everything】搜索栏输入
cs
*.dll C:\OpenCASCADE-7.7.0-vc14-64\
复制所有的dll到文件夹"OCCT-samples-csharp\win64\bind"中
重新生成项目"OCCTProxy",启动项目,【File】【New】之后【Import】,可以导入文件夹"C:\OpenCASCADE-7.7.0-vc14-64\opencascade-7.7.0\data"内的三维模型文件
参考
- OCC_MSVC编译
- 手把手教你VS2019编译、配置Opencascade_opencascade配置vs-CSDN博客
- Open CASCADE 技术:Direct3D CSharp 示例 - OpenCascade 文档 --- Open CASCADE Technology: Direct3D CSharp sample - OpenCascade Documentation
- 在 C# 示例上构建 OCCTProxy - 论坛 Open Cascade Technology --- Building OCCTProxy on C# Samples - Forum Open Cascade Technology