-
-
Notifications
You must be signed in to change notification settings - Fork 383
Porting from 0.18.x to 7.4.0
Thomas Paviot edited this page Feb 27, 2020
·
4 revisions
From releases 0.18.x to 7.4.0, pythonocc moved up from open cascade technology (OCCT) 6.9 to 7.4.0. This new release comes with two major changes:
- API changes related to the C++ API itself. There has been new classes, deprecated classes removed, new methods, deprecated methods remove etc. OCCT also made major changes to its smart pointers (known as Handles). This wiki page cannot gives the exhaustive list of changes. To trace these changes, refer to:
-
the OCCT official release notes at https://www.opencascade.com/content/previous-releases Each release comes with its release notes, and the major changes to the API.
-
the OCCT official API documentation, generated with doxygen, at https://www.opencascade.com/doc/occt-7.4.0/refman/html/index.html
- Changes to the python wrapper itself:
-
transparent handles: under pythonocc 0.18.x and before, OCCT smart pointers were wrapped using
GetObjet()
andGetHandle()
methods and you had to care about using Handles or the base class. With pythonocc 7.4 and above, this difference is not visible anymore thanks to "transparent handles". You don't have to worry about those handles, everything is performed by the wrapper. To port your old code, just remove all the calls toGetHandle
andGetObject
. For example, the commit related to the occ classical example port is available here: https://github.com/tpaviot/pythonocc-demos/commit/e59acdce5720d84ce76134789b48c268e36446d6#diff-68b70730ce65eb74e098809766ab3d0d
# Build edges and wires for threading
# Old code (pythonocc 0.18.x)
anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(Handle_Geom2d_Curve(anArc1), Handle_Geom_Surface(aCyl1))
# New Code (pythonocc 7.4.0)
anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(Geom2d_Curve(anArc1), Geom_Surface(aCyl1))
-
new package structure: move all
from OCC.xxx
imports tofrom OCC.Core.xxx
, for instance:
# Old Code (pythonocc 0.18.x)
from OCC.gp import gp_Pnt, gp_OX, gp_Vec, gp_Trsf
# New Code (pythonocc 7.4.0)
from OCC.Core.gp import gp_Pnt, gp_OX, gp_Vec, gp_Trsf
- smart inheritance*: no need to DownCast anything anymore. Base classes are automatically identified by the wrapper. This result in the following change, for example:
# Old Code (pythonocc 0.18.x)
geom_plane = Geom_Plane(some_gp_pln)
h_surface = Handle_Geom_Surface(geom_plane)
e1 = BRepBuilderAPI_MakeEdge(seg1.Value(), h_surface)
# New Code (pythonocc 7.4.0)
geom_plane = Geom_Plane(some_gp_pln)
e1 = BRepBuilderAPI_MakeEdge(seg1.Value(), geom_plane)