Skip to content

Commit

Permalink
Addressed pylint warnings for PathGeom
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jul 1, 2019
1 parent ed8911c commit c5c976f
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/Mod/Path/PathScripts/PathGeom.py
Expand Up @@ -59,7 +59,7 @@ class Side:

@classmethod
def toString(cls, side):
"""(side)
"""toString(side)
Returns a string representation of the enum value."""
if side == cls.Left:
return 'Left'
Expand All @@ -69,7 +69,7 @@ def toString(cls, side):

@classmethod
def of(cls, ptRef, pt):
"""(ptRef, pt)
"""of(ptRef, pt)
Determine the side of pt in relation to ptRef.
If both Points are viewed as vectors with their origin in (0,0,0)
then the two vectors either form a straight line (On) or pt
Expand All @@ -89,29 +89,29 @@ def of(cls, ptRef, pt):
CmdMove = CmdMoveStraight + CmdMoveArc

def isRoughly(float1, float2, error=Tolerance):
"""(float1, float2, [error=%s])
Returns true if the two values are the same within a given error.""" % Tolerance
"""isRoughly(float1, float2, [error=Tolerance])
Returns true if the two values are the same within a given error."""
return math.fabs(float1 - float2) <= error

def pointsCoincide(p1, p2, error=Tolerance):
"""(p1, p2, [error=%s])
Return True if two points are roughly identical (see also isRoughly).""" % Tolerance
"""pointsCoincide(p1, p2, [error=Tolerance])
Return True if two points are roughly identical (see also isRoughly)."""
return isRoughly(p1.x, p2.x, error) and isRoughly(p1.y, p2.y, error) and isRoughly(p1.z, p2.z, error)

def edgesMatch(e0, e1, error=Tolerance):
"""(e0, e1, [error=%s]
Return true if the edges start and end at the same point and have the same type of curve.""" % Tolerance
"""edgesMatch(e0, e1, [error=Tolerance]
Return true if the edges start and end at the same point and have the same type of curve."""
if type(e0.Curve) != type(e1.Curve) or len(e0.Vertexes) != len(e1.Vertexes):
return False
return all(pointsCoincide(e0.Vertexes[i].Point, e1.Vertexes[i].Point) for i in range(len(e0.Vertexes)))
return all(pointsCoincide(e0.Vertexes[i].Point, e1.Vertexes[i].Point, error) for i in range(len(e0.Vertexes)))

def edgeConnectsTo(edge, vector, error=Tolerance):
"""(edge, vector, error=%f)
Returns True if edge connects to given vector.""" % Tolerance
return pointsCoincide(edge.valueAt(edge.FirstParameter), vector) or pointsCoincide(edge.valueAt(edge.LastParameter), vector)
"""edgeConnectsTop(edge, vector, error=Tolerance)
Returns True if edge connects to given vector."""
return pointsCoincide(edge.valueAt(edge.FirstParameter), vector, error) or pointsCoincide(edge.valueAt(edge.LastParameter), vector, error)

def getAngle(vector):
"""(vector)
"""getAngle(vector)
Returns the angle [-pi,pi] of a vector using the X-axis as the reference.
Positive angles for vertexes in the upper hemisphere (positive y values)
and negative angles for the lower hemisphere."""
Expand All @@ -121,7 +121,7 @@ def getAngle(vector):
return a

def diffAngle(a1, a2, direction = 'CW'):
"""(a1, a2, [direction='CW'])
"""diffAngle(a1, a2, [direction='CW'])
Returns the difference between two angles (a1 -> a2) into a given direction."""
if direction == 'CW':
while a1 < a2:
Expand Down Expand Up @@ -198,15 +198,15 @@ def isHorizontal(obj):


def commandEndPoint(cmd, defaultPoint = Vector(), X='X', Y='Y', Z='Z'):
"""(cmd, [defaultPoint=Vector()], [X='X'], [Y='Y'], [Z='Z'])
"""commandEndPoint(cmd, [defaultPoint=Vector()], [X='X'], [Y='Y'], [Z='Z'])
Extracts the end point from a Path Command."""
x = cmd.Parameters.get(X, defaultPoint.x)
y = cmd.Parameters.get(Y, defaultPoint.y)
z = cmd.Parameters.get(Z, defaultPoint.z)
return Vector(x, y, z)

def xy(point):
"""(point)
"""xy(point)
Convenience function to return the projection of the Vector in the XY-plane."""
return Vector(point.x, point.y, 0)

Expand Down Expand Up @@ -234,7 +234,7 @@ def speedBetweenPoints(p0, p1, hSpeed, vSpeed):
return speed

def cmdsForEdge(edge, flip = False, useHelixForBSpline = True, segm = 50, hSpeed = 0, vSpeed = 0):
"""(edge, flip=False, useHelixForBSpline=True, segm=50) -> List(Path.Command)
"""cmdsForEdge(edge, flip=False, useHelixForBSpline=True, segm=50) -> List(Path.Command)
Returns a list of Path.Command representing the given edge.
If flip is True the edge is considered to be backwards.
If useHelixForBSpline is True an Edge based on a BSplineCurve is considered
Expand Down Expand Up @@ -314,7 +314,7 @@ def cmdsForEdge(edge, flip = False, useHelixForBSpline = True, segm = 50, hSpeed
return commands

def edgeForCmd(cmd, startPoint):
"""(cmd, startPoint).
"""edgeForCmd(cmd, startPoint).
Returns an Edge representing the given command, assuming a given startPoint."""

endPoint = commandEndPoint(cmd, startPoint)
Expand Down Expand Up @@ -369,7 +369,7 @@ def edgeForCmd(cmd, startPoint):
return None

def wireForPath(path, startPoint = Vector(0, 0, 0)):
"""(path, [startPoint=Vector(0,0,0)])
"""wireForPath(path, [startPoint=Vector(0,0,0)])
Returns a wire representing all move commands found in the given path."""
edges = []
rapid = []
Expand All @@ -384,7 +384,7 @@ def wireForPath(path, startPoint = Vector(0, 0, 0)):
return (Part.Wire(edges), rapid)

def wiresForPath(path, startPoint = Vector(0, 0, 0)):
"""(path, [startPoint=Vector(0,0,0)])
"""wiresForPath(path, [startPoint=Vector(0,0,0)])
Returns a collection of wires, each representing a continuous cutting Path in path."""
wires = []
if hasattr(path, "Commands"):
Expand All @@ -402,7 +402,7 @@ def wiresForPath(path, startPoint = Vector(0, 0, 0)):
return wires

def arcToHelix(edge, z0, z1):
"""(edge, z0, z1)
"""arcToHelix(edge, z0, z1)
Assuming edge is an arc it'll return a helix matching the arc starting at z0 and rising/falling to z1."""


Expand All @@ -421,7 +421,7 @@ def arcToHelix(edge, z0, z1):


def helixToArc(edge, z = 0):
"""(edge, z=0)
"""helixToArc(edge, z=0)
Returns the projection of the helix onto the XY-plane with a given offset."""
p1 = edge.valueAt(edge.FirstParameter)
p2 = edge.valueAt((edge.FirstParameter + edge.LastParameter)/2)
Expand All @@ -432,7 +432,7 @@ def helixToArc(edge, z = 0):
return Part.Edge(Part.Arc(p01, p02, p03))

def splitArcAt(edge, pt):
"""(edge, pt)
"""splitArcAt(edge, pt)
Returns a list of 2 edges which together form the original arc split at the given point.
The Vector pt has to represent a point on the given arc."""
p1 = edge.valueAt(edge.FirstParameter)
Expand All @@ -453,7 +453,7 @@ def splitArcAt(edge, pt):
return edges

def splitEdgeAt(edge, pt):
"""(edge, pt)
"""splitEdgeAt(edge, pt)
Returns a list of 2 edges, forming the original edge split at the given point.
The results are undefined if the Vector representing the point is not part of the edge."""
# I could not get the OCC parameterAt and split to work ...
Expand Down Expand Up @@ -545,7 +545,7 @@ def flipEdge(edge):

return Part.Edge(flipped)

global OddsAndEnds
global OddsAndEnds # pylint: disable=global-statement
OddsAndEnds.append(edge)
PathLog.warning(translate('PathGeom', "%s not support for flipping") % type(edge.Curve))

Expand Down

0 comments on commit c5c976f

Please sign in to comment.