OCCT源码学习
OCCT源码学习
OCCT 源码学习
姜豪
2023 年 6 月
目录
1. 编译记录................................................................................................. 1
1.1 概况.................................................................................................................. 1
1.2 基本情况.............................................................................................................. 1
1.3 第三方库编译........................................................................................................... 1
1.3.1 TCL 8.6.13【OCC 的 DRAW 模块依赖】...............................................................1
1.3.2 TK 8.6.13【OCC 的 DRAW 模块依赖】.................................................................4
1.3.3 FreeType 2.13.1......................................................................................6
1.3.4 oneTBB 2021.9.0....................................................................................6
1.3.5 FreeImage 3.18.0....................................................................................6
1.3.6 VTK-9.2.6................................................................................................ 7
1.4 编译 OCCT......................................................................................................... 7
2. 代码学习...............................................................................................15
1. 编译记录
1.1 概况
1.2 基本情况
本次编译的版本是 7.7.0;
支持的编译平台有:
OS Compiler
OS X /
XCode 6 or newer
macOS
1.3 第三方库编译
1
译器版本里是不同的。比如,原有的 buildall.vc.bat 脚本指定的路径是
直接运行该脚本会报路径错误。
直接运行原有脚本会报错
另一方面,buildall.vc.bat 脚本中指定了编译后结果的安装路径,我们也需要对其进行调整。
3) 做如下几处修改:
a) 指定系统的开发者环境
b) 指定编译结果安装路径
2
d) 删除第二个 nmake
e) 修改 rules.vc
f) 将动态运行时库改为静态运行时库
/MT 是 "multithread, static version ” 意思是多线程静态的版本,定义了它后,编译
器把 LIBCMT.lib 安置到 OBJ 文件中,让链接器使用 LIBCMT.lib 处理外部符号。
/MD 是 "multithread- and DLL-specific version” ,意思是多线程 DLL 版
本,定义了它后,编译器把 MSVCRT.lib 安置到 OBJ 文件中,它连接到 DLL 的方式是静态链接,
实际上工作的库是 MSVCR80.DLL。
即:
静态运行时库:LIBCMT.lib
动态运行时库:MSVCRT.lib + MSVCR80.DLL
这是修改的 makefile.vc
实际应该修改 rules.vc:
3
Mode LastWriteTime Length Name
仅修改 makefile.vc:
Mode LastWriteTime Length Name
4) 运行两次 buildall.vc.bat
5) 拷贝 tclsh76.exe,重命名为 tclsh.exe
b) 指定编译结果安装路径
c) 指定 tcl 源码路径
4
d) 为第一次调用 nmake 添加安装路径
e) 删除第二个 nmake
f) 修改 rules.vc
g) 将动态运行时库改为静态运行时库
5
2) 运行一次 buildall.vc.bat
3) 拷贝 wish86.exe,重命名为 wish.exe
内有配置好的 sln,直接编译即可。
1.3.6 VTK-9.2.6
6
1.4 编译 OCCT
1) 设置目录
Source:源目录
Build:构建目录
Installation:安装目录
2) 一些 CMake 编译选项的设置
Indicates whether 是
FreeType product should
USE_FREETYPE Boolean
be used in OCCT for text
rendering
Indicates whether 是
FreeImage product
should be used in OCCT
USE_FREEIMAGE Boolean visualization module for
support of popular
graphics image formats
(PNG, BMP, etc.)
Indicates whether 否
OpenVR product should
USE_OPENVR Boolean be used in OCCT
visualization module for
support of Virtual Reality
7
TKOpenGl graphic driver
using OpenGL library
(desktop) should be
built within OCCT
visualization module
Indicates whether 否
TKOpenGles graphic
driver using OpenGL ES
USE_GLES2 Boolean library (embedded
OpenGL) should be built
within OCCT
visualization module
Indicates whether 否
RapidJSON product
should be used in OCCT
USE_RAPIDJSON Boolean
Data Exchange module
for support of glTF mesh
file format
8
OCCT comes with a
bridge between CAD
data representation and
VTK by means of its
dedicated VIS
component (VTK
Integration Services).
You may skip this 3rd
party unless you are
planning to use VTK
visualization for OCCT
geometry. See the
official
documentation VTK
Integration Services
(VIS) for the details on
VIS
3RDPARTY_TCL_* Done
Path Path to Tcl/Tk binaries
3RDPARTY_TK_*
9
module should be built
or not. It should be
noted that some toolkits
of a module can be built
even if this module is
not checked (this
happens if some other
modules depend on
these toolkits). The main
modules and their
descriptions can be
found in User Guides
Semicolon-separated None
individual toolkits to
include into build
process. If you want to
build some particular
libraries (toolkits) only,
then you may uncheck
BUILD_ADDITIONAL_T
String all modules in the
OOLKITS
corresponding BUILD_M
ODUE_<MODULE> optio
ns and provide the list of
necessary libraries here.
Of course, all
dependencies will be
resolved automatically
10
Enables Flex/Bison No
lexical analyzers. OCCT
source files relating to
STEP reader and
ExprIntrp functionality
are generated
BUILD_YACCLEX Boolean automatically with
Flex/Bison. Checking
this option leads to
automatic search of
Flex/Bison binaries and
regeneration of the
mentioned files
11
for OCCT. If specified,
the files from this
directory take
precedence over the
corresponding native
OCCT sources. This way
you are able to
introduce patches to
Open CASCADE
Technology not affecting
the original source
distribution
Enable/Disable the No
floating point exceptions
(FPE) during DRAW
execution only.
Corresponding
BUILD_ENABLE_FPE_S
Boolean environment variable
IGNAL_HANDLER
(CSF_FPE) can be
changed manually in
custom.bat/sh scripts
without regeneration by
CMake.
CMAKE_CONFIGURATI Semicolon-separated
String
ON_TYPES CMake configurations
12
a synonym 7.7.0-install
of CMAKE_INSTALL_PREF
IX. The user can specify
both INSTALL_DIR or CM
AKE_INSTALL_PREFIX
13
and for Unix operating
systems (standard Linux
layout). If needed, the
layout can be
customized with
INSTALL_DIR_* variables
14
Indicates whether TBB Yes
binaries should be
INSTALL_TBB Boolean
installed into the
installation directory
15
2. Quaoar Workshop
16
17
18