Skip to content

Commit c5b45d4

Browse files
committed
2 parents a97956d + 030895e commit c5b45d4

File tree

10 files changed

+64
-126
lines changed

10 files changed

+64
-126
lines changed

.travis.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,19 @@ language: cpp
44

55
matrix:
66
include:
7-
- env: PYTHON="2.7" CONDA_PY=27
8-
os: linux
9-
dist: trusty
10-
- env: PYTHON="2.7" CONDA_PY=27
11-
os: osx
12-
osx_image: xcode8.3
13-
- env: PYTHON="3.5" CONDA_PY=35
14-
os: linux
15-
dist: trusty
16-
- env: PYTHON="3.5" CONDA_PY=35
17-
os: osx
18-
osx_image: xcode8.3
197
- env: PYTHON="3.6" CONDA_PY=36
208
os: linux
21-
dist: trusty
9+
dist: bionic
2210
- env: PYTHON="3.6" CONDA_PY=36
2311
os: osx
24-
osx_image: xcode8.3
12+
osx_image: xcode9.4
13+
- env: PYTHON="3.7" CONDA_PY=37
14+
os: linux
15+
dist: bionic
16+
- env: PYTHON="3.7" CONDA_PY=37
17+
os: osx
18+
osx_image: xcode9.4
19+
2520

2621
install:
2722
- if [ ${PYTHON:0:1} == "2" ]; then
@@ -52,7 +47,7 @@ install:
5247
conda create -n pythonocc-utils-test;
5348
source activate pythonocc-utils-test;
5449
fi;
55-
- conda install -c dlr-sc -c conda-forge -c oce -c pythonocc pythonocc-core=0.18.1
50+
- conda install -c dlr-sc -c pythonocc pythonocc-core=7.4.0rc1
5651

5752
script:
5853
# osx needs a dedicate environment

OCCUtils/Common.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def to_tcol_(_list, collection_type):
120120
array = collection_type(1, len(_list)+1)
121121
for n, i in enumerate(_list):
122122
array.SetValue(n+1, i)
123-
return array.GetHandle()
123+
return array
124124

125125

126126
def _Tcol_dim_1(li, _type):
@@ -188,7 +188,7 @@ def fix(li, _type):
188188

189189
fixed_points = fix(list_of_points, TColgp_HArray1OfPnt)
190190
try:
191-
interp = GeomAPI_Interpolate(fixed_points.GetHandle(), False, tolerance)
191+
interp = GeomAPI_Interpolate(fixed_points, False, tolerance)
192192
interp.Load(start_tangent, end_tangent, False)
193193
interp.Perform()
194194
if interp.IsDone():
@@ -224,8 +224,8 @@ def fix(li, _type):
224224
fixed_vectors = fix(list_of_vectors, TColgp_Array1OfVec)
225225

226226
try:
227-
interp = GeomAPI_Interpolate(fixed_points.GetHandle(), False, tolerance)
228-
interp.Load(fixed_vectors, fixed_mask.GetHandle(), False)
227+
interp = GeomAPI_Interpolate(fixed_points, False, tolerance)
228+
interp.Load(fixed_vectors, fixed_mask, False)
229229
interp.Perform()
230230
if interp.IsDone():
231231
return interp.Curve()
@@ -252,7 +252,7 @@ def fix(li, _type):
252252

253253
fixed_points = fix(list_of_points, TColgp_HArray1OfPnt)
254254
try:
255-
interp = GeomAPI_Interpolate(fixed_points.GetHandle(), closed, tolerance)
255+
interp = GeomAPI_Interpolate(fixed_points, closed, tolerance)
256256
interp.Perform()
257257
if interp.IsDone():
258258
return interp.Curve()
@@ -414,12 +414,12 @@ def normal_vector_from_plane(plane, vec_length=1.):
414414

415415

416416
def fix_tolerance(shape, tolerance=TOLERANCE):
417-
from OCC.ShapeFix import ShapeFix_ShapeTolerance
417+
from OCC.Core.ShapeFix import ShapeFix_ShapeTolerance
418418
ShapeFix_ShapeTolerance().SetTolerance(shape, tolerance)
419419

420420

