Skip to content

Commit

Permalink
Rebase on new Line/LineSegment code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Jan 3, 2017
1 parent 23196b4 commit 198ab6d
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Draft/DraftGeomUtils.py
Expand Up @@ -454,7 +454,7 @@ def getLineIntersections(pt1,pt2,pt3,pt4,infinite1,infinite2):

return int
else:
# print("DraftGeomUtils: Unsupported curve type: (" + str(edge1.Curve) + ", " + str(edge2.Curve) + ")")
print("DraftGeomUtils: Unsupported curve type: (" + str(edge1.Curve) + ", " + str(edge2.Curve) + ")")
return []

def wiresIntersect(wire1,wire2):
Expand Down
24 changes: 12 additions & 12 deletions src/Mod/Path/PathScripts/PathDressupHoldingTags.py
Expand Up @@ -93,7 +93,7 @@ def debugCylinder(vector, r, height, label, color = None):
def pathCommandForEdge(edge):
pt = edge.valueAt(edge.LastParameter)
params = {'X': pt.x, 'Y': pt.y, 'Z': pt.z}
if type(edge.Curve) == Part.Line:
if type(edge.Curve) == Part.Line or type(edge.Curve) == Part.LineSegment:
command = Path.Command('G1', params)
else:
p1 = edge.valueAt(edge.FirstParameter)
Expand Down Expand Up @@ -151,7 +151,7 @@ def top(self):
return self.z + self.actualHeight

def centerLine(self):
return Part.Line(self.originAt(self.bottom() - 1), self.originAt(self.top() + 1))
return Part.LineSegment(self.originAt(self.bottom() - 1), self.originAt(self.top() + 1))

def createSolidsAt(self, z):
self.z = z
Expand Down Expand Up @@ -210,9 +210,9 @@ def hasEdges(self):
return self.state != self.Pnone

def moveEdgeToPlateau(self, edge):
if type(edge.Curve) is Part.Line:
if type(edge.Curve) is Part.Line or type(edge.Curve) is Part.LineSegment:
e = copy.copy(edge)
z = edge.Curve.StartPoint.z
z = edge.valueAt(edge.FirstParameter).z
elif type(edge.Curve) is Part.Circle:
# it's an arc
e = copy.copy(edge)
Expand All @@ -236,7 +236,7 @@ def intersectP0Core(self, edge):
if PathGeom.pointsCoincide(i, edge.valueAt(edge.FirstParameter)):
# if P0 and P1 are the same, we need to insert a segment for the rise
debugPrint('P0', "------- insert vertical rise (%s)" % i)
self.edges.append(Part.Edge(Part.Line(i, FreeCAD.Vector(i.x, i.y, self.tag.top()))))
self.edges.append(Part.Edge(Part.LineSegment(i, FreeCAD.Vector(i.x, i.y, self.tag.top()))))
self.p1 = i
self.state = self.P1
return edge
Expand Down Expand Up @@ -267,8 +267,8 @@ def intersectP0(self, edge):
# if we have no core the tip is the origin of the Tag
line = Part.Edge(self.tag.centerLine())
debugEdge(line, "------- center line", 'P0')
#i = DraftGeomUtils.findIntersection(line, edge, True)
i = line.Curve.intersect(edge)
i = DraftGeomUtils.findIntersection(line, edge, True)
#i = line.Curve.intersect(edge)
if i:
debugPrint('P0', '------- P0 split @ (%.2f, %.2f, %.2f)' % (i[0].x, i[0].y, i[0].z))
if PathGeom.pointsCoincide(i[0], edge.valueAt(edge.LastParameter)):
Expand Down Expand Up @@ -329,7 +329,7 @@ def intersectP2(self, edge):
if i:
if PathGeom.pointsCoincide(i, edge.valueAt(edge.FirstParameter)):
debugPrint('P2', "------- insert exit plunge (%s)" % i)
self.edges.append(Part.Edge(Part.Line(FreeCAD.Vector(i.x, i.y, self.tag.top()), i)))
self.edges.append(Part.Edge(Part.LineSegment(FreeCAD.Vector(i.x, i.y, self.tag.top()), i)))
e = None
tail = edge
elif PathGeom.pointsCoincide(i, edge.valueAt(edge.LastParameter)):
Expand Down Expand Up @@ -390,7 +390,7 @@ def mapEdgeToSolid(self, edge, label):
p1a = edge.valueAt(edge.FirstParameter)
p1b = FreeCAD.Vector(p1a.x, p1a.y, p1a.z + self.height)
p1a.z = self.bottom()
e1 = Part.Edge(Part.Line(p1a, p1b))
e1 = Part.Edge(Part.LineSegment(p1a, p1b))
p1 = self.nextIntersectionClosestTo(e1, self.solid, p1b) # top most intersection
print("---------- p1: (%s %s) -> %s %d" % (p1a, p1b, p1, self.solid.isInside(p1, 0.0000001, True)))
if not p1:
Expand All @@ -400,7 +400,7 @@ def mapEdgeToSolid(self, edge, label):
p2a = edge.valueAt(edge.LastParameter)
p2b = FreeCAD.Vector(p2a.x, p2a.y, p2a.z + self.height)
p2a.z = self.bottom()
e2 = Part.Edge(Part.Line(p2a, p2b))
e2 = Part.Edge(Part.LineSegment(p2a, p2b))
p2 = self.nextIntersectionClosestTo(e2, self.solid, p2b) # top most intersection
if not p2:
p1 = edge.valueAt(edge.FirstParameter)
Expand All @@ -418,8 +418,8 @@ def mapEdgeToSolid(self, edge, label):
if PathGeom.pointsCoincide(p1, p2):
return []

if type(edge.Curve) == Part.Line:
e = Part.Edge(Part.Line(p1, p2))
if type(edge.Curve) == Part.Line or type(edge.Curve) == Part.LineSegment:
e = Part.Edge(Part.LineSegment(p1, p2))
debugEdge(e, "-------- >>")
return [e]

Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Path/PathTests/PathTestUtils.py
Expand Up @@ -45,9 +45,9 @@ def assertCoincide(self, pt1, pt2):

def assertLine(self, edge, pt1, pt2):
"""Verify that edge is a line from pt1 to pt2."""
self.assertIs(type(edge.Curve), Part.LineSegment)
self.assertCoincide(edge.Curve.StartPoint, pt1)
self.assertCoincide(edge.Curve.EndPoint, pt2)
self.assertIs(type(edge.Curve), Part.Line)
self.assertCoincide(edge.valueAt(edge.FirstParameter), pt1)
self.assertCoincide(edge.valueAt(edge.LastParameter), pt2)

def assertLines(self, edgs, tail, points):
"""Verify that the edges match the polygon resulting from points."""
Expand Down

0 comments on commit 198ab6d

Please sign in to comment.