diff --git a/cadquery/occ_impl/assembly.py b/cadquery/occ_impl/assembly.py index 365374e07..3cea87aff 100644 --- a/cadquery/occ_impl/assembly.py +++ b/cadquery/occ_impl/assembly.py @@ -36,7 +36,7 @@ Quantity_TOC_RGB, ) from OCP.BRepAlgoAPI import BRepAlgoAPI_Fuse -from OCP.TopTools import TopTools_ListOfShape +from OCP.collections import List_TopoDS_Shape as TopTools_ListOfShape from OCP.BOPAlgo import BOPAlgo_GlueEnum, BOPAlgo_Builder from OCP.TopoDS import TopoDS_Shape from OCP.gp import gp_EulerSequence diff --git a/cadquery/occ_impl/exporters/assembly.py b/cadquery/occ_impl/exporters/assembly.py index 05f9e8a89..4c52929b7 100644 --- a/cadquery/occ_impl/exporters/assembly.py +++ b/cadquery/occ_impl/exporters/assembly.py @@ -41,7 +41,9 @@ ) from OCP.PCDM import PCDM_StoreStatus from OCP.RWGltf import RWGltf_CafWriter -from OCP.TColStd import TColStd_IndexedDataMapOfStringString +from OCP.collections import ( + IndexedDataMap_TCollection_AsciiString_TCollection_AsciiString as TColStd_IndexedDataMapOfStringString, +) from OCP.Message import Message_ProgressRange from OCP.Interface import Interface_Static diff --git a/cadquery/occ_impl/geom.py b/cadquery/occ_impl/geom.py index 1a9074c59..2797b9ba3 100644 --- a/cadquery/occ_impl/geom.py +++ b/cadquery/occ_impl/geom.py @@ -360,7 +360,7 @@ def _rotate(self, direction: gp_Ax1, angle: float): new = gp_Trsf() new.SetRotation(direction, angle) - self.wrapped = self.wrapped * gp_GTrsf(new) + self.wrapped = self.wrapped.Multiplied(gp_GTrsf(new)) def inverse(self) -> "Matrix": @@ -890,7 +890,14 @@ class BoundBox(object): def __init__(self, bb: Bnd_Box) -> None: self.wrapped = bb - XMin, YMin, ZMin, XMax, YMax, ZMax = bb.Get() + XMin, YMin, ZMin, XMax, YMax, ZMax = ( + bb.GetXMin(), + bb.GetYMin(), + bb.GetZMin(), + bb.GetXMax(), + bb.GetYMax(), + bb.GetZMax(), + ) self.xmin = XMin self.xmax = XMax @@ -1135,7 +1142,7 @@ def inverse(self) -> "Location": def __mul__(self, other: "Location") -> "Location": - return Location(self.wrapped * other.wrapped) + return Location(self.wrapped.Multiplied(other.wrapped)) def __pow__(self, exponent: int) -> "Location": diff --git a/cadquery/occ_impl/importers/assembly.py b/cadquery/occ_impl/importers/assembly.py index 98dbc4de7..f85ce5752 100644 --- a/cadquery/occ_impl/importers/assembly.py +++ b/cadquery/occ_impl/importers/assembly.py @@ -4,7 +4,8 @@ from OCP.TopoDS import TopoDS_Shape from OCP.TCollection import TCollection_ExtendedString from OCP.Quantity import Quantity_ColorRGBA -from OCP.TDF import TDF_Label, TDF_LabelSequence +from OCP.TDF import TDF_Label +from OCP.collections import Sequence_TDF_Label as TDF_LabelSequence from OCP.IFSelect import IFSelect_RetDone from OCP.TDocStd import TDocStd_Document from OCP.TDataStd import TDataStd_Name, TDataStd_TreeNode diff --git a/cadquery/occ_impl/importers/dxf.py b/cadquery/occ_impl/importers/dxf.py index a6c5093d4..ab1d8b05f 100644 --- a/cadquery/occ_impl/importers/dxf.py +++ b/cadquery/occ_impl/importers/dxf.py @@ -9,11 +9,14 @@ import ezdxf from OCP.ShapeAnalysis import ShapeAnalysis_FreeBounds -from OCP.TopTools import TopTools_HSequenceOfShape +from OCP.collections import HSequence_TopoDS_Shape as TopTools_HSequenceOfShape from OCP.gp import gp_Pnt from OCP.Geom import Geom_BSplineCurve -from OCP.TColgp import TColgp_Array1OfPnt -from OCP.TColStd import TColStd_Array1OfReal, TColStd_Array1OfInteger +from OCP.collections import Array1_gp_Pnt as TColgp_Array1OfPnt +from OCP.collections import ( + Array1_double as TColStd_Array1OfReal, + Array1_int as TColStd_Array1OfInteger, +) from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeEdge diff --git a/cadquery/occ_impl/nurbs.py b/cadquery/occ_impl/nurbs.py index 9f77b1949..45fc079db 100644 --- a/cadquery/occ_impl/nurbs.py +++ b/cadquery/occ_impl/nurbs.py @@ -14,10 +14,13 @@ from casadi import ldl, ldl_solve, Linsol, DM, solve from OCP.Geom import Geom_BSplineCurve, Geom_BSplineSurface -from OCP.TColgp import TColgp_Array1OfPnt, TColgp_Array2OfPnt -from OCP.TColStd import ( - TColStd_Array1OfInteger, - TColStd_Array1OfReal, +from OCP.collections import ( + Array1_gp_Pnt as TColgp_Array1OfPnt, + Array2_gp_Pnt as TColgp_Array2OfPnt, +) +from OCP.collections import ( + Array1_int as TColStd_Array1OfInteger, + Array1_double as TColStd_Array1OfReal, ) from OCP.gp import gp_Pnt from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeFace diff --git a/cadquery/occ_impl/shapes.py b/cadquery/occ_impl/shapes.py index 31b125e37..fba948fed 100644 --- a/cadquery/occ_impl/shapes.py +++ b/cadquery/occ_impl/shapes.py @@ -63,21 +63,21 @@ ) # Array of points (used for B-spline construction): -from OCP.TColgp import ( - TColgp_HArray1OfPnt, - TColgp_HArray2OfPnt, - TColgp_Array1OfPnt, - TColgp_HArray1OfPnt2d, +from OCP.collections import ( + HArray1_gp_Pnt as TColgp_HArray1OfPnt, + HArray2_gp_Pnt as TColgp_HArray2OfPnt, + Array1_gp_Pnt as TColgp_Array1OfPnt, + HArray1_gp_Pnt2d as TColgp_HArray1OfPnt2d, ) # Array of vectors (used for B-spline interpolation): -from OCP.TColgp import TColgp_Array1OfVec +from OCP.collections import Array1_gp_Vec as TColgp_Array1OfVec # Array of booleans (used for B-spline interpolation): -from OCP.TColStd import TColStd_HArray1OfBoolean +from OCP.collections import HArray1_bool as TColStd_HArray1OfBoolean # Array of floats (used for B-spline interpolation): -from OCP.TColStd import TColStd_HArray1OfReal +from OCP.collections import HArray1_double as TColStd_HArray1OfReal from OCP.BRepAdaptor import ( BRepAdaptor_Curve, @@ -141,8 +141,7 @@ TopoDS_CompSolid, ) -from OCP.GC import GC_MakeArcOfCircle, GC_MakeArcOfEllipse # geometry construction -from OCP.GCE2d import GCE2d_MakeSegment +from OCP.GC import GC_MakeArcOfCircle, GC_MakeArcOfEllipse, GC_MakeSegment2d from OCP.gce import gce_MakeLin, gce_MakeDir from OCP.GeomAPI import ( GeomAPI_Interpolate, @@ -195,11 +194,10 @@ BRepFilletAPI_MakeFillet2d, ) -from OCP.TopTools import ( - TopTools_IndexedDataMapOfShapeListOfShape, - TopTools_ListOfShape, - TopTools_MapOfShape, - TopTools_IndexedMapOfShape, +from OCP.collections import ( + IndexedDataMap_TopoDS_Shape_List_TopoDS_Shape_TopTools_ShapeMapHasher as TopTools_IndexedDataMapOfShapeListOfShape, + List_TopoDS_Shape as TopTools_ListOfShape, + IndexedMap_TopoDS_Shape_TopTools_ShapeMapHasher as TopTools_IndexedMapOfShape, ) @@ -242,7 +240,7 @@ Graphic3d_VTA_TOP, ) -from OCP.NCollection import NCollection_Utf8String +from OCP.NCollection import NCollection_String as NCollection_Utf8String from OCP.BRepFeat import BRepFeat_MakeDPrism, BRepFeat_MakePrism @@ -288,7 +286,7 @@ ShapeAnalysis, ShapeAnalysis_WireOrder, ) -from OCP.TopTools import TopTools_HSequenceOfShape +from OCP.collections import HSequence_TopoDS_Shape as TopTools_HSequenceOfShape from OCP.GCPnts import ( GCPnts_AbscissaPoint, @@ -327,7 +325,7 @@ from OCP.Approx import Approx_ParametrizationType -from OCP.LProp3d import LProp3d_CLProps +from OCP.LProp import LProp_CLProps3d from OCP.BinTools import BinTools @@ -1797,7 +1795,7 @@ def siblings( TopExp.MapShapesAndAncestors_s( ctx.wrapped, inverse_shape_LUT[kind], shapetype(self.wrapped), shape_map, ) - exclude = TopTools_MapOfShape() + exclude = TopTools_IndexedMapOfShape() def _siblings(shapes: Iterable[Shape], level: int) -> set[Shape]: @@ -2590,7 +2588,7 @@ def curvatureAt( curve, param = self._curve_and_param(d, mode) - props = LProp3d_CLProps(curve, param, 2, resolution) + props = LProp_CLProps3d(curve, param, 2, resolution) return props.Curvature() @@ -3158,7 +3156,7 @@ def makeHelix( n_turns = height / pitch u_start = geom_line.Value(0.0) u_stop = geom_line.Value(n_turns * sqrt((2 * pi) ** 2 + pitch ** 2)) - geom_seg = GCE2d_MakeSegment(u_start, u_stop).Value() + geom_seg = GC_MakeSegment2d(u_start, u_stop).Value() e = BRepBuilderAPI_MakeEdge(geom_seg, geom_surf).Edge() @@ -3897,7 +3895,7 @@ def trim( # build (u,v) segments for el1, el2 in zip((pt1, pt2, pt3, *pts), (pt2, pt3, *pts, pt1)): - segs_uv.append(GCE2d_MakeSegment(gp_Pnt2d(*el1), gp_Pnt2d(*el2)).Value()) + segs_uv.append(GC_MakeSegment2d(gp_Pnt2d(*el1), gp_Pnt2d(*el2)).Value()) # convert to edges edges = [] @@ -5034,7 +5032,7 @@ def siblings( ctx.wrapped, inverse_shape_LUT[kind], t, shape_map, ) - exclude = TopTools_MapOfShape() + exclude = TopTools_IndexedMapOfShape() def _siblings(shapes: Iterable[Shape], level: int) -> set[Shape]: diff --git a/cadquery/occ_impl/solver.py b/cadquery/occ_impl/solver.py index 66bc71898..a56e2478b 100644 --- a/cadquery/occ_impl/solver.py +++ b/cadquery/occ_impl/solver.py @@ -418,7 +418,7 @@ def point_in_plane_cost( m1_dm = ca.DM((m1.X(), m1.Y(), m1.Z())) m2_dir = m2.Axis().Direction() - m2_pnt = m2.Axis().Location().Translated(val * gp_Vec(m2_dir)) + m2_pnt = m2.Axis().Location().Translated(gp_Vec(m2_dir).Scaled(val)) m2_dir_dm = ca.DM((m2_dir.X(), m2_dir.Y(), m2_dir.Z())) m2_pnt_dm = ca.DM((m2_pnt.X(), m2_pnt.Y(), m2_pnt.Z())) diff --git a/environment.yml b/environment.yml index 4608af03b..136b7db35 100644 --- a/environment.yml +++ b/environment.yml @@ -4,8 +4,8 @@ channels: dependencies: - python>=3.11 - ipython -# - cadquery/label/dev::ocp=x.x.x for dev - - ocp=7.9.3.1 + - cadquery/label/dev::ocp=8.0.0.0 +# - ocp=7.9.3.1 - pyparsing>=3.0.0 - sphinx=9.1.0 # - sphinx_rtd_theme=3.1.0 diff --git a/tests/test_cadquery.py b/tests/test_cadquery.py index a65ae3e54..d78c2ee37 100644 --- a/tests/test_cadquery.py +++ b/tests/test_cadquery.py @@ -5200,6 +5200,8 @@ def testSplineApprox(self): from .naca import naca5305 from math import pi, cos + import OCP + pts = [Vector(e[0], e[1], 0) for e in naca5305] # spline @@ -5211,7 +5213,7 @@ def testSplineApprox(self): self.assertTrue(e2.isValid()) self.assertTrue(e1.Length() > e2.Length()) - with raises(ValueError): + with raises(OCP.Standard.Standard_ConstructionError): e4 = Edge.makeSplineApprox(pts, 1e-6, maxDeg=3, smoothing=(1, 1, 1.0)) pts_closed = pts + [pts[0]] @@ -5258,7 +5260,7 @@ def testSplineApprox(self): self.assertTrue(f1.isValid()) self.assertTrue(f2.isValid()) - with raises(ValueError): + with raises(OCP.Standard.Standard_ConstructionError): f3 = Face.makeSplineApprox(pts, smoothing=(1, 1, 1), maxDeg=3) def testParametricSurface(self): diff --git a/tests/test_free_functions.py b/tests/test_free_functions.py index fdad7c811..6228b607c 100644 --- a/tests/test_free_functions.py +++ b/tests/test_free_functions.py @@ -671,7 +671,9 @@ def patch_find(monkeypatch): Fixture for throwing exception during imprinting. """ - from OCP.TopTools import TopTools_DataMapOfShapeListOfShape + from OCP.collections import ( + DataMap_TopoDS_Shape_List_TopoDS_Shape_TopTools_ShapeMapHasher as TopTools_DataMapOfShapeListOfShape, + ) from OCP.Standard import Standard_NoSuchObject from OCP.BOPAlgo import BOPAlgo_Builder