Skip to content

Commit 52b347d

Browse files
committed
moved print statements to the print_function; pep8; fixed miports
1 parent 29e9fa2 commit 52b347d

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

OCCUtils/Common.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def fix(li, _type):
170170
if interp.IsDone():
171171
return interp.Curve()
172172
except RuntimeError:
173-
print 'FAILED TO INTERPOLATE THE SHOWN POINTS'
173+
print("Failed to interpolate the shown points")
174174

175175

176176
def interpolate_points_vectors_to_spline(list_of_points, list_of_vectors, vector_mask=[], tolerance=TOLERANCE):
@@ -239,7 +239,6 @@ def fix(li, _type):
239239
# --- RANDOMNESS ---
240240
#===========================================================================
241241

242-
243242
def random_vec():
244243
import random
245244
x, y, z = [random.uniform(-1, 1) for i in range(3)]
@@ -250,7 +249,7 @@ def random_colored_material_aspect():
250249
import random
251250
clrs = [i for i in dir(Graphic3d) if i.startswith('Graphic3d_NOM_')]
252251
color = random.sample(clrs, 1)[0]
253-
print 'color', color
252+
print("color", color)
254253
return Graphic3d.Graphic3d_MaterialAspect(getattr(Graphic3d, color))
255254

256255

@@ -319,7 +318,7 @@ def point_in_solid(solid, pnt, tolerance=1e-5):
319318
from OCC.BRepClass3d import BRepClass3d_SolidClassifier
320319
from OCC.TopAbs import TopAbs_ON, TopAbs_OUT, TopAbs_IN
321320
_in_solid = BRepClass3d_SolidClassifier(solid, pnt, tolerance)
322-
print 'STATE', _in_solid.State()
321+
print("State", _in_solid.State())
323322
if _in_solid.State() == TopAbs_ON:
324323
return None, 'on'
325324
if _in_solid.State() == TopAbs_OUT:
@@ -433,7 +432,7 @@ def resample_curve_with_uniform_deflection(curve, deflection=0.5, degreeMin=3, d
433432
crv = to_adaptor_3d(curve)
434433
defl = GCPnts_UniformDeflection(crv, deflection)
435434
with assert_isdone(defl, 'failed to compute UniformDeflection'):
436-
print 'number of points:', defl.NbPoints()
435+
print("Number of points:", defl.NbPoints())
437436
sampled_pnts = [defl.Value(i) for i in xrange(1, defl.NbPoints())]
438437
resampled_curve = GeomAPI_PointsToBSpline(point_list_to_TColgp_Array1OfPnt(sampled_pnts), degreeMin, degreeMax, continuity, tolerance)
439438
return resampled_curve.Curve().GetObject()

OCCUtils/Construct.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,10 @@ def sew_shapes(shapes, tolerance=0.001):
629629
else:
630630
sew.Add(shp)
631631
sew.Perform()
632-
print 'n degenerated shapes', sew.NbDegeneratedShapes()
633-
print 'n deleted faces:', sew.NbDeletedFaces()
634-
print 'n free edges', sew.NbFreeEdges()
635-
print 'n multiple edges:', sew.NbMultipleEdges()
632+
print("n degenerated shapes", sew.NbDegeneratedShapes())
633+
print("n deleted faces:", sew.NbDeletedFaces())
634+
print("n free edges", sew.NbFreeEdges())
635+
print("n multiple edges:", sew.NbMultipleEdges())
636636
result = ShapeToTopology()(sew.SewedShape())
637637
return result
638638

@@ -644,7 +644,7 @@ def boolean_cut(shapeToCutFrom, cuttingShape):
644644
from OCC.BRepAlgoAPI import BRepAlgoAPI_Cut
645645
try:
646646
cut = BRepAlgoAPI_Cut(shapeToCutFrom, cuttingShape)
647-
print 'can work?', cut.BuilderCanWork()
647+
print("Can work?", cut.BuilderCanWork())
648648
_error = {0: '- Ok',
649649
1: '- The Object is created but Nothing is Done',
650650
2: '- Null source shapes is not allowed',
@@ -654,14 +654,14 @@ def boolean_cut(shapeToCutFrom, cuttingShape):
654654
6: '- Unknown operation is not allowed',
655655
7: '- Can not allocate memory for the Builder',
656656
}
657-
print 'error status:', _error[cut.ErrorStatus()]
657+
print("Error status:", _error[cut.ErrorStatus()])
658658
cut.RefineEdges()
659659
cut.FuseEdges()
660660
shp = cut.Shape()
661661
cut.Destroy()
662662
return shp
663663
except:
664-
print 'FAILED TO BOOLEAN CUT'
664+
print("Failed to boolean cut")
665665
return shapeToCutFrom
666666

667667

OCCUtils/edge.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,14 @@ def divide_by_number_of_points(self, n_pts, lbound=None, ubound=None):
375375
elif ubound:
376376
_ubound = ubound
377377

378-
379378
# minimally two points or a Standard_ConstructionError is raised
380379
if n_pts <= 1:
381380
n_pts = 2
382381

383382
try:
384383
npts = GCPnts_UniformAbscissa(self.adaptor, n_pts, _lbound, _ubound)
385384
except:
386-
print "Warning : GCPnts_UniformAbscissa failed"
385+
print("Warning : GCPnts_UniformAbscissa failed")
387386
if npts.IsDone():
388387
tmp = []
389388
for i in xrange(1, npts.NbPoints()+1):

OCCUtils/types_lut.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ class ShapeToTopology(object):
2828
looks up the topology type and returns the corresponding topological entity
2929
'''
3030
def __init__(self):
31-
self.tds = topods()
32-
self.topoTypes = {TopAbs_VERTEX: self.tds.Vertex,
33-
TopAbs_EDGE: self.tds.Edge,
34-
TopAbs_FACE: self.tds.Face,
35-
TopAbs_WIRE: self.tds.Wire,
36-
TopAbs_SHELL: self.tds.Shell,
37-
TopAbs_SOLID: self.tds.Solid,
38-
TopAbs_COMPOUND: self.tds.Compound,
39-
TopAbs_COMPSOLID: self.tds.CompSolid,
31+
self.topoTypes = {TopAbs_VERTEX: topods.Vertex,
32+
TopAbs_EDGE: topods.Edge,
33+
TopAbs_FACE: topods.Face,
34+
TopAbs_WIRE: topods.Wire,
35+
TopAbs_SHELL: topods.Shell,
36+
TopAbs_SOLID: topods.Solid,
37+
TopAbs_COMPOUND: topods.Compound,
38+
TopAbs_COMPSOLID: topods.CompSolid,
4039
}
4140

4241
def __call__(self, shape):
@@ -105,7 +104,7 @@ def __getitem__(self, item):
105104
# no need for 2 lists to define an EnumLookup
106105

107106
def fix_formatting(_str):
108-
return [i.strip() for i in _str.decode('string_escape').split(',')]
107+
return [i.strip() for i in _str.split(',')]
109108

110109
_brep_check_a = fix_formatting("NoError, InvalidPointOnCurve,\
111110
InvalidPointOnCurveOnSurface, InvalidPointOnSurface,\
@@ -167,8 +166,8 @@ def fix_formatting(_str):
167166
def what_is_face(face):
168167
''' Returns all class names for which this class can be downcasted
169168
'''
170-
if not face.ShapeType()==TopAbs_FACE:
171-
print '%s is not a TopAbs_FACE. Conversion impossible'
169+
if not face.ShapeType() == TopAbs_FACE:
170+
print('%s is not a TopAbs_FACE. Conversion impossible')
172171
return None
173172
hs = BRep_Tool_Surface(face)
174173
obj = hs.GetObject()

0 commit comments

Comments
 (0)