Skip to content

Commit fd0b930

Browse files
committed
Ran pylint over face module
1 parent 73e5f2d commit fd0b930

File tree

1 file changed

+16
-97
lines changed

1 file changed

+16
-97
lines changed

OCCUtils/face.py

Lines changed: 16 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,25 @@
1616
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>
1717

1818
from OCC.BRep import BRep_Tool_Surface, BRep_Tool
19-
from OCC.BRepIntCurveSurface import BRepIntCurveSurface_Inter
2019
from OCC.BRepTopAdaptor import BRepTopAdaptor_FClass2d
2120
from OCC.Geom import Geom_Curve
2221
from OCC.GeomAPI import GeomAPI_ProjectPointOnSurf
2322
from OCC.GeomLib import GeomLib_IsPlanarSurface
2423
from OCC.TopAbs import TopAbs_IN
2524
from OCC.TopExp import topexp
26-
from OCC.TopoDS import *
25+
from OCC.TopoDS import TopoDS_Vertex, TopoDS_Face, TopoDS_Edge
2726
from OCC.GeomLProp import GeomLProp_SLProps
28-
from OCC.BRepCheck import BRepCheck_Face
2927
from OCC.BRepTools import breptools_UVBounds
3028
from OCC.BRepAdaptor import BRepAdaptor_Surface, BRepAdaptor_HSurface
3129
from OCC.ShapeAnalysis import ShapeAnalysis_Surface
32-
from OCC.IntTools import IntTools_FaceFace
33-
from OCC.ShapeAnalysis import ShapeAnalysis_Surface
3430
from OCC.GeomProjLib import geomprojlib
3531
from OCC.Adaptor3d import Adaptor3d_IsoCurve
32+
from OCC.gp import gp_Pnt2d, gp_Dir
3633

37-
from base import Display, KbeObject, GlobalProperties
38-
from edge import Edge
39-
from Construct import *
40-
from Topology import Topo, WireExplorer
41-
42-
'''
43-
44-
TODO:
45-
46-
use IntTools_FaceFace to compute intersection between 2 faces
47-
also useful to test if 2 faces are tangent
48-
49-
inflection point -> scipy.fsolve
50-
radius / centre of circle
51-
divide curve by circles
52-
frenet frame
53-
54-
55-
'''
34+
from OCCUtils.base import BaseObject
35+
from OCCUtils.edge import Edge
36+
from OCCUtils.Construct import TOLERANCE, to_adaptor_3d
37+
from OCCUtils.Topology import Topo, WireExplorer
5638

5739

5840
class DiffGeomSurface(object):
@@ -144,45 +126,8 @@ def radius(self, u, v):
144126
_crv_max = 0.
145127
return abs((_crv_min+_crv_max)/2.)
146128

147-
def frenet_frame(self, u, v):
148-
'''returns the frenet frame ( the 2 tangency directions + normal )
149-
syntax sugar
150-
'''
151-
raise NotImplementedError
152129

