Skip to content

Commit c2f9d1b

Browse files
authored
Merge pull request #1261 from tpaviot/review/prepare-772
Review/prepare 772
2 parents a43f1f7 + d7c5219 commit c2f9d1b

File tree

325 files changed

+60399
-14482
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+60399
-14482
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set(PYTHONOCC_VERSION_MINOR 7)
2525
set(PYTHONOCC_VERSION_PATCH 2)
2626

2727
# Empty for official releases, set to -dev, -rc1, etc for development releases
28-
set(PYTHONOCC_VERSION_DEVEL -dev)
28+
set(PYTHONOCC_VERSION_DEVEL )
2929

3030
# set OCCT version
3131
set(OCCT_VERSION_MAJOR 7)

INSTALL.md

+68-54
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,105 @@
1-
Overview
2-
--------
3-
4-
pythonOCC is a python library whose purpose is to provide 3D modeling features.
5-
It's intended to
6-
developers who aim at developing a complete CAD/PLM application, and to
7-
engineers who want to have a total control over the data during complex design
8-
activities.
9-
10-
About this document
11-
-------------------
12-
13-
This file explains how to build pythonocc-core from source on Windows, Linux or
14-
MacOSX platforms.
1+
Build pythonocc-7.7.2 from scratch on a fresh Ubuntu 22.04 install
2+
------------------------------------------------------------------
153

164
Requirements
175
------------
186

19-
pythonOCC needs the following libraries or programs to be installed before you
7+
pythonOCC-7.7.2 needs the following libraries or programs to be installed before you
208
can compile/use it:
219