421421
def fix_continuity(edge, continuity=1):
422-
from OCC.ShapeUpgrade import ShapeUpgrade_ShapeDivideContinuity
422+
from OCC.Core.ShapeUpgrade import ShapeUpgrade_ShapeDivideContinuity
423423
su = ShapeUpgrade_ShapeDivideContinuity(edge)
424424
su.SetBoundaryCriterion(eval('GeomAbs_C'+str(continuity)))
425425
su.Perform()
@@ -433,7 +433,7 @@ def resample_curve_with_uniform_deflection(curve, deflection=0.5, degreeMin=3, d
433433
@param curve: TopoDS_Wire, TopoDS_Edge, curve
434434
@param n_samples:
435435
'''
436-
from OCC.GCPnts import GCPnts_UniformDeflection
436+
from OCC.Core.GCPnts import GCPnts_UniformDeflection
437437
crv = to_adaptor_3d(curve)
438438
defl = GCPnts_UniformDeflection(crv, deflection)
439439
with assert_isdone(defl, 'failed to compute UniformDeflection'):
@@ -497,7 +497,7 @@ def minimum_distance(shp1, shp2):
497497
minimum distance points on shp1
498498
minimum distance points on shp2
499499
'''
500-
from OCC.BRepExtrema import BRepExtrema_DistShapeShape
500+
from OCC.Core.BRepExtrema import BRepExtrema_DistShapeShape
501501
bdss = BRepExtrema_DistShapeShape(shp1, shp2)
502502
bdss.Perform()
503503
with assert_isdone(bdss, 'failed computing minimum distances'):
@@ -512,7 +512,7 @@ def minimum_distance(shp1, shp2):
512512
def vertex2pnt(vertex):
513513
'''returns a gp_Pnt from a TopoDS_Vertex
514514
'''
515-
from OCC.Core.BRep import BRep_Tool
515+
from OCC.Core.Core.BRep import BRep_Tool
516516
return BRep_Tool.Pnt(vertex)
517517

518518

@@ -543,7 +543,7 @@ def to_adaptor_3d(curveType):
543543
elif isinstance(curveType, TopoDS_Edge):
544544
return BRepAdaptor_Curve(curveType)
545545
elif issubclass(curveType.__class__, Geom_Curve):
546-
return GeomAdaptor_Curve(curveType.GetHandle())
546+
return GeomAdaptor_Curve(curveType)
547547
elif hasattr(curveType, 'GetObject'):
548548
_crv = curveType.GetObject()
549549
if issubclass(_crv.__class__, Geom_Curve):
@@ -554,7 +554,7 @@ def to_adaptor_3d(curveType):
554554

555555
def project_point_on_curve(crv, pnt):
556556
if isinstance(crv, TopoDS_Shape):
557-
# get the curve handle...
557+
# get the curve
558558
crv = adapt_edge_to_curve(crv).Curve().Curve()
559559
else:
560560
raise NotImplementedError('expected a TopoDS_Edge...')
@@ -568,7 +568,7 @@ def project_point_on_plane(plane, point):
568568
@param plane: Geom_Plane
569569
@param point: gp_Pnt
570570
'''
571-
from OCC.ProjLib import projlib_Project
571+
from OCC.Core.ProjLib import projlib_Project
572572
pl = plane.Pln()
573573
aa, bb = projlib_Project(pl, point).Coord()
574574
point = plane.Value(aa, bb)
@@ -583,8 +583,8 @@ def wire_to_curve(wire, tolerance=TOLERANCE, order=GeomAbs_C2, max_segment=200,
583583
'''
584584
adap = BRepAdaptor_CompCurve(wire)
585585
hadap = BRepAdaptor_HCompCurve(adap)
586-
from OCC.Approx import Approx_Curve3d
587-
approx = Approx_Curve3d(hadap.GetHandle(), tolerance, order, max_segment, max_order)
586+
from OCC.Core.Approx import Approx_Curve3d
587+
approx = Approx_Curve3d(hadap, tolerance, order, max_segment, max_order)
588588
with assert_isdone(approx, 'not able to compute approximation from wire'):
589589
return approx.Curve().GetObject()
590590

OCCUtils/Construct.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def make_solid(*args):
214214
sld = BRepBuilderAPI_MakeSolid(*args)
215215
with assert_isdone(sld, 'failed to produce solid'):
216216
result = sld.Solid()
217-
sld.Delete()
218217
return result
219218

220219

@@ -224,7 +223,6 @@ def make_shell(*args):
224223
st = ShapeToTopology()
225224
with assert_isdone(shell, 'failed to produce shell'):
226225
result = shell.Shell()
227-
shell.Delete()
228226
return st(result)
229227

230228

@@ -233,7 +231,6 @@ def make_face(*args):
233231
face = BRepBuilderAPI_MakeFace(*args)
234232
with assert_isdone(face, 'failed to produce face'):
235233
result = face.Face()
236-
face.Delete()
237234
return result
238235

239236

@@ -242,7 +239,6 @@ def make_edge2d(*args):
242239
edge = BRepBuilderAPI_MakeEdge2d(*args)
243240
with assert_isdone(edge, 'failed to produce edge'):
244241
result = edge.Edge()
245-
edge.Delete()
246242
return result
247243

248244

@@ -251,7 +247,6 @@ def make_edge(*args):
251247
edge = BRepBuilderAPI_MakeEdge(*args)
252248
with assert_isdone(edge, 'failed to produce edge'):
253249
result = edge.Edge()
254-
edge.Delete()
255250
return result
256251

257252

@@ -260,10 +255,8 @@ def make_vertex(*args):
260255
vert = BRepBuilderAPI_MakeVertex(*args)
261256
with assert_isdone(vert, 'failed to produce vertex'):
262257
result = vert.Vertex()
263-
vert.Delete()
264258
return result
265259

266-
267260
@wraps(BRepBuilderAPI_MakeWire)
268261
def make_wire(*args):
269262
# if we get an iterable, than add all edges to wire builder
@@ -580,14 +573,14 @@ def make_constrained_surface_from_edges(edges): #, w
580573
for edg in edges:
581574
c = BRepAdaptor_HCurve()
582575
c.ChangeCurve().Initialize(edg)
583-
constraint = BRepFill_CurveConstraint(c.GetHandle(), 0)
576+
constraint = BRepFill_CurveConstraint(c, 0)
584577
bpSrf.Add(constraint)
585578
bpSrf.Perform()
586579
maxSeg, maxDeg, critOrder = 9, 8, 0
587580
tol = 1e-4
588581
srf = bpSrf.Surface()
589582
plate = GeomPlate_MakeApprox(srf, tol, maxSeg, maxDeg, tol, critOrder)
590-
uMin, uMax, vMin, vMax = srf.Bounds() #srf.GetObject().Bounds()
583+
uMin, uMax, vMin, vMax = srf.Bounds()
591584
face = make_face(plate.Surface(), uMin, uMax, vMin, vMax)
592585
#face = make_face(srf, w, False) #plate.Surface(), uMin, uMax, vMin, vMax)
593586
return face
@@ -606,7 +599,6 @@ def add_wire_to_face(face, wire, reverse=False):
606599
wire.Reverse()
607600
face.Add(wire)
608601
result = face.Face()
609-
face.Delete()
610602
return result
611603

612604

@@ -676,15 +668,14 @@ def trim_wire(wire, shapeLimit1, shapeLimit2, periodic=False):
676668
adap = to_adaptor_3d(wire)
677669
bspl = adap.BSpline()
678670
if periodic:
679-
spl = bspl # .GetObject()
680-
if spl.IsClosed():
681-
spl.SetPeriodic()
671+
if bspl.IsClosed():
672+
bspl.SetPeriodic()
682673
else:
683674
warnings.warn('the wire to be trimmed is not closed, hence cannot be made periodic')
684675
p1 = project_point_on_curve(bspl, shapeLimit1)[0]
685676
p2 = project_point_on_curve(bspl, shapeLimit2)[0]
686677
a, b = sorted([p1, p2])
687-
tr = Geom_TrimmedCurve(bspl, a, b).GetHandle()
678+
tr = Geom_TrimmedCurve(bspl, a, b)
688679
return make_edge(tr)
689680

690681
#===========================================================================
@@ -696,7 +687,7 @@ def fix_shape(shp, tolerance=1e-3):
696687
from OCC.Core.ShapeFix import ShapeFix_Shape
697688
fix = ShapeFix_Shape(shp)
698689
fix.SetFixFreeShellMode(True)
699-
sf = fix.FixShellTool() #.GetObject()
690+
sf = fix.FixShellTool()
700691
sf.SetFixOrientationMode(True)
701692
fix.LimitTolerance(tolerance)
702693
fix.Perform()
@@ -823,16 +814,16 @@ def face_normal(face):
823814

824815

825816
def face_from_plane(_geom_plane, lowerLimit=-1000, upperLimit=1000):
826-
from OCC.Core.Geom import Geom_RectangularTrimmedSurface
827-
_trim_plane = make_face(Geom_RectangularTrimmedSurface(_geom_plane.GetHandle(), lowerLimit, upperLimit, lowerLimit, upperLimit).GetHandle())
817+
from OCC.Geom import Geom_RectangularTrimmedSurface
818+
_trim_plane = make_face(Geom_RectangularTrimmedSurface(_geom_plane, lowerLimit, upperLimit, lowerLimit, upperLimit))
828819
return _trim_plane
829820

830821

831822
def find_plane_from_shape(shape, tolerance=-1):
832823
try:
833824
fpl = BRepBuilderAPI_FindPlane(shape, tolerance)
834825
if fpl.Found():
835-
return fpl.Plane() #.GetObject()
826+
return fpl.Plane()
836827
else:
837828
return None
838829
except:
@@ -854,7 +845,7 @@ def fit_plane_through_face_vertices(_face):
854845
[NORMALS.Append(i) for i in normals]
855846
POINTS = to_tcol_(points, TColgp_HArray1OfPnt)
856847

857-
pl = GeomPlate_BuildAveragePlane(NORMALS, POINTS).Plane() #.GetObject()
848+
pl = GeomPlate_BuildAveragePlane(NORMALS, POINTS).Plane()
858849
vec = gp_Vec(pl.Location(), _face.GlobalProperties.centre())
859850
pt = (pl.Location().as_vec() + vec).as_pnt()
860851
pl.SetLocation(pt)
@@ -867,13 +858,13 @@ def project_edge_onto_plane(edg, plane):
867858
:param plane: Geom_Plane
868859
:return: TopoDS_Edge projected on the plane
869860
"""
870-
from OCC.Core.GeomProjLib import geomprojlib_ProjectOnPlane
871-
proj = geomprojlib_ProjectOnPlane(edg.adaptor.Curve().Curve(), plane.GetHandle(), plane.Axis().Direction(), 1)
861+
from OCC.GeomProjLib import geomprojlib_ProjectOnPlane
862+
proj = geomprojlib_ProjectOnPlane(edg.adaptor.Curve().Curve(), plane, plane.Axis().Direction(), 1)
872863
return make_edge(proj)
873864

874865

875-
def curve_to_bspline(crv_handle, tolerance=TOLERANCE, continuity=GeomAbs_C1, sections=300, degree=12):
876-
approx_curve = GeomConvert_ApproxCurve(crv_handle, tolerance, continuity, sections, degree)
866+
def curve_to_bspline(crv, tolerance=TOLERANCE, continuity=GeomAbs_C1, sections=300, degree=12):
867+
approx_curve = GeomConvert_ApproxCurve(crv, tolerance, continuity, sections, degree)
877868
with assert_isdone(approx_curve, 'could not compute bspline from curve'):
878869
return approx_curve.Curve()
879870

OCCUtils/Iteration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'''
1919
This module helps looping through topology
2020
'''
21-
from OCC.BRep import BRep_Tool
21+
from OCC.Core.BRep import BRep_Tool
2222

2323
from OCCUtils.Topology import WireExplorer, Topo
2424
from OCCUtils.edge import Edge

OCCUtils/Topology.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def _map_shapes_and_ancestors(self, topoTypeA, topoTypeB, topologicalEntity):
310310
_map = TopTools_IndexedDataMapOfShapeListOfShape()
311311
topexp_MapShapesAndAncestors(self.myShape, topoTypeA, topoTypeB, _map)
312312
results = _map.FindFromKey(topologicalEntity)
313-
if results.IsEmpty():
313+
if results.Size() == 0:
314314
yield None
315315

316316
topology_iterator = TopTools_ListIteratorOfListOfShape(results)
@@ -348,7 +348,7 @@ def _number_shapes_ancestors(self, topoTypeA, topoTypeB, topologicalEntity):
348348
_map = TopTools_IndexedDataMapOfShapeListOfShape()
349349
topexp_MapShapesAndAncestors(self.myShape, topoTypeA, topoTypeB, _map)
350350
results = _map.FindFromKey(topologicalEntity)
351-
if results.IsEmpty():
351+
if results.Size() == 0:
352352
return None
353353
topology_iterator = TopTools_ListIteratorOfListOfShape(results)
354354
while topology_iterator.More():

0 commit comments

Comments
 (0)