153-
def derivative_u(self, u, n):
154-
'''return n derivatives of u
155-
'''
156-
raise NotImplementedError
157-
158-
def derivative_v(self, v, n):
159-
'''return n derivatives of v
160-
'''
161-
raise NotImplementedError
162-
163-
def torsion(self, u, v):
164-
'''returns the torsion at the parameter
165-
http://en.wikipedia.org/wiki/Frenet-Serret_formulas
166-
'''
167-
raise NotImplementedError
168-
169-
def continuity(self, face):
170-
'''returns continuity between self and another surface
171-
'''
172-
# add dictionary mapping which G / C continuity it is...
173-
raise NotImplementedError
174-
175-
def inflection_parameters(self):
176-
"""
177-
:return: a list of tuples (u,v) of parameters
178-
where there are inflection points on the edge
179-
180-
returns None if no inflection parameters are found
181-
"""
182-
raise NotImplementedError
183-
184-
185-
class Face(TopoDS_Face, KbeObject):
130+
class Face(TopoDS_Face, BaseObject):
186131
"""high level surface API
187132
object is a Face if part of a Solid
188133
otherwise the same methods do apply, apart from the topology obviously
@@ -193,7 +138,7 @@ def __init__(self, face):
193138
assert isinstance(face, TopoDS_Face), 'need a TopoDS_Face, got a %s' % face.__class__
194139
assert not face.IsNull()
195140
super(Face, self).__init__()
196-
KbeObject.__init__(self, 'face')
141+
BaseObject.__init__(self, 'face')
197142
# we need to copy the base shape using the following three
198143
# lines
199144
assert self.IsNull()
@@ -264,8 +209,7 @@ def mid_point(self):
264209
u_min, u_max, v_min, v_max = self.domain()
265210
u_mid = (u_min + u_max) / 2.
266211
v_mid = (v_min + v_max) / 2.
267-
pnt = self.parameter_to_point(u_mid, v_mid)
268-
return ((u_mid, v_mid), self.adaptor.Value(u_mid, v_mid))
212+
return ((u_mid, v_mid), self.adaptor.Value(u_mid, v_mid))
269213

270214
@property
271215
def topo(self):
@@ -277,19 +221,15 @@ def topo(self):
277221

278222
@property
279223
def surface(self):
280-
if self._srf is not None and not self.is_dirty:
281-
pass
282-
else:
224+
if self._srf is None or self.is_dirty:
283225
self._h_srf = BRep_Tool_Surface(self)
284226
self._srf = self._h_srf.GetObject()
285227
return self._srf
286228

287229
@property
288230
def surface_handle(self):
289-
if self._h_srf is not None and not self.is_dirty:
290-
pass
291-
else:
292-
self.surface
231+
if self._h_srf is None or self.is_dirty:
232+
self.surface # force building handle
293233
return self._h_srf
294234

295235
@property
@@ -310,19 +250,6 @@ def adaptor_handle(self):
310250
self.adaptor
311251
return self._adaptor_handle
312252

313-
def weight(self, indx):
314-
'''sets or gets the weight of a control point at the index
315-
316-
'''
317-
# TODO: somehow its hard to get a Geom_SplineSurface object from a face
318-
# nessecary to get control points and weights
319-
320-
raise NotImplementedError
321-
322-
def close(self):
323-
'''if possible, close self'''
324-
raise NotImplementedError
325-
326253
def is_closed(self):
327254
sa = ShapeAnalysis_Surface(self.surface_handle)
328255
# sa.GetBoxUF()
@@ -332,8 +259,9 @@ def is_planar(self, tol=TOLERANCE):
332259
'''checks if the surface is planar within a tolerance
333260
:return: bool, gp_Pln
334261
'''
335-
aaa = GeomLib_IsPlanarSurface(self.surface_handle, tol)
336-
return aaa.IsPlanar()
262+
print(self.surface_handle)
263+
is_planar_surface = GeomLib_IsPlanarSurface(self.surface_handle, tol)
264+
return is_planar_surface.IsPlanar()
337265

338266
def is_trimmed(self):
339267
"""
@@ -351,9 +279,6 @@ def is_trimmed(self):
351279
return True
352280
return False
353281

354-
def is_overlapping(self, other):
355-
overlap = IntTools_FaceFace()
356-
357282
def on_trimmed(self, u, v):
358283
'''tests whether the surface at the u,v parameter has been trimmed
359284
'''
@@ -379,11 +304,6 @@ def point_to_parameter(self, pt):
379304
uv = sas.ValueOfUV(pt, self.tolerance)
380305
return uv.Coord()
381306

382-
def transform(self, transform):
383-
'''affine transform
384-
'''
385-
raise NotImplementedError
386-
387307
def continuity_edge_face(self, edge, face):
388308
"""
389309
compute the continuity between two faces at :edge:
@@ -446,11 +366,10 @@ def iso_curve(self, u_or_v, param):
446366
:return:
447367
"""
448368
uv = 0 if u_or_v == 'u' else 1
449-
# TODO: REFACTOR, part of the Face class now...
450369
iso = Adaptor3d_IsoCurve(self.adaptor_handle.GetHandle(), uv, param)
451370
return iso
452371

453-
def Edges(self):
372+
def edges(self):
454373
return [Edge(i) for i in WireExplorer(next(self.topo.wires())).ordered_edges()]
455374

456375
def __repr__(self):

0 commit comments

Comments
 (0)