22-
* the python programming language (<https://www.python.org>). Python 3.x is required.
10+
* the python programming language (<https://www.python.org>). Python 3.8 or more is required.
2311

24-
* OpenCascade 7.7.0 (<https://dev.opencascade.org>)
12+
* OpenCascade 7.7.2 (<https://dev.opencascade.org>)
2513

26-
IMPORTANT: OpenCASCADE has to be compiled using flag -D BUILD_RELEASE_DISABLE_EXCEPTIONS=OFF
14+
* SWIG 4.1.1 (<https://www.swig.org>)
2715

28-
* SWIG 4.0.2 (<https://www.swig.org>)
16+
* rapidjson (<https://rapidjson.org/>) for Gltf import/export
2917

30-
Optional
31-
--------
32-
33-
If you want to benefit from a 3D graphical rendering, you will need a GUI manager, e.g. PyQt, PySide or wxPython.
34-
35-
Create a local copy of the repository
36-
-------------------------------------
18+
* cmake
3719

20+
All the necessary libraries can be downloaded/installed using apt:
3821
```bash
39-
git clone https://github.com/tpaviot/pythonocc-core.git
22+
$ sudo apt-get update
23+
$ sudo apt-get install -y wget libglu1-mesa-dev libgl1-mesa-dev libxmu-dev libxi-dev build-essential cmake libfreetype6-dev tk-dev python3-dev rapidjson-dev python3 git python3-pip libpcre2-dev
4024
```
4125

42-
pythonocc-core compilation
43-
--------------------------
44-
26+
Build swig
27+
----------
28+
The required swgi version is 4.1.1. Unfortunately, the ubuntu ppa only provides an outdated 4.0.2 version. If swig 4.1.1 is not available on your machine, you have to download/build by yourself (depends on libpcre2, previously installed):
4529
```bash
46-
cd pythonocc-core
47-
mkdir cmake-build
48-
cd cmake-build
30+
$ wget http://prdownloads.sourceforge.net/swig/swig-4.1.1.tar.gz
31+
$ tar -zxvf swig-4.1.1.tar.gz
32+
$ cd swig-4.1.1
33+
$ ./configure && make -j4 && make install
4934
```
5035

51-
The configuration steps uses cmake:
36+
Build OpenCascade
37+
-----------------
38+
39+
Download/extract version 7.7.2 https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=cec1ecd0c9f3b3d2572c47035d11949e8dfa85e2;sf=tgz
5240

5341
```bash
54-
cmake ..
42+
$ wget -o occt-7.7.2.tgz https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=cec1ecd0c9f3b3d2572c47035d11949e8dfa85e2;sf=tgz
43+
$ tar -zxvf occt-7.7.2.tgz
5544
```
5645

57-
By default, cmake looks for oce include headers in /usr/local/include/oce and
58-
libraries in /usr/local/include/lib. If these paths don't match your
59-
installation, you have to set OCE_INCLUDE_PATH and OCE_LIB_PATH:
60-
46+
Prepare the build stage:
6147
```bash
62-
cmake -DOCE_INCLUDE_PATH=/your_oce_headers -DOCE_LIB_PATH=/your_lib_dir ..
48+
$ cd occt-cec1ecd
49+
$ mkdir cmake-build
50+
$ cd cmake-build
6351
```
6452

65-
And launch the build process
66-
53+
Choose an installation destination. Default is /usr/local, but it is better to set up
54+
an other folder so that it's easier to work with concurrent versions.
6755
```bash
68-
make
56+
$ cmake -DINSTALL_DIR=/opt/build/occt772 -DBUILD_RELEASE_DISABLE_EXCEPTIONS=OFF ..
6957
```
70-
71-
If you have many cpus, you can increase the compilation speed with:
72-
58+
then
7359
```bash
74-
make -j$ncpus
60+
$ make -j4
61+
```
62+
and finally add the libraries to the system
63+
```bash
64+
echo "/opt/build/occt772/lib" >> /etc/ld.so.conf.d/occt.conf
7565
```
7666

77-
According to your machine/os/ncpus, the total compilation time should be around 15 minutes.
67+
Build pythonocc
68+
---------------
69+
First create a local copy of the git repository:
70+
```bash
71+
git clone https://github.com/tpaviot/pythonocc-core.git
72+
```
73+
then
74+
```bash
75+
cd xx/pythonocc-core
76+
mkdir cmake-build && cd cmake-build
7877

79-
Then
78+
RUN cmake \
79+
-DOCCT_INCLUDE_DIR=/opt/build/occt772/include/opencascade \
80+
-DOCCT_LIBRARY_DIR=/opt/build/occt772/lib \
81+
-DPYTHONOCC_BUILD_TYPE=Release \
82+
..
8083

81-
```bash
82-
make install
84+
RUN make -j4 && make install
8385
```
8486

85-
You may require admin privileges to install
87+
simple test
88+
-----------
89+
```
90+
$ python
91+
>>> from OCC.Core.gp import gp_Pnt
92+
>>> p = gp_Pnt(1., 2., 3.)
93+
>>> p.X()
94+
1.0
95+
>>>
96+
```
8697

87-
```bash
88-
sudo make install
98+
additional dependencies
99+
-----------------------
100+
Additional python packages are required if you want to benefit from all pythonocc features.
101+
```
102+
pip install svgwrite numpy matplotlib PyQt5
89103
```
90104

91105
test

NEWS

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
Version 7.7.2 - October 2023
2+
=============================
3+
4+
This release requires opencascade-7.7.2
5+
6+
* wrapper: port to opencascade-7.7.2
7+
8+
* wrapper: bump swig version to 4.1.1
9+
10+
* wrapper: new wrappers for RWPly, Unitsmethod
11+
12+
* wrapper: handle TCollection_AsciiString, Standard_CString, TCollection_ExtendedString as
13+
python strings
14+
15+
* wrapper: pickle objects that provide json serializer
16+
17+
* dataexchange: glt importer/exporter, ply exporter, obj exporter
18+
19+
* display: support for PyQt6 and PySide6
20+
21+
* webgl: refactored threejs and x3dom renderer to stay sync with latest releases
22+
23+
* display: new tkinter renderer, making PyQt or wx GUI managers optional
24+
25+
* cmake installer: respect CMake install prefix
26+
127
Version 7.7.0 - November 2022
228
=============================
329

README.md

+19-24
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Downloads Badge](https://anaconda.org/conda-forge/pythonocc-core/badges/downloads.svg)](https://anaconda.org/conda-forge/pythonocc-core)
33
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/tpaviot/pythonocc-core.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/tpaviot/pythonocc-core/context:python)
44
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67c121324b8d4f37bc27029464c87020)](https://www.codacy.com/app/tpaviot/pythonocc-core?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=tpaviot/pythonocc-core&amp;utm_campaign=Badge_Grade)
5-
[![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/7.7.0)
5+
[![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/7.7.2)
66
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3605364.svg)](https://doi.org/10.5281/zenodo.3605364)
77

88
pythonocc-core
@@ -13,59 +13,54 @@ About
1313

1414
pythonocc provides 3D modeling and dataexchange features. It is intended to CAD/PDM/PLM and BIM related development. It is based on the OpenCascade Technology modeling kernel.
1515

16-
Latest release: [pythonocc-core 7.7.0 (December 2022)](https://github.com/tpaviot/pythonocc-core/releases/tag/7.7.0)
16+
Latest release: [pythonocc-core 7.7.2 (October 2023)](https://github.com/tpaviot/pythonocc-core/releases/tag/7.7.2)
1717

1818
Features
1919
--------
2020
pythonocc provides the following features:
2121

2222
* a full access from Python to almost all af the thousand OpenCascade C++ classes. Classes and methods/functions share the same names, and, as possible as it can be, the same signature
23-
* 3D visualization from the most famous Python Gui (pyQt, PySide1 and 2, wxPython)
24-
* 3D visualization in a web browser using WebGl and/or x3dom renderers
23+
* 3D visualization from the most famous Python Gui (tkinter, pyQt5 and 6, PySide2 and 6, wxPython)
24+
* 3D visualization in a web browser using threejs or x3dom frameworks
2525
* 3D visualization and work within a jupyter notebook
26-
* Various utility Python classes/methods for DataExchange, Topology operations, inertia computations etc.
27-
28-
Cite as
29-
-------
30-
31-
pythonocc is widely used in the industrial and academic communities. It is registered as a Zenodo open caccess software (https://zenodo.org/record/7471333) and should be cited as:
32-
33-
Thomas Paviot. (2022). pythonocc (7.7.0). Zenodo. https://doi.org/10.5281/zenodo.3605364
26+
* data exchange using most famous formats IGES/STEP/STL/PLY/OBJ/GLTF
27+
* various utility Python classes/methods for Topology operations, inertia computations etc.
3428

3529
Try online at mybinder
3630
----------------------
31+
Click [![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/7.7.0) to open a jupyter notebook running the latest pythonocc-core 7.7.2, gmesh (<http://gmsh.info/>) and latest IfcOpenshell (<https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0>) dev branch.
3732

38-
Click [![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/tpaviot/pythonocc-binderhub/7.7.0) to open a jupyter notebook running latest pythonocc-core 7.7.0, gmesh (<http://gmsh.info/>) and latest IfcOpenshell (<https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0>) dev branch.
39-
40-
Download/install binaries for Linux/OSX/Windows
41-
-----------------------------------------------
42-
43-
pythonocc provides precompiled [conda packages](https://anaconda.org/pythonocc/pythonocc-core) (they depend on third part libraries made available from the dlr-sc and conda-forge conda channels) for python 3.8, 3.9 and 3.10. This will get you up and running in minutes whether you run win32/win64/linux64/osx64. Here is an example for python 3.9:
33+
Install with conda
34+
------------------
35+
pythonocc provides precompiled [conda packages](https://anaconda.org/pythonocc/pythonocc-core) (they depend on third part libraries made available from the conda-forge channel) for python 3.8, 3.9 and 3.10. This will get you up and running in minutes whether you run win32/win64/linux64/osx64. Here is an example for python 3.9:
4436

4537
```bash
4638
# first create an environment
4739
conda create --name=pyoccenv python=3.9
4840
source activate pyoccenv
49-
conda install -c conda-forge pythonocc-core=7.7.0
41+
conda install -c conda-forge pythonocc-core=7.7.2
5042
```
5143

5244
Other conda channels may provide pythonocc-core packages, check https://anaconda.org/search?q=pythonocc-core.
5345

5446
Build from source
5547
-----------------
56-
5748
Read the [INSTALL.md](https://github.com/tpaviot/pythonocc-core/blob/master/INSTALL.md) instructions where you find compilation instructions for all platforms.
5849

50+
51+
Cite as
52+
-------
53+
pythonocc is widely used in the industrial and academic communities. It is registered as a Zenodo open caccess software (https://zenodo.org/record/7471333) and should be cited as:
54+
55+
Thomas Paviot. (2022). pythonocc (7.7.2). Zenodo. https://doi.org/10.5281/zenodo.3605364
56+
5957
Other pythonocc related resources
6058
---------------------------------
61-
6259
* Demos: python examples, as well as jupyter notebooks <https://github.com/tpaviot/pythonocc-demos>. A good place to start with pythonocc
6360
* Docker, binderhub: docker and online jupyter notebooks <https://github.com/tpaviot/pythonocc-binderhub>
6461
* Documentation: <https://github.com/tpaviot/pythonocc-documentation>
6562
* <https://github.com/tpaviot/pythonocc-generator> automates the production of SWIG interface files used for the OpenCascade python wrapper
6663

6764
License
6865
-------
69-
70-
You can redistribute it and/or modify it under the terms of the GNU Lesser
71-
General Public License version 3 as published by the Free Software Foundation.
66+
You can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation.

src/Display/SimpleGui.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ def call_function(s, func: Callable) -> None:
8181
# returns empty classes and functions
8282
return offscreen_renderer, do_nothing, do_nothing, call_function
8383

84-
if backend_str in ["wx", "pyside2", "pyside6", "pyqt5", "pyqt6"]:
85-
used_backend = load_backend(backend_str)
86-
else: # default to tk in all other cases
87-
used_backend = "tk"
84+
used_backend = load_backend(backend_str)
8885

8986
# tkinter SimpleGui
9087
if used_backend == "tk":

src/Display/WebGl/flask_server.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ def convert_shape(
125125
edge_content = ""
126126
nbr_vertices = tess.ObjEdgeGetVertexCount(i_edge)
127127
edge_point_set = [
128-
tess.GetEdgeVertex(i_edge, i_vert)
129-
for i_vert in range(nbr_vertices)
128+
tess.GetEdgeVertex(i_edge, i_vert) for i_vert in range(nbr_vertices)
130129
]
131130
# write to file
132131
edge_hash = f"edg{uuid.uuid4().hex}"

src/Display/WebGl/jupyter_renderer.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
from OCC.Core.Bnd import Bnd_Box
6363
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeSphere
64-
from OCC.Core.BRepBndLib import brepbndlib_Add
64+
from OCC.Core.BRepBndLib import brepbndlib
6565
from OCC.Core.gp import gp_Pnt, gp_Dir
6666
from OCC.Core.TopoDS import TopoDS_Compound
6767
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeVertex
@@ -373,7 +373,7 @@ def _max_dist_from_origin(self):
373373
def _bounding_box(self, obj, tol=1e-5):
374374
bbox = Bnd_Box()
375375
bbox.SetGap(self.tol)
376-
brepbndlib_Add(obj, bbox, True)
376+
brepbndlib.Add(obj, bbox, True)
377377
values = bbox.Get()
378378
return (values[0], values[3], values[1], values[4], values[2], values[5])
379379

@@ -1039,9 +1039,7 @@ def Display(self, position=None, rotation=None):
10391039
)
10401040

10411041
# Set up Controllers
1042-
self._controller = OrbitControls(
1043-
controlling=self._camera, target=camera_target, target0=camera_target
1044-
)
1042+
self._controller = OrbitControls(controlling=self._camera, target=camera_target)
10451043
# Update controller to instantiate camera position
10461044
self._camera.zoom = camera_zoom
10471045
self._update()

src/Display/backend.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
PYSIDE2 = "pyside2"
2626
PYQT6 = "pyqt6"
2727
PYSIDE6 = "pyside6"
28+
TK = "tk"
2829

2930
# backend module
3031
HAVE_PYQT5, HAVE_PYSIDE2, HAVE_PYQT6, HAVE_PYSIDE6, HAVE_WX = (
@@ -206,7 +207,7 @@ def load_backend(backend_str=None):
206207
return BACKEND_MODULE
207208

208209
if backend_str is not None:
209-
compatible_backends = (PYQT5, PYQT6, PYSIDE2, PYSIDE6, WX)
210+
compatible_backends = (PYQT5, PYQT6, PYSIDE2, PYSIDE6, WX, TK)
210211
if backend_str not in compatible_backends:
211212
msg = (
212213
f"incompatible backend_str specified: {backend_str}\n"
@@ -270,11 +271,8 @@ def load_backend(backend_str=None):
270271
log.exception("%s backend could not be loaded", backend_str)
271272
raise ValueError(msg)
272273

273-
if not HAVE_BACKEND:
274-
raise ImportError(
275-
"No compliant GUI library could be imported.\n"
276-
"Either PyQt5, PyQt6 or wxPython is required."
277-
)
274+
# finally, return a tk backend, available on all machines
275+
return "tk"
278276

279277

280278
def get_qt_modules():

src/Extend/TopologyUtils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ def _loop_topo(
226226
]
227227
else:
228228
index_list = filter_orientation_hash_codes[i_hash_code]
229-
unique = not any(i.IsSame(filter_orientation_seq[j]) for j in index_list)
229+
unique = not any(
230+
i.IsSame(filter_orientation_seq[j]) for j in index_list
231+
)
230232
if unique:
231233
filter_orientation_seq.append(i)
232234
index_list.append(len(filter_orientation_seq) - 1)

src/PkgBase/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
PYTHONOCC_VERSION_PATCH = 2
44

55
# Empty for official releases, set to -dev, -rc1, etc for development releases
6-
PYTHONOCC_VERSION_DEVEL = "-dev"
6+
PYTHONOCC_VERSION_DEVEL = ""
77

88
VERSION = f"{PYTHONOCC_VERSION_MAJOR}.{PYTHONOCC_VERSION_MINOR}.{PYTHONOCC_VERSION_PATCH}{PYTHONOCC_VERSION_DEVEL}"

0 commit comments

Comments
 (0)