Skip to content

Commit

Permalink
Tests and fixes for triangular shaped tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Nov 22, 2016
1 parent 1fd4c49 commit 3ce5ea6
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 352 deletions.
32 changes: 31 additions & 1 deletion src/Mod/Path/PathScripts/PathDressupHoldingTags.py
Expand Up @@ -149,6 +149,9 @@ def bottom(self):
def top(self):
return self.z + self.actualHeight

def centerLine(self):
return Part.Line(self.originAt(self.bottom()), self.originAt(self.top()))

def createSolidsAt(self, z):
self.z = z
r1 = self.width / 2
Expand Down Expand Up @@ -210,30 +213,57 @@ def moveEdgeToPlateau(self, edge):
#print("\nplateau= %s - %s" %(pt1, pt2))
return Part.Edge(Part.Line(pt1, pt2))

def intersectP0(self, edge):
def intersectP0Core(self, edge):
#print("----- P0 (%s - %s)" % (edge.Curve.StartPoint, edge.Curve.EndPoint))

i = self.tag.nextIntersectionClosestTo(edge, self.tag.core, edge.Curve.StartPoint)
if i:
if pointsCoincide(i, edge.Curve.StartPoint):
# if P0 and P1 are the same, we need to insert a segment for the rise
#print("------- insert vertical rise (%s)" % i)
self.edges.append(Part.Edge(Part.Line(i, FreeCAD.Vector(i.x, i.y, self.tag.top()))))
self.p1 = i
self.state = self.P1
return edge
if pointsCoincide(i, edge.Curve.EndPoint):
#print("------- consumed (%s)" % i)
e = edge
tail = None
else:
#print("------- split at (%s)" % i)
e, tail = self.tag.splitEdgeAt(edge, i)
self.p1 = e.Curve.EndPoint
self.edges.append(self.tag.mapEdgeToSolid(e))
self.state = self.P1
return tail
# no intersection, the entire edge fits between P0 and P1
#print("------- no intersection")
self.edges.append(self.tag.mapEdgeToSolid(edge))
return None

def intersectP0(self, edge):
if self.tag.core:
return self.intersectP0Core(edge)
# if we have no core the tip is the origin of the Tag
line = Part.Edge(self.tag.centerLine())
i = DraftGeomUtils.findIntersection(line, edge)
if i:
if pointsCoincide(i[0], edge.Curve.EndPoint):
e = edge
tail = None
else:
e, tail = self.tag.splitEdgeAt(edge, i[0])
self.state = self.P2 # P1 and P2 are identical for triangular tags
self.p1 = i[0]
self.p2 = i[0]
else:
e = edge
tail = None
self.edges.append(self.tag.mapEdgeToSolid(e))
return tail



def intersectP1(self, edge):
#print("----- P1 (%s - %s)" % (edge.Curve.StartPoint, edge.Curve.EndPoint))
i = self.tag.nextIntersectionClosestTo(edge, self.tag.core, edge.Curve.EndPoint)
Expand Down

0 comments on commit 3ce5ea6

Please sign in to comment.