本文整理汇总了Python中PathScripts.PathGeom.PathGeom.pointsCoincide方法的典型用法代码示例。如果您正苦于以下问题:Python PathGeom.pointsCoincide方法的具体用法?Python PathGeom.pointsCoincide怎么用?Python PathGeom.pointsCoincide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathScripts.PathGeom.PathGeom
的用法示例。
在下文中一共展示了PathGeom.pointsCoincide方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def __init__(self, edge, tag, i, segm, maxZ):
debugEdge(edge, 'MapWireToTag(%.2f, %.2f, %.2f)' % (i.x, i.y, i.z))
self.tag = tag
self.segm = segm
self.maxZ = maxZ
if PathGeom.pointsCoincide(edge.valueAt(edge.FirstParameter), i):
tail = edge
self.commands = []
debugEdge(tail, '.........=')
elif PathGeom.pointsCoincide(edge.valueAt(edge.LastParameter), i):
debugEdge(edge, '++++++++ .')
self.commands = PathGeom.cmdsForEdge(edge, segm=segm)
tail = None
else:
e, tail = PathGeom.splitEdgeAt(edge, i)
debugEdge(e, '++++++++ .')
self.commands = PathGeom.cmdsForEdge(e, segm=segm)
debugEdge(tail, '.........-')
self.initialEdge = edge
self.tail = tail
self.edges = []
self.entry = i
if tail:
PathLog.debug("MapWireToTag(%s - %s)" % (i, tail.valueAt(tail.FirstParameter)))
else:
PathLog.debug("MapWireToTag(%s - )" % i)
self.complete = False
self.haveProblem = False
示例2: isValidTagStartIntersection
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def isValidTagStartIntersection(self, edge, i):
if PathGeom.pointsCoincide(i, edge.valueAt(edge.LastParameter)):
return False
p1 = edge.valueAt(edge.FirstParameter)
p2 = edge.valueAt(edge.LastParameter)
if PathGeom.pointsCoincide(PathGeom.xy(p1), PathGeom.xy(p2)):
# if this vertical goes up, it can't be the start of a tag intersection
if p1.z < p2.z:
return False
return True
示例3: isEntryOrExitStrut
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def isEntryOrExitStrut(self, e):
p1 = e.valueAt(e.FirstParameter)
p2 = e.valueAt(e.LastParameter)
if PathGeom.pointsCoincide(p1, self.entry) and p2.z >= self.entry.z:
return 1
if PathGeom.pointsCoincide(p2, self.entry) and p1.z >= self.entry.z:
return 1
if PathGeom.pointsCoincide(p1, self.exit) and p2.z >= self.exit.z:
return 2
if PathGeom.pointsCoincide(p2, self.exit) and p1.z >= self.exit.z:
return 2
return 0
示例4: orientSelected
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def orientSelected(self, axis):
def flipSel(sel):
PathLog.debug("flip")
p = sel.Object.Placement
loc = sel.Object.Placement.Base
rot = FreeCAD.Rotation(FreeCAD.Vector(1-axis.x, 1-axis.y, 1-axis.z), 180)
sel.Object.Placement = FreeCAD.Placement(loc, p.Rotation.multiply(rot))
def rotateSel(sel, n):
p = sel.Object.Placement
loc = sel.Object.Placement.Base
r = axis.cross(n) # rotation axis
a = DraftVecUtils.angle(n, axis, r) * 180 / math.pi
PathLog.debug("oh boy: (%.2f, %.2f, %.2f) -> %.2f" % (r.x, r.y, r.z, a))
Draft.rotate(sel.Object, a, axis=r)
selObject = None
selFeature = None
for sel in FreeCADGui.Selection.getSelectionEx():
selObject = sel.Object
for feature in sel.SubElementNames:
selFeature = feature
sub = sel.Object.Shape.getElement(feature)
if 'Face' == sub.ShapeType:
n = sub.Surface.Axis
if sub.Orientation == 'Reversed':
n = FreeCAD.Vector() - n
PathLog.debug("(%.2f, %.2f, %.2f) -> reversed (%s)" % (n.x, n.y, n.z, sub.Orientation))
else:
PathLog.debug("(%.2f, %.2f, %.2f) -> forward (%s)" % (n.x, n.y, n.z, sub.Orientation))
if PathGeom.pointsCoincide(axis, n):
PathLog.debug("face properly oriented (%.2f, %.2f, %.2f)" % (n.x, n.y, n.z))
else:
if PathGeom.pointsCoincide(axis, FreeCAD.Vector() - n):
flipSel(sel)
else:
rotateSel(sel, n)
if 'Edge' == sub.ShapeType:
n = (sub.Vertexes[1].Point - sub.Vertexes[0].Point).normalize()
if PathGeom.pointsCoincide(axis, n) or PathGeom.pointsCoincide(axis, FreeCAD.Vector() - n):
# Don't really know the orientation of an edge, so let's just flip the object
# and if the user doesn't like it they can flip again
flipSel(sel)
else:
rotateSel(sel, n)
if selObject and selFeature:
FreeCADGui.Selection.clearSelection()
FreeCADGui.Selection.addSelection(selObject, selFeature)
示例5: buildpathocc
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def buildpathocc(self, obj, wires, zValues):
'''buildpathocc(obj, wires, zValues) ... internal helper function to generate engraving commands.'''
PathLog.track(obj.Label, len(wires), zValues)
for wire in wires:
offset = wire
# reorder the wire
offset = DraftGeomUtils.rebaseWire(offset, obj.StartVertex)
last = None
for z in zValues:
if last:
self.commandlist.append(Path.Command('G1', {'X': last.x, 'Y': last.y, 'Z': z, 'F': self.vertFeed}))
for edge in offset.Edges:
if not last:
# we set the first move to our first point
last = edge.Vertexes[0].Point
if len(offset.Edges) > 1:
e2 = offset.Edges[1]
if not PathGeom.pointsCoincide(edge.Vertexes[-1].Point, e2.Vertexes[0].Point) and not PathGeom.pointsCoincide(edge.Vertexes[-1].Point, e2.Vertexes[-1].Point):
PathLog.debug("flip first edge")
last = edge.Vertexes[-1].Point
else:
PathLog.debug("original first edge")
else:
PathLog.debug("not enough edges to flip")
self.commandlist.append(Path.Command('G0', {'X': last.x, 'Y': last.y, 'Z': obj.ClearanceHeight.Value, 'F': self.horizRapid}))
self.commandlist.append(Path.Command('G0', {'X': last.x, 'Y': last.y, 'Z': obj.SafeHeight.Value, 'F': self.vertRapid}))
self.commandlist.append(Path.Command('G0', {'X': last.x, 'Y': last.y, 'Z': z, 'F': self.vertFeed}))
if PathGeom.pointsCoincide(last, edge.Vertexes[0].Point):
for cmd in PathGeom.cmdsForEdge(edge):
params = cmd.Parameters
params.update({'Z': z, 'F': self.horizFeed})
self.commandlist.append(Path.Command(cmd.Name, params))
last = edge.Vertexes[-1].Point
else:
for cmd in PathGeom.cmdsForEdge(edge, True):
params = cmd.Parameters
params.update({'Z': z, 'F': self.horizFeed})
self.commandlist.append(Path.Command(cmd.Name, params))
last = edge.Vertexes[0].Point
self.commandlist.append(Path.Command('G0', {'Z': obj.ClearanceHeight.Value, 'F': self.vertRapid}))
if self.commandlist:
self.commandlist.pop()
示例6: orderAndFlipEdges
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def orderAndFlipEdges(self, edges):
PathLog.track("entry(%.2f, %.2f, %.2f), exit(%.2f, %.2f, %.2f)" % (self.entry.x, self.entry.y, self.entry.z, self.exit.x, self.exit.y, self.exit.z))
self.edgesOrder = []
outputEdges = []
p0 = self.entry
lastP = p0
while edges:
# print("(%.2f, %.2f, %.2f) %d %d" % (p0.x, p0.y, p0.z))
for e in edges:
p1 = e.valueAt(e.FirstParameter)
p2 = e.valueAt(e.LastParameter)
if PathGeom.pointsCoincide(p1, p0):
outputEdges.append((e, False))
edges.remove(e)
lastP = None
p0 = p2
debugEdge(e, ">>>>> no flip")
break
elif PathGeom.pointsCoincide(p2, p0):
outputEdges.append((e, True))
edges.remove(e)
lastP = None
p0 = p1
debugEdge(e, ">>>>> flip")
break
else:
debugEdge(e, "<<<<< (%.2f, %.2f, %.2f)" % (p0.x, p0.y, p0.z))
if lastP == p0:
self.edgesOrder.append(outputEdges)
self.edgesOrder.append(edges)
print('ordered edges:')
for e, flip in outputEdges:
debugEdge(e, ' %c ' % ('<' if flip else '>'), False)
print('remaining edges:')
for e in edges:
debugEdge(e, ' ', False)
raise ValueError("No connection to %s" % (p0))
elif lastP:
PathLog.debug("xxxxxx (%.2f, %.2f, %.2f) (%.2f, %.2f, %.2f)" % (p0.x, p0.y, p0.z, lastP.x, lastP.y, lastP.z))
else:
PathLog.debug("xxxxxx (%.2f, %.2f, %.2f) -" % (p0.x, p0.y, p0.z))
lastP = p0
PathLog.track("-")
return outputEdges
示例7: generateHelix
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def generateHelix(self):
edges = self.wire.Edges
minZ = self.findMinZ(edges)
outedges = []
i = 0
while i < len(edges):
edge = edges[i]
israpid = False
for redge in self.rapids:
if PathGeom.edgesMatch(edge, redge):
israpid = True
if not israpid:
bb = edge.BoundBox
p0 = edge.Vertexes[0].Point
p1 = edge.Vertexes[1].Point
if bb.XLength < 1e-6 and bb.YLength < 1e-6 and bb.ZLength > 0 and p0.z > p1.z:
# plungelen = abs(p0.z-p1.z)
PathLog.debug("Found plunge move at X:{} Y:{} From Z:{} to Z{}, Searching for closed loop".format(p0.x, p0.y, p0.z, p1.z))
# next need to determine how many edges in the path after plunge are needed to cover the length:
loopFound = False
rampedges = []
j = i + 1
while not loopFound:
candidate = edges[j]
cp0 = candidate.Vertexes[0].Point
cp1 = candidate.Vertexes[1].Point
if PathGeom.pointsCoincide(p1, cp1):
# found closed loop
loopFound = True
rampedges.append(candidate)
break
if abs(cp0.z - cp1.z) > 1e-6:
# this edge is not parallel to XY plane, not qualified for ramping.
break
# PathLog.debug("Next edge length {}".format(candidate.Length))
rampedges.append(candidate)
j = j + 1
if j >= len(edges):
break
if len(rampedges) == 0 or not loopFound:
PathLog.debug("No suitable helix found")
outedges.append(edge)
else:
outedges.extend(self.createHelix(rampedges, p0, p1))
if not PathGeom.isRoughly(p1.z, minZ):
# the edges covered by the helix not handled again,
# unless reached the bottom height
i = j
else:
outedges.append(edge)
else:
outedges.append(edge)
i = i + 1
return outedges
示例8: tagAtPoint
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def tagAtPoint(self, point, matchZ):
x = point[0]
y = point[1]
z = point[2]
if self.tags and not matchZ:
z = self.tags[0].point.z
p = FreeCAD.Vector(x, y, z)
for i, tag in enumerate(self.tags):
if PathGeom.pointsCoincide(p, tag.point, tag.sphere.radius.getValue() * 1.3):
return i
return -1
示例9: shell
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def shell(self):
if len(self.edges) > 1:
wire = Part.Wire(self.initialEdge)
else:
edge = self.edges[0]
if PathGeom.pointsCoincide(edge.valueAt(edge.FirstParameter), self.finalEdge.valueAt(self.finalEdge.FirstParameter)):
wire = Part.Wire(self.finalEdge)
elif hasattr(self, 'initialEdge') and PathGeom.pointsCoincide(edge.valueAt(edge.FirstParameter), self.initialEdge.valueAt(self.initialEdge.FirstParameter)):
wire = Part.Wire(self.initialEdge)
else:
wire = Part.Wire(edge)
for edge in self.edges[1:]:
if PathGeom.pointsCoincide(edge.valueAt(edge.FirstParameter), self.finalEdge.valueAt(self.finalEdge.FirstParameter)):
wire.add(self.finalEdge)
else:
wire.add(edge)
shell = wire.extrude(FreeCAD.Vector(0, 0, self.tag.height + 1))
return shell.removeShape(filter(lambda f: PathGeom.isRoughly(f.Area, 0), shell.Faces))
示例10: removePathCrossing
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def removePathCrossing(self, commands, bone1, bone2):
commands.append(bone2.lastCommand)
bones = bone2.commands
if True and hasattr(bone1, "outCommands") and hasattr(bone2, "inCommands"):
inEdges = edgesForCommands(bone1.outCommands, bone1.tip)
outEdges = edgesForCommands(bone2.inCommands, bone2.inChord.Start)
for i in range(len(inEdges)):
e1 = inEdges[i]
for j in range(len(outEdges)-1, -1, -1):
e2 = outEdges[j]
cutoff = DraftGeomUtils.findIntersection(e1, e2)
for pt in cutoff:
# debugCircle(e1.Curve.Center, e1.Curve.Radius, "bone.%d-1" % (self.boneId), (1.,0.,0.))
# debugCircle(e2.Curve.Center, e2.Curve.Radius, "bone.%d-2" % (self.boneId), (0.,1.,0.))
if PathGeom.pointsCoincide(pt, e1.valueAt(e1.LastParameter)) or PathGeom.pointsCoincide(pt, e2.valueAt(e2.FirstParameter)):
continue
# debugMarker(pt, "it", (0.0, 1.0, 1.0))
# 1. remove all redundant commands
commands = commands[:-(len(inEdges) - i)]
# 2., correct where c1 ends
c1 = bone1.outCommands[i]
c1Params = c1.Parameters
c1Params.update({'X': pt.x, 'Y': pt.y, 'Z': pt.z})
c1 = Path.Command(c1.Name, c1Params)
commands.append(c1)
# 3. change where c2 starts, this depends on the command itself
c2 = bone2.inCommands[j]
if c2.Name in movearc:
center = e2.Curve.Center
offset = center - pt
c2Params = c2.Parameters
c2Params.update({'I': offset.x, 'J': offset.y, 'K': offset.z})
c2 = Path.Command(c2.Name, c2Params)
bones = [c2]
bones.extend(bone2.commands[j+1:])
else:
bones = bone2.commands[j:]
# there can only be the one ...
return commands, bones
return commands, bones
示例11: add
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def add(self, edge):
self.tail = None
self.finalEdge = edge
if self.tag.solid.isInside(edge.valueAt(edge.LastParameter), PathGeom.Tolerance, True):
self.addEdge(edge)
else:
i = self.tag.intersects(edge, edge.LastParameter)
if not i:
self.offendingEdge = edge
debugEdge(edge, 'offending Edge:', False)
o = self.tag.originAt(self.tag.z)
print('originAt: (%.2f, %.2f, %.2f)' % (o.x, o.y, o.z))
i = edge.valueAt(edge.FirstParameter)
if PathGeom.pointsCoincide(i, edge.valueAt(edge.FirstParameter)):
self.tail = edge
else:
e, tail = PathGeom.splitEdgeAt(edge, i)
self.addEdge(e)
self.tail = tail
self.exit = i
self.complete = True
self.commands.extend(self.commandsForEdges())
示例12: makeAreaCurve
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def makeAreaCurve(edges, direction, startpt=None, endpt=None):
curveobj = area.Curve()
cleanededges = Part.__sortEdges__(PathUtils.cleanedges(edges, 0.01))
# for e in cleanededges:
# print str(e.valueAt(e.FirstParameter)) + "," +
# str(e.valueAt(e.LastParameter))
edgelist = []
if len(cleanededges) == 1: # user selected a single edge.
edgelist = cleanededges
else:
# edgelist = [] #Multiple edges. Need to sequence the vetexes.
# First get the first segment oriented correctly.
# We first compare the last parameter of the first segment to see if it
# matches either end of the second segment. If not, it must need
# flipping.
p0L = cleanededges[0].valueAt(cleanededges[0].LastParameter)
if PathGeom.pointsCoincide(p0L, cleanededges[1].valueAt(cleanededges[1].FirstParameter)) or PathGeom.pointsCoincide(p0L, cleanededges[1].valueAt(cleanededges[1].LastParameter)):
edge0 = cleanededges[0]
else:
edge0 = PathUtils.reverseEdge(cleanededges[0])
edgelist.append(edge0)
# Now iterate the rest of the edges matching the last parameter of the
# previous segment.
for edge in cleanededges[1:]:
if PathGeom.pointsCoincide(edge.valueAt(edge.FirstParameter), edgelist[-1].valueAt(edgelist[-1].LastParameter)):
nextedge = edge
else:
nextedge = PathUtils.reverseEdge(edge)
edgelist.append(nextedge)
# print "makeareacurve 87: " + "area.Point(" +
# str(edgelist[0].Vertexes[0].X) + ", " +
# str(edgelist[0].Vertexes[0].Y)+")"
curveobj.append(area.Point(edgelist[0].Vertexes[
0].X, edgelist[0].Vertexes[0].Y))
# seglist =[]
# if direction=='CW':
# edgelist.reverse()
# for e in edgelist:
# seglist.append(PathUtils.reverseEdge(e)) #swap end points on every segment
# else:
# for e in edgelist:
# seglist.append(e)
for s in edgelist:
curveobj.append(makeAreaVertex(s))
if startpt:
# future nearest point code yet to be worked out -fixme
# v1 = Vector(startpt.X,startpt.Y,startpt.Z)
# perppoint1 = DraftGeomUtils.findPerpendicular(v1,firstedge)
# perppoint1 = DraftGeomUtils.findDistance(v1,firstedge)
# if perppoint1:
# curveobj.ChangeStart(area.Point(perppoint1[0].x,perppoint1[0].y))
# else:
# curveobj.ChangeStart(area.Point(startpt.X,startpt.Y))
curveobj.ChangeStart(area.Point(startpt.x, startpt.y))
if endpt:
# future nearest point code yet to be worked out -fixme
# v2 = Vector(endpt.X,endpt.Y,endpt.Z)
# perppoint2 = DraftGeomUtils.findPerpendicular(v2,lastedge)
# if perppoint2:
# curveobj.ChangeEnd(area.Point(perppoint2[0].x,perppoint2[0].y))
# else:
# curveobj.ChangeEnd(area.Point(endpt.X,endpt.Y))
curveobj.ChangeEnd(area.Point(endpt.x, endpt.y))
if curveobj.IsClockwise() and direction == 'CCW':
curveobj.Reverse()
elif not curveobj.IsClockwise() and direction == 'CW':
curveobj.Reverse()
return curveobj
示例13: smoothChordCommands
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def smoothChordCommands(self, bone, inChord, outChord, edge, wire, corner, smooth, color=None):
if smooth == 0:
PathLog.info(" No smoothing requested")
return [bone.lastCommand, outChord.g1Command(bone.F)]
d = 'in'
refPoint = inChord.Start
if smooth == Smooth.Out:
d = 'out'
refPoint = outChord.End
if DraftGeomUtils.areColinear(inChord.asEdge(), outChord.asEdge()):
PathLog.info(" straight edge %s" % d)
return [outChord.g1Command(bone.F)]
pivot = None
pivotDistance = 0
PathLog.info("smooth: (%.2f, %.2f)-(%.2f, %.2f)" % (edge.Vertexes[0].Point.x, edge.Vertexes[0].Point.y, edge.Vertexes[1].Point.x, edge.Vertexes[1].Point.y))
for e in wire.Edges:
self.dbg.append(e)
if type(e.Curve) == Part.LineSegment or type(e.Curve) == Part.Line:
PathLog.debug(" (%.2f, %.2f)-(%.2f, %.2f)" % (e.Vertexes[0].Point.x, e.Vertexes[0].Point.y, e.Vertexes[1].Point.x, e.Vertexes[1].Point.y))
else:
PathLog.debug(" (%.2f, %.2f)^%.2f" % (e.Curve.Center.x, e.Curve.Center.y, e.Curve.Radius))
for pt in DraftGeomUtils.findIntersection(edge, e, True, findAll=True):
if not PathGeom.pointsCoincide(pt, corner) and self.pointIsOnEdge(pt, e):
# debugMarker(pt, "candidate-%d-%s" % (self.boneId, d), color, 0.05)
PathLog.debug(" -> candidate")
distance = (pt - refPoint).Length
if not pivot or pivotDistance > distance:
pivot = pt
pivotDistance = distance
else:
PathLog.debug(" -> corner intersect")
if pivot:
# debugCircle(pivot, self.toolRadius, "pivot.%d-%s" % (self.boneId, d), color)
pivotEdge = Part.Edge(Part.Circle(pivot, FreeCAD.Vector(0, 0, 1), self.toolRadius))
t1 = self.findPivotIntersection(pivot, pivotEdge, inChord.asEdge(), inChord.End, d, color)
t2 = self.findPivotIntersection(pivot, pivotEdge, outChord.asEdge(), inChord.End, d, color)
commands = []
if not PathGeom.pointsCoincide(t1, inChord.Start):
PathLog.debug(" add lead in")
commands.append(Chord(inChord.Start, t1).g1Command(bone.F))
if bone.obj.Side == Side.Left:
PathLog.debug(" add g3 command")
commands.append(Chord(t1, t2).g3Command(pivot, bone.F))
else:
PathLog.debug(" add g2 command center=(%.2f, %.2f) -> from (%2f, %.2f) to (%.2f, %.2f" % (pivot.x, pivot.y, t1.x, t1.y, t2.x, t2.y))
commands.append(Chord(t1, t2).g2Command(pivot, bone.F))
if not PathGeom.pointsCoincide(t2, outChord.End):
PathLog.debug(" add lead out")
commands.append(Chord(t2, outChord.End).g1Command(bone.F))
# debugMarker(pivot, "pivot.%d-%s" % (self.boneId, d), color, 0.2)
# debugMarker(t1, "pivot.%d-%s.in" % (self.boneId, d), color, 0.1)
# debugMarker(t2, "pivot.%d-%s.out" % (self.boneId, d), color, 0.1)
return commands
PathLog.info(" no pivot found - straight command")
return [inChord.g1Command(bone.F), outChord.g1Command(bone.F)]
示例14: connectsTo
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def connectsTo(self, chord):
return PathGeom.pointsCoincide(self.End, chord.Start)
示例15: createRampMethod2
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import pointsCoincide [as 别名]
def createRampMethod2(self, rampedges, p0, projectionlen, rampangle):
"""
This method generates ramp with following pattern:
1. Start from the original startpoint of the plunge
2. Calculate the distance on the path which is needed to implement the ramp
and travel that distance while maintaining start depth
3. Start ramping while travelling the original path backwards until reaching the
original plunge end point
4. Continue with the original path
"""
outedges = []
rampremaining = projectionlen
curPoint = p0 # start from the upper point of plunge
if PathGeom.pointsCoincide(PathGeom.xy(p0), PathGeom.xy(rampedges[-1].valueAt(rampedges[-1].LastParameter))):
PathLog.debug("The ramp forms a closed wire, needless to move on original Z height")
else:
for i, redge in enumerate(rampedges):
if redge.Length >= rampremaining:
# this edge needs to be split
p1 = self.getSplitPoint(redge, rampremaining)
splitEdge = PathGeom.splitEdgeAt(redge, p1)
PathLog.debug("Got split edges with lengths: {}, {}".format(splitEdge[0].Length, splitEdge[1].Length))
# ramp starts at the last point of first edge
p1 = splitEdge[0].valueAt(splitEdge[0].LastParameter)
p1.z = p0.z
outedges.append(self.createRampEdge(splitEdge[0], curPoint, p1))
# now we have reached the beginning of the ramp.
# start that by going to the beginning of this splitEdge
deltaZ = splitEdge[0].Length / math.tan(math.radians(rampangle))
newPoint = FreeCAD.Base.Vector(splitEdge[0].valueAt(splitEdge[0].FirstParameter).x, splitEdge[0].valueAt(splitEdge[0].FirstParameter).y, p1.z - deltaZ)
outedges.append(self.createRampEdge(splitEdge[0], p1, newPoint))
curPoint = newPoint
elif i == len(rampedges) - 1:
# last ramp element but still did not reach the full length?
# Probably a rounding issue on floats.
# Lets start the ramp anyway
p1 = redge.valueAt(redge.LastParameter)
p1.z = p0.z
outedges.append(self.createRampEdge(redge, curPoint, p1))
# and go back that edge
deltaZ = redge.Length / math.tan(math.radians(rampangle))
newPoint = FreeCAD.Base.Vector(redge.valueAt(redge.FirstParameter).x, redge.valueAt(redge.FirstParameter).y, p1.z - deltaZ)
outedges.append(self.createRampEdge(redge, p1, newPoint))
curPoint = newPoint
else:
# we are travelling on start depth
newPoint = FreeCAD.Base.Vector(redge.valueAt(redge.LastParameter).x, redge.valueAt(redge.LastParameter).y, p0.z)
outedges.append(self.createRampEdge(redge, curPoint, newPoint))
curPoint = newPoint
rampremaining = rampremaining - redge.Length
# the last edge got handled previously
rampedges.pop()
# ramp backwards to the plunge position
for i, redge in enumerate(reversed(rampedges)):
deltaZ = redge.Length / math.tan(math.radians(rampangle))
newPoint = FreeCAD.Base.Vector(redge.valueAt(redge.FirstParameter).x, redge.valueAt(redge.FirstParameter).y, curPoint.z - deltaZ)
if i == len(rampedges) - 1:
# make sure that the last point of the ramps ends to the original position
newPoint = redge.valueAt(redge.FirstParameter)
outedges.append(self.createRampEdge(redge, curPoint, newPoint))
curPoint = newPoint
return outedges