From 42f7b691497638b2a3178feeb36d341d87709622 Mon Sep 17 00:00:00 2001 From: adam-urbanczyk Date: Sat, 8 Dec 2018 22:50:42 +0100 Subject: [PATCH] Use the new OCC submodule structure --- cadquery/occ_impl/exporters.py | 18 +++---- cadquery/occ_impl/geom.py | 14 +++--- cadquery/occ_impl/importers.py | 6 +-- cadquery/occ_impl/jupyter_tools.py | 4 +- cadquery/occ_impl/shapes.py | 80 +++++++++++++++--------------- tests/TestCadQuery.py | 2 +- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/cadquery/occ_impl/exporters.py b/cadquery/occ_impl/exporters.py index 175f2ae7..4da5a516 100644 --- a/cadquery/occ_impl/exporters.py +++ b/cadquery/occ_impl/exporters.py @@ -1,5 +1,5 @@ from __future__ import unicode_literals -from OCC.Visualization import Tesselator +from OCC.Core.Visualization import Tesselator import cadquery @@ -14,14 +14,14 @@ else: from .shapes import Shape, Compound, TOLERANCE from .geom import BoundBox -from OCC.gp import gp_Ax2, gp_Pnt, gp_Dir -from OCC.BRep import BRep_Tool -from OCC.BRepMesh import BRepMesh_IncrementalMesh -from OCC.BRepLib import breplib -from OCC.TopLoc import TopLoc_Location -from OCC.HLRBRep import HLRBRep_Algo, HLRBRep_HLRToShape -from OCC.HLRAlgo import HLRAlgo_Projector -from OCC.GCPnts import GCPnts_QuasiUniformDeflection +from OCC.Core.gp import gp_Ax2, gp_Pnt, gp_Dir +from OCC.Core.BRep import BRep_Tool +from OCC.Core.BRepMesh import BRepMesh_IncrementalMesh +from OCC.Core.BRepLib import breplib +from OCC.Core.TopLoc import TopLoc_Location +from OCC.Core.HLRBRep import HLRBRep_Algo, HLRBRep_HLRToShape +from OCC.Core.HLRAlgo import HLRAlgo_Projector +from OCC.Core.GCPnts import GCPnts_QuasiUniformDeflection try: import xml.etree.cElementTree as ET diff --git a/cadquery/occ_impl/geom.py b/cadquery/occ_impl/geom.py index ccc0b6f1..1a929a1e 100644 --- a/cadquery/occ_impl/geom.py +++ b/cadquery/occ_impl/geom.py @@ -1,10 +1,10 @@ import math import cadquery -from OCC.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp, gp_XYZ -from OCC.Bnd import Bnd_Box -from OCC.BRepBndLib import brepbndlib_Add # brepbndlib_AddOptimal -from OCC.BRepMesh import BRepMesh_IncrementalMesh +from OCC.Core.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp, gp_XYZ +from OCC.Core.Bnd import Bnd_Box +from OCC.Core.BRepBndLib import brepbndlib_Add # brepbndlib_AddOptimal +from OCC.Core.BRepMesh import BRepMesh_IncrementalMesh TOL = 1e-2 @@ -43,7 +43,7 @@ class Vector(object): elif len(args) == 0: fV = gp_Vec(0, 0, 0) else: - raise ValueError("Expected three floats, OCC Geom_, or 3-tuple") + raise ValueError("Expected three floats, OCC.Core.Geom_, or 3-tuple") self._wrapped = fV @@ -168,7 +168,7 @@ class Vector(object): def transform(self, T): - # to gp_Pnt to obey cq transformation convention (in OCC vectors do not translate) + # to gp_Pnt to obey cq transformation convention (in OCC.Core.vectors do not translate) pnt = self.toPnt() pnt_t = pnt.Transformed(T.wrapped) @@ -652,7 +652,7 @@ class Plane(object): class BoundBox(object): - """A BoundingBox for an object or set of objects. Wraps the OCC one""" + """A BoundingBox for an object or set of objects. Wraps the OCC.Core.one""" def __init__(self, bb): self.wrapped = bb diff --git a/cadquery/occ_impl/importers.py b/cadquery/occ_impl/importers.py index fa3bdb4c..d32035c3 100644 --- a/cadquery/occ_impl/importers.py +++ b/cadquery/occ_impl/importers.py @@ -7,8 +7,8 @@ import os import urllib as urlreader import tempfile -from OCC.STEPControl import STEPControl_Reader -import OCC.IFSelect +from OCC.Core.STEPControl import STEPControl_Reader +import OCC.Core.IFSelect class ImportTypes: @@ -41,7 +41,7 @@ def importStep(fileName): # Now read and return the shape reader = STEPControl_Reader() readStatus = reader.ReadFile(fileName) - if readStatus != OCC.IFSelect.IFSelect_RetDone: + if readStatus != OCC.Core.IFSelect.IFSelect_RetDone: raise ValueError("STEP File could not be loaded") reader.TransferRoot() diff --git a/cadquery/occ_impl/jupyter_tools.py b/cadquery/occ_impl/jupyter_tools.py index d7ef310b..4a787f5d 100644 --- a/cadquery/occ_impl/jupyter_tools.py +++ b/cadquery/occ_impl/jupyter_tools.py @@ -1,5 +1,5 @@ -from OCC.Display.WebGl.x3dom_renderer import X3DExporter -from OCC.gp import gp_Quaternion, gp_Vec +from OCC.Core.Display.WebGl.x3dom_renderer import X3DExporter +from OCC.Core.gp import gp_Quaternion, gp_Vec from uuid import uuid1 from math import tan diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index 86688b68..4275f78d 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -1,15 +1,15 @@ from cadquery import Vector, BoundBox -import OCC.TopAbs as ta # Tolopolgy type enum -import OCC.GeomAbs as ga # Geometry type enum +import OCC.Core.TopAbs as ta # Tolopolgy type enum +import OCC.Core.GeomAbs as ga # Geometry type enum -from OCC.gp import (gp_Vec, gp_Pnt, gp_Ax1, gp_Ax2, gp_Ax3, gp_Dir, gp_Circ, +from OCC.Core.gp import (gp_Vec, gp_Pnt, gp_Ax1, gp_Ax2, gp_Ax3, gp_Dir, gp_Circ, gp_Trsf, gp_Pln, gp_GTrsf, gp_Pnt2d, gp_Dir2d) # collection of pints (used for spline construction) -from OCC.TColgp import TColgp_Array1OfPnt -from OCC.BRepAdaptor import BRepAdaptor_Curve, BRepAdaptor_Surface -from OCC.BRepBuilderAPI import (BRepBuilderAPI_MakeVertex, +from OCC.Core.TColgp import TColgp_Array1OfPnt +from OCC.Core.BRepAdaptor import BRepAdaptor_Curve, BRepAdaptor_Surface +from OCC.Core.BRepBuilderAPI import (BRepBuilderAPI_MakeVertex, BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeFace, BRepBuilderAPI_MakePolygon, @@ -18,14 +18,14 @@ from OCC.BRepBuilderAPI import (BRepBuilderAPI_MakeVertex, BRepBuilderAPI_GTransform, BRepBuilderAPI_Transform) # properties used to store mass calculation result -from OCC.GProp import GProp_GProps -from OCC.BRepGProp import BRepGProp_Face, \ +from OCC.Core.GProp import GProp_GProps +from OCC.Core.BRepGProp import BRepGProp_Face, \ brepgprop_LinearProperties, \ brepgprop_SurfaceProperties, \ brepgprop_VolumeProperties # used for mass calculation -from OCC.BRepLProp import BRepLProp_CLProps # local curve properties +from OCC.Core.BRepLProp import BRepLProp_CLProps # local curve properties -from OCC.BRepPrimAPI import (BRepPrimAPI_MakeBox, # TODO list functions/used for making primitives +from OCC.Core.BRepPrimAPI import (BRepPrimAPI_MakeBox, # TODO list functions/used for making primitives BRepPrimAPI_MakeCone, BRepPrimAPI_MakeCylinder, BRepPrimAPI_MakeTorus, @@ -34,13 +34,13 @@ from OCC.BRepPrimAPI import (BRepPrimAPI_MakeBox, # TODO list functions/used fo BRepPrimAPI_MakeRevol, BRepPrimAPI_MakeSphere) -from OCC.TopExp import TopExp_Explorer # Toplogy explorer -from OCC.BRepTools import (BRepTools_WireExplorer, # might be needed for iterating thorugh wires +from OCC.Core.TopExp import TopExp_Explorer # Toplogy explorer +from OCC.Core.BRepTools import (BRepTools_WireExplorer, # might be needed for iterating thorugh wires breptools_UVBounds) # used for getting underlying geoetry -- is this equvalent to brep adaptor? -from OCC.BRep import BRep_Tool +from OCC.Core.BRep import BRep_Tool -from OCC.TopoDS import (topods_Vertex, # downcasting functions +from OCC.Core.TopoDS import (topods_Vertex, # downcasting functions topods_Edge, topods_Wire, topods_Face, @@ -48,65 +48,65 @@ from OCC.TopoDS import (topods_Vertex, # downcasting functions topods_Compound, topods_Solid) -from OCC.TopoDS import (TopoDS_Shell, +from OCC.Core.TopoDS import (TopoDS_Shell, TopoDS_Compound, TopoDS_Builder) -from OCC.GC import GC_MakeArcOfCircle # geometry construction -from OCC.GCE2d import GCE2d_MakeSegment -from OCC.GeomAPI import (GeomAPI_PointsToBSpline, +from OCC.Core.GC import GC_MakeArcOfCircle # geometry construction +from OCC.Core.GCE2d import GCE2d_MakeSegment +from OCC.Core.GeomAPI import (GeomAPI_PointsToBSpline, GeomAPI_ProjectPointOnSurf) -from OCC.BRepFill import brepfill_Shell, brepfill_Face +from OCC.Core.BRepFill import brepfill_Shell, brepfill_Face -from OCC.BRepAlgoAPI import (BRepAlgoAPI_Common, +from OCC.Core.BRepAlgoAPI import (BRepAlgoAPI_Common, BRepAlgoAPI_Fuse, BRepAlgoAPI_Cut) -from OCC.GeomLProp import GeomLProp_SLProps +from OCC.Core.GeomLProp import GeomLProp_SLProps -from OCC.Geom import Geom_ConicalSurface, Geom_CylindricalSurface -from OCC.Geom2d import Geom2d_Line +from OCC.Core.Geom import Geom_ConicalSurface, Geom_CylindricalSurface +from OCC.Core.Geom2d import Geom2d_Line -from OCC.BRepLib import breplib_BuildCurves3d +from OCC.Core.BRepLib import breplib_BuildCurves3d -from OCC.BRepOffsetAPI import (BRepOffsetAPI_ThruSections, +from OCC.Core.BRepOffsetAPI import (BRepOffsetAPI_ThruSections, BRepOffsetAPI_MakePipe, BRepOffsetAPI_MakePipeShell, BRepOffsetAPI_MakeThickSolid) -from OCC.BRepFilletAPI import (BRepFilletAPI_MakeChamfer, +from OCC.Core.BRepFilletAPI import (BRepFilletAPI_MakeChamfer, BRepFilletAPI_MakeFillet) -from OCC.TopTools import (TopTools_IndexedDataMapOfShapeListOfShape, +from OCC.Core.TopTools import (TopTools_IndexedDataMapOfShapeListOfShape, TopTools_ListOfShape) -from OCC.TopExp import topexp_MapShapesAndAncestors +from OCC.Core.TopExp import topexp_MapShapesAndAncestors -from OCC.TopTools import TopTools_HSequenceOfShape, Handle_TopTools_HSequenceOfShape +from OCC.Core.TopTools import TopTools_HSequenceOfShape, Handle_TopTools_HSequenceOfShape -from OCC.ShapeAnalysis import ShapeAnalysis_FreeBounds +from OCC.Core.ShapeAnalysis import ShapeAnalysis_FreeBounds -from OCC.ShapeFix import ShapeFix_Wire, ShapeFix_Face +from OCC.Core.ShapeFix import ShapeFix_Wire, ShapeFix_Face -from OCC.STEPControl import STEPControl_Writer, STEPControl_AsIs +from OCC.Core.STEPControl import STEPControl_Writer, STEPControl_AsIs -from OCC.BRepMesh import BRepMesh_IncrementalMesh -from OCC.StlAPI import StlAPI_Writer +from OCC.Core.BRepMesh import BRepMesh_IncrementalMesh +from OCC.Core.StlAPI import StlAPI_Writer -from OCC.TopTools import TopTools_DataMapOfShapeListOfShape, TopTools_ListIteratorOfListOfShape +from OCC.Core.TopTools import TopTools_DataMapOfShapeListOfShape, TopTools_ListIteratorOfListOfShape -from OCC.ShapeUpgrade import ShapeUpgrade_UnifySameDomain +from OCC.Core.ShapeUpgrade import ShapeUpgrade_UnifySameDomain -from OCC.BRepTools import breptools_Write +from OCC.Core.BRepTools import breptools_Write -from OCC.Visualization import Tesselator +from OCC.Core.Visualization import Tesselator from math import pi, sqrt TOLERANCE = 1e-6 DEG2RAD = 2 * pi / 360. -HASH_CODE_MAX = int(1e+6) # required by OCC HashCode +HASH_CODE_MAX = int(1e+6) # required by OCC.Core.HashCode shape_LUT = \ {ta.TopAbs_VERTEX: 'Vertex', @@ -1403,7 +1403,7 @@ class Compound(Shape, Mixin3D): return cls(comp) -# TODO this is likely not needed if sing PythonOCC correclty but we will see +# TODO this is likely not needed if sing PythonOCC.Core.correclty but we will see def sortWiresByBuildOrder(wireList, plane, result=[]): diff --git a/tests/TestCadQuery.py b/tests/TestCadQuery.py index 8a7f3d7c..9846ae0f 100644 --- a/tests/TestCadQuery.py +++ b/tests/TestCadQuery.py @@ -83,7 +83,7 @@ class TestCadQuery(BaseTest): r = r.toOCC() - import OCC + import OCC.Core as OCC self.assertEqual(type(r), OCC.TopoDS.TopoDS_Compound) def testToSVG(self):