Skip to content

Commit 6be7918

Browse files
committed
pylint fixes over edge.py
1 parent fd0b930 commit 6be7918

File tree

1 file changed

+29
-128
lines changed

1 file changed

+29
-128
lines changed

OCCUtils/edge.py

Lines changed: 29 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,32 @@
2020
from OCC.Geom import Geom_OffsetCurve, Geom_TrimmedCurve
2121
from OCC.TopExp import topexp
2222
from OCC.TopoDS import TopoDS_Edge, TopoDS_Vertex, TopoDS_Face
23-
from OCC.gp import *
23+
from OCC.gp import gp_Vec, gp_Dir, gp_Pnt
2424
from OCC.GeomLProp import GeomLProp_CurveTool
2525
from OCC.BRepLProp import BRepLProp_CLProps
2626
from OCC.GeomLib import geomlib
2727
from OCC.GCPnts import GCPnts_AbscissaPoint
2828
from OCC.GeomAPI import GeomAPI_ProjectPointOnCurve
2929
from OCC.ShapeAnalysis import ShapeAnalysis_Edge
30-
from OCC.BRep import *
30+
from OCC.BRep import BRep_Tool, BRep_Tool_Continuity
31+
from OCC.BRepIntCurveSurface import BRepIntCurveSurface_Inter
3132

3233
# high-level
33-
from Common import vertex2pnt, minimum_distance
34-
from Construct import make_edge, fix_continuity
35-
from Context import assert_isdone
36-
from vertex import Vertex
37-
from types_lut import geom_lut
38-
from base import KbeObject
34+
from OCCUtils.Common import vertex2pnt, minimum_distance, assert_isdone, fix_continuity
35+
from OCCUtils.Construct import make_edge
36+
from OCCUtils.types_lut import geom_lut
37+
from OCCUtils.base import BaseObject
3938

4039

4140
class IntersectCurve(object):
4241
def __init__(self, instance):
4342
self.instance = instance
4443

45-
def intersect(self, other, disp, tolerance=1e-2):
44+
def intersect(self, other, tolerance=1e-2):
4645
'''Intersect self with a point, curve, edge, face, solid
4746
method wraps dealing with the various topologies
4847
'''
4948
if isinstance(other, TopoDS_Face):
50-
from OCC.BRepIntCurveSurface import BRepIntCurveSurface_Inter
5149
face_curve_intersect = BRepIntCurveSurface_Inter()
5250
face_curve_intersect.Init(other, self.instance.adaptor.Curve(), tolerance)
5351
pnts = []
@@ -61,7 +59,6 @@ class DiffGeomCurve(object):
6159
def __init__(self, instance):
6260
self.instance = instance
6361
self._local_props = BRepLProp_CLProps(self.instance.adaptor, 2, self.instance.tolerance)
64-
# initialize with random parameter: 0
6562

6663
@property
6764
def _curvature(self):
@@ -103,9 +100,9 @@ def normal(self, u):
103100
'''
104101
try:
105102
self._curvature.SetParameter(u)
106-
ddd = gp_Dir()
107-
self._curvature.Normal(ddd)
108-
return ddd
103+
a_dir = gp_Dir()
104+
self._curvature.Normal(a_dir)
105+
return a_dir
109106
except:
110107
raise ValueError('no normal was found')
111108

@@ -135,11 +132,6 @@ class ConstructFromCurve():
135132
def __init__(self, instance):
136133
self.instance = instance
137134

138-
def make_face(self):
139-
'''returns a brep face iff self.closed()
140-
'''
141-
raise NotImplementedError
142-
143135
def make_offset(self, offset, vec):
144136
'''
145137
returns an offsetted curve
@@ -148,19 +140,13 @@ def make_offset(self, offset, vec):
148140
'''
149141
return Geom_OffsetCurve(self.instance.h_crv, offset, vec)
150142

151-
def approximate_on_surface(self):
152-
'''
153-
approximation of a curve on surface
154-
'''
155-
raise NotImplementedError
156143

157-
158-
class Edge(TopoDS_Edge, KbeObject):
144+
class Edge(TopoDS_Edge, BaseObject):
159145
def __init__(self, edge):
160146
assert isinstance(edge, TopoDS_Edge), 'need a TopoDS_Edge, got a %s' % edge.__class__
161147
assert not edge.IsNull()
162148
super(Edge, self).__init__()
163-
KbeObject.__init__(self, 'edge')
149+
BaseObject.__init__(self, 'edge')
164150
# we need to copy the base shape using the following three
165151
# lines
166152
assert self.IsNull()
@@ -184,7 +170,6 @@ def __init__(self, edge):
184170
self.DiffGeom = DiffGeomCurve(self)
185171
self.Intersect = IntersectCurve(self)
186172
self.Construct = ConstructFromCurve(self)
187-
#self.graphic = GraphicCurve(self)
188173

189174
# GeomLProp object
190175
self._curvature = None
@@ -228,10 +213,9 @@ def curve(self):
228213
@property
229214
def curve_handle(self):
230215
if self._curve_handle is not None and not self.is_dirty:
231-
pass
216+
return self._curve_handle
232217
else:
233-
self.curve
234-
return self._curve_handle
218+
return None
235219

236220
@property
237221
def adaptor(self):
@@ -256,10 +240,9 @@ def geom_curve_handle(self):
256240
:return: Handle_Geom_Curve adapted from `self`
257241
"""
258242
if self._adaptor_handle is not None and not self.is_dirty:
259-
pass
243+
return self._adaptor.Curve().Curve()
260244
else:
261-
self.adaptor
262-
return self._adaptor.Curve().Curve()
245+
return None
263246

264247
@property
265248
def type(self):
@@ -281,12 +264,6 @@ def domain(self):
281264
'''returns the u,v domain of the curve'''
282265
return self.adaptor.FirstParameter(), self.adaptor.LastParameter()
283266

284-
def project(self, other):
285-
'''projects self with a point, curve, edge, face, solid
286-
method wraps dealing with the various topologies
287-
'''
288-
raise NotImplementedError
289-
290267
#===========================================================================
291268
# Curve.GlobalProperties
292269
#===========================================================================
@@ -310,7 +287,7 @@ def length(self, lbound=None, ubound=None, tolerance=1e-5):
310287
# Curve.modify
311288
#===========================================================================
312289

313-
def trim(self, lbound, ubound, periodic=False):
290+
def trim(self, lbound, ubound):
314291
'''
315292
trim the curve
316293
@param lbound:
@@ -347,14 +324,14 @@ def project_vertex(self, pnt_or_vertex):
347324
poc = GeomAPI_ProjectPointOnCurve(pnt_or_vertex, self.curve_handle)
348325
return poc.LowerDistanceParameter(), poc.NearestPoint()
349326

350-
def distance_on_curve(self, distance, close_parameter, estimate_parameter, check_seam=True):
327+
def distance_on_curve(self, distance, close_parameter, estimate_parameter):
351328
'''returns the parameter if there is a parameter
352329
on the curve with a distance length from u
353330
raises OutOfBoundary if no such parameter exists
354331
'''
355-
ccc = GCPnts_AbscissaPoint(self.adaptor, distance, close_parameter, estimate_parameter, 1e-5)
356-
with assert_isdone(ccc, 'couldnt compute distance on curve'):
357-
return ccc.Parameter()
332+
gcpa = GCPnts_AbscissaPoint(self.adaptor, distance, close_parameter, estimate_parameter, 1e-5)
333+
with assert_isdone(gcpa, 'couldnt compute distance on curve'):
334+
return gcpa.Parameter()
358335

359336
def mid_point(self):
360337
"""
@@ -393,41 +370,16 @@ def divide_by_number_of_points(self, n_pts, lbound=None, ubound=None):
393370
else:
394371
return None
395372

396-
@property
397-
def weight(self, indx):
398-
'''descriptor sets or gets the weight of a control point at the index
399-
'''
400-
#TODO self.curve has to be generalized to a bspline for this...
401-
raise NotImplementedError
402-
403-
def control_pt_coord(self, indx):
404-
#TODO confused; vertices != control points
405-
'''descriptor setting or getting the coordinate of a
406-
control point at indx'''
407-
raise NotImplementedError
408-
409-
def greville_points(self):
410-
#TODO confused; vertices != greville points
411-
'''descriptor setting or getting the coordinate
412-
of a control point at indx'''
413-
raise NotImplementedError
414-
415-
def control_point(self, indx, pt=None):
416-
'''gets or sets the coordinate of the control point
417-
'''
418-
raise NotImplementedError
419-
420373
def __eq__(self, other):
421374
if hasattr(other, 'topo'):
422375
return self.IsEqual(other)
423376
else:
424377
return self.IsEqual(other)
425378

426379
def __ne__(self, other):
427-
return not(self.__eq__(other))
380+
return not self.__eq__(other)
428381

429382
def first_vertex(self):
430-
# TODO: should return Vertex, not TopoDS_Vertex
431383
return topexp.FirstVertex(self)
432384

433385
def last_vertex(self):
@@ -456,58 +408,22 @@ def parameter_to_point(self, u):
456408
'''
457409
return self.adaptor.Value(u)
458410

459-
def point_to_parameter(self, coord):
460-
'''returns the parameters / pnt on edge at world coordinate `coord`
461-
'''
462-
raise NotImplementedError
463-
464-
def transform(self, transform):
465-
'''affine transform
466-
'''
467-
raise NotImplementedError
468-
469411
def fix_continuity(self, continuity):
470412
"""
471413
splits an edge to achieve a level of continuity
472414
:param continuity: GeomAbs_C*
473415
"""
474416
return fix_continuity(self, continuity)
475417

476-
def continuity_to_another_curve(self, other):
477-
'''returns continuity between self and another curve
478-
'''
479-
raise NotImplementedError
480-
481418
def continuity_from_faces(self, f1, f2):
482419
return BRep_Tool_Continuity(self, f1, f2)
483420

484-
#===========================================================================
485-
# Curve.loop
486-
#===========================================================================
487-
488-
def iter_control_points(self):
489-
'''iterator over the control points
490-
'''
491-
raise NotImplementedError
492-
493-
def iter_weights(self):
494-
'''iterator over the weights
495-
'''
496-
raise NotImplementedError
497-
498421
#===========================================================================
499422
# Curve.
500423
#===========================================================================
501-
def is_trimmed(self):
502-
'''checks if curve is trimmed
503-
504-
check if the underlying geom type is trimmed
505424

506-
'''
507-
raise NotImplementedError
508-
509-
def is_line(self, tolerance=None):
510-
'''checks if the curve is planar within a tolerance
425+
def is_line(self):
426+
'''checks if the curve is planar
511427
'''
512428
if self.nb_knots() == 2 and self.nb_poles() == 2:
513429
return True
@@ -527,37 +443,22 @@ def is_edge_on_face(self, face):
527443
'''
528444
return ShapeAnalysis_Edge().HasPCurve(self, face)
529445

530-
def on_edge(self, edge):
531-
'''checks if the curve lies on an edge or a border
532-
'''
533-
raise NotImplementedError
534-
535446
#===========================================================================
536447
# Curve.graphic
537448
#===========================================================================
538-
def show(self, poles=False, vertices=False, knots=False):
449+
def show(self):
539450
'''
540451
poles, knots, should render all slightly different.
541452
here's how...
542453
543454
http://www.opencascade.org/org/forum/thread_1125/
544455
'''
545-
show = super(Edge, self).show()
546-
547-
def update(self, context):
548-
'''updates the graphic presentation when called
549-
'''
550-
raise NotImplementedError
456+
super(Edge, self).show()
551457

552-
@property
553-
def color(self, *rgb):
554-
'''color descriptor for the curve
555-
'''
556-
raise NotImplementedError
557458

558459
if __name__ == '__main__':
559-
from OCC.BRepPrimAPI import *
560-
from Topology import Topo
460+
from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
461+
from OCCUtils.Topology import Topo
561462
b = BRepPrimAPI_MakeBox(10, 20, 30).Shape()
562463
t = Topo(b)
563464
ed = next(t.edges())

0 commit comments

Comments
 (0)