generated from cotes2020/chirpy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
358 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: OCCT projects on github | ||
date: 2023-05-24 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [OCCT] | ||
tags: [occt] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# OCCT projects on github | ||
|
||
## OCCT samples | ||
|
||
需要安装 `OpenGL`: [基于Ubuntu搭建OpenGL开发环境](https://www.cnblogs.com/jiujiubashiyi/p/16429717.html) | ||
|
||
```bash | ||
sudo apt-get install libglfw3-dev | ||
sudo apt install mesa-utils | ||
``` | ||
|
||
以下两个项目均来自 [github gkv311](https://github.com/gkv311) | ||
|
||
* [occt-samples-qopenglwidget](https://gitee.com/occt/occt-samples-qopenglwidget.git) | ||
* [occt-hello](https://gitee.com/occt/occt-hello) | ||
|
||
## OCCT 文章 | ||
|
||
### Boolean | ||
|
||
* [Open Cascade中的布尔操作](http://cppblog.com/eryar/archive/2013/01/17/197357.html) | ||
* [OpenCASCADE 布尔运算简介](https://www.cnblogs.com/opencascade/p/OCCT_BO_Intro.html) | ||
* [OpenCasCade拓扑几何的布尔运算](https://blog.csdn.net/qq_22642239/article/details/97271457) | ||
* [Boolean Operations](https://dev.opencascade.org/doc/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_5) | ||
* [OpenCascade Modeling Algorithms Boolean Operations](https://www.cnblogs.com/opencascade/p/3511140.html) | ||
|
||
### Fillet | ||
|
||
* [autoCAD doc Fillet](https://help.autodesk.com/view/ACD/2023/ENU/?guid=GUID-64F8B700-23B3-4BD6-8C03-66121AA13E8F) | ||
|
||
### Mesh | ||
|
||
* [Mesh](https://dev.opencascade.org/doc/overview/html/occt_user_guides__mesh.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
--- | ||
title: Ubuntu 安装 OCCT | ||
date: 2023-05-24 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [OCCT] | ||
tags: [occt] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
## OCCT 依赖库 | ||
|
||
* [Introduction -- Requirements](https://dev.opencascade.org/doc/overview/html/index.html) | ||
|
||
## 下载OpenCascade | ||
|
||
`OCC 7.7`编译有问题,使能`VTK`时编译错误,下载最新版的`OCC`修复该问题: | ||
|
||
```bash | ||
# https://dev.opencascade.org/resources/git_repository | ||
git clone https://git.dev.opencascade.org/repos/occt.git occt | ||
``` | ||
|
||
## 编译安装命令 | ||
|
||
### 1. 编译安装第三方库 | ||
|
||
* 注意要 `tcl-dev`, `tk-dev`, `tcllib`, `tklib`,除非自己编译安装,此时要设置TCL/TK相关的路径,比较麻烦。 | ||
|
||
```bash | ||
sudo apt-get install tcllib tklib tcl-dev tk-dev libfreetype-dev libx11-dev libgl1-mesa-dev libfreeimage-dev | ||
sudo apt-get install rapidjson-dev libdraco-dev | ||
``` | ||
|
||
`tcl 8.6`编译安装命令(`tk 8.6`相同的编译配置命令): | ||
|
||
```bash | ||
# https://www.tcl.tk/software/tcltk/8.6.html | ||
|
||
cd tcl8.6.13/unix | ||
./configure --enable-gcc --enable-shared --enable-threads --enable-64bit | ||
make && sudo make install | ||
``` | ||
|
||
`freeType`编译安装命令: | ||
|
||
```bash | ||
# https://freetype.org/download.html | ||
|
||
CFLAGS='-m64 -fPIC' CPPFLAGS='-m64 -fPIC' ./configure | ||
make && sudo make install | ||
``` | ||
|
||
`FreeImage`编译安装命令: | ||
|
||
```bash | ||
# https://freeimage.sourceforge.io/download.html | ||
# 修改 Makefile.fip:增加 CXXFLAGS += -std=c++11 | ||
make -f Makefile.fip | ||
# 拷贝头文件及 .so, .a 到相应目录 | ||
``` | ||
|
||
编译安装`fdk-acc`及`ffmpeg`: | ||
|
||
```bash | ||
# install dependencies | ||
sudo apt install libavformat-dev libavcodec-dev libswresample-dev libswscale-dev libavutil-dev libsdl1.2-dev libx264-dev nasm | ||
|
||
# tdk-acc | ||
./configure && make && sudo make install | ||
|
||
# ffmpeg | ||
./configure --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libx264 --enable-filter=delogo --enable-shared --enable-pthreads | ||
make && sudo make install | ||
``` | ||
|
||
### 2. 编译安装 OCCT | ||
|
||
```bash | ||
cd opencascade-7.7.0 | ||
mdkir build && cd build | ||
|
||
# 配置OCC编译,使能VTK, ITK等功能 | ||
ccmake .. | ||
|
||
make -j6 | ||
sudo make install | ||
``` | ||
|
||
几次配置截图之后,配置如下 | ||
|
||
![ccmake1](/assets/images/occ/ccmake01.png) | ||
|
||
![ccmake2](/assets/images/occ/ccmake02.png) | ||
|
||
### 3. 安装或编译 Qt5 | ||
|
||
* 安装 Qt5 | ||
|
||
```bash | ||
sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools | ||
sudo apt-get install qtcreator | ||
``` | ||
|
||
* 编译 Qt5 | ||
|
||
编译及设置环境变量见 [VTK(1):ubuntu 22.04 源码编译安装 Qt5.15.6](https://www.cnblogs.com/vaughnhuang/articles/16678048.html) | ||
|
||
## 国内学习博客 | ||
|
||
* [OpenCascade基本框架介绍-昨夜星辰 (hustlei.github.io)](https://hustlei.github.io/2014/10/opencascade-introduction-and-compile.html) | ||
* [OpenCASCADE入门指南 - opencascade - 博客园 (cnblogs.com)](https://www.cnblogs.com/opencascade/p/OpenCASCADE_StartGuide.html) | ||
* [2.OpenCASCADE - eryar - C++博客 (cppblog.com)](http://cppblog.com/eryar/category/17808.html?Show=All) | ||
|
||
## 引用资料 | ||
|
||
* [Build 3rd-parties - Open CASCADE Technology Documentation](https://dev.opencascade.org/doc/overview/html/build_upgrade_building_3rdparty.html#build_3rdparty_linux) | ||
* [Build OCCT - Open CASCADE Technology Documentation](https://dev.opencascade.org/doc/occt-7.6.0/overview/html/build_upgrade__building_occt.html#build_occt_win_cmake) | ||
* [Download - Open CASCADE Technology](https://dev.opencascade.org/release) | ||
* [3rd party Components](https://dev.opencascade.org/resources/download/3rd-party-components) | ||
* [TCL/TK 8.6](https://www.tcl.tk/software/tcltk/download.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: Ubuntu 编译 Qt + VTK + OCCT + samples | ||
date: 2023-05-25 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [OCCT] | ||
tags: [occt] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# Ubuntu 编译 Qt + VTK + OCCT + samples | ||
|
||
## 1. 卸载安装的Qt,编译安装Qt | ||
|
||
实践发现使用安装的`Qt`,编译带`samples`的`OCCT`在`CMake`阶段就出错(可能是Ubuntu系统中环境有问题,或者是没有完整设置`Qt`相关变量)。 | ||
|
||
使用手动编译安装的`Qt`,并设置好相关环境变量可正常编译带`samples`的`OCCT`。手动编译安装`Qt`见:[VTK(1):ubuntu 22.04 源码编译安装 Qt5.15.6](https://www.cnblogs.com/vaughnhuang/articles/16678048.html) 。 | ||
|
||
## 2. 编译 VTK | ||
|
||
[VTK (2):ubuntu 22.04 编译 VTK 9.2 rc2](https://www.cnblogs.com/vaughnhuang/articles/16683118.html) | ||
|
||
## 2. 编译 OCCT 及 samples | ||
|
||
顶层`CMakeLists.txt`中有变量`BUILD_SAMPLES_QT`控制是否编译`samples`(包括qt相关samples)。 | ||
|
||
```bash | ||
cmake -D3RDPARTY_QT_DIR=/usr/local/Qt-5.15.6 -DCMAKE_BUILD_TYPE=Debug -DBUILD_SAMPLES_QT=ON .. | ||
make -j | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: OCC boundding box 以及 distance | ||
date: 2023-06-12 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [OCCT] | ||
tags: [occt] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# OCC boundding box 以及 distance | ||
|
||
## bounding box 方式检测 | ||
|
||
```C++ | ||
#include <Bnd_Box.hxx> | ||
#include <BRepBndLib.hxx> | ||
|
||
TopoDS_Shape shape1, shape2; // Assume these shapes are already defined | ||
Bnd_Box boundingBox1, boundingBox2; | ||
|
||
BRepBndLib::Add(shape1, boundingBox1); | ||
BRepBndLib::Add(shape2, boundingBox2); | ||
|
||
bool isInterfering = !boundingBox1.IsOut(boundingBox2); | ||
``` | ||
## distance 方式检测 | ||
```C++ | ||
#include <BRepExtrema_DistShapeShape.hxx> | ||
BRepExtrema_DistShapeShape distShapeShape(shape1, shape2); | ||
Standard_Real minDistance = distShapeShape.Value(); | ||
bool isInterfering = (minDistance <= Precision::Confusion()); | ||
``` | ||
|
||
* BRepExtrema_DistShapeShape 比 bounding box 方式费时; | ||
* 如果`bouding box`方式检测出来出现干涉(interference, overlap),则可以使用`distance`检测方式确认; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: OCC TopExp_Explorer 用法 | ||
date: 2023-06-12 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [OCCT] | ||
tags: [occt] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# OCC TopExp_Explorer 用法 | ||
|
||
```c++ | ||
#include <iostream> | ||
#include <TopoDS_Shape.hxx> | ||
#include <TopExp_Explorer.hxx> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
// Create a TopoDS_Shape object. | ||
TopoDS_Shape shape; | ||
|
||
// Create a TopExp_Explorer object and explore the shape. | ||
TopExp_Explorer exp(shape, TopAbs_FACE); | ||
|
||
// While there are more faces, print the face's name. | ||
while (exp.More()) | ||
{ | ||
cout << exp.Current().Name() << endl; | ||
exp.Next(); | ||
} | ||
|
||
return 0; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: OCCT 使用 BVH 树加速 bounding box 查找遍历 | ||
date: 2023-06-14 +0800 # 2022-01-01 13:14:15 +0800 只写日期也行;不写秒也行;这样也行 2022-03-09T00:55:42+08:00 | ||
categories: [OCCT] | ||
tags: [occt] # TAG names should always be lowercase | ||
|
||
# 以下默认false | ||
math: true | ||
mermaid: true | ||
# pin: true | ||
--- | ||
|
||
# OCCT 使用 BVH 树加速 bounding box 查找遍历 | ||
|
||
## Demo code | ||
|
||
### Demo code 1 | ||
|
||
```C++ | ||
#include <BVH_Tree.hxx> | ||
#include <TopoDS_Shape.hxx> | ||
#include <vector> | ||
|
||
// Assuming you have a vector of TopoDS_Shape objects called 'shapes' | ||
|
||
// Create a BVH tree | ||
Handle(BVH_Tree<Standard_Real, 3>) bvhTree = new BVH_Tree<Standard_Real, 3>(); | ||
|
||
// Insert the shapes into the BVH tree | ||
for (const auto& shape : shapes) { | ||
// Compute the bounding box for the shape | ||
Bnd_Box box; | ||
BRepBndLib::Add(shape, box); | ||
|
||
// Insert the bounding box into the BVH tree | ||
bvhTree->Insert(box, shape); | ||
} | ||
|
||
// a query on the BVH tree to find possible interference | ||
bvhTree->Select([](const TopoDS_Shape& shape1, const TopoDS_Shape& shape2) { | ||
// Check for interference between shape1 and shape2 | ||
// If there is interference, process it accordingly | ||
}); | ||
|
||
``` | ||
### Demo code 2 | ||
```C++ | ||
#include <SpatialHash.hxx> | ||
#include <TopoDS_Shape.hxx> | ||
int main() | ||
{ | ||
// Create a spatial hash from the shapes. | ||
SpatialHash hash(shapes.size()); | ||
for (TopoDS_Shape& shape : shapes) | ||
{ | ||
hash.Add(shape); | ||
} | ||
// Find possibly interfering objects. | ||
for (TopoDS_Shape& shape : shapes) | ||
{ | ||
std::vector<TopoDS_Shape> interferingObjects = hash.Find(shape); | ||
for (TopoDS_Shape& otherShape : interferingObjects) | ||
{ | ||
// Check if the shapes interfere. | ||
} | ||
} | ||
return 0; | ||
} | ||
``` | ||
|
||
## References | ||
|
||
* [几何体数据结构学习(6)BVH树](https://zhuanlan.zhihu.com/p/430469154) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.