本文整理汇总了Python中PathScripts.PathGeom.PathGeom.splitEdgeAt方法的典型用法代码示例。如果您正苦于以下问题:Python PathGeom.splitEdgeAt方法的具体用法?Python PathGeom.splitEdgeAt怎么用?Python PathGeom.splitEdgeAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathScripts.PathGeom.PathGeom
的用法示例。
在下文中一共展示了PathGeom.splitEdgeAt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test65
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import splitEdgeAt [as 别名]
def test65(self):
"""Verify splitEdgeAt."""
e = PathGeom.splitEdgeAt(Part.Edge(Part.LineSegment(Vector(), Vector(2, 4, 6))), Vector(1, 2, 3))
self.assertLine(e[0], Vector(), Vector(1,2,3))
self.assertLine(e[1], Vector(1,2,3), Vector(2,4,6))
# split an arc
p1 = Vector(10,-10,1)
p2 = Vector(0,0,1)
p3 = Vector(10,10,1)
arc = Part.Edge(Part.Arc(p1, p2, p3))
e = PathGeom.splitEdgeAt(arc, p2)
o = 10*math.sin(math.pi/4)
p12 = Vector(10 - o, -o, 1)
p23 = Vector(10 - o, +o, 1)
self.assertCurve(e[0], p1, p12, p2)
self.assertCurve(e[1], p2, p23, p3)
# split a helix
p1 = Vector(10,-10,0)
p2 = Vector(0,0,5)
p3 = Vector(10,10,10)
h = PathGeom.arcToHelix(arc, 0, 10)
self.assertCurve(h, p1, p2, p3)
e = PathGeom.splitEdgeAt(h, p2)
o = 10*math.sin(math.pi/4)
p12 = Vector(10 - o, -o, 2.5)
p23 = Vector(10 - o, +o, 7.5)
pf = e[0].valueAt((e[0].FirstParameter + e[0].LastParameter)/2)
pl = e[1].valueAt((e[1].FirstParameter + e[1].LastParameter)/2)
self.assertCurve(e[0], p1, p12, p2)
self.assertCurve(e[1], p2, p23, p3)
示例2: __init__
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import splitEdgeAt [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
示例3: add
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import splitEdgeAt [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())
示例4: createRampMethod2
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import splitEdgeAt [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
示例5: createRampMethod3
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import splitEdgeAt [as 别名]
def createRampMethod3(self, rampedges, p0, projectionlen, rampangle):
"""
This method generates ramp with following pattern:
1. Start from the original startpoint of the plunge
2. Ramp down along the path that comes after the plunge until
traveled half of the Z distance
3. Change direction and ramp backwards to the origianal plunge end point
4. Continue with the original path
This method causes unecessarily many moves with tool down
"""
outedges = []
rampremaining = projectionlen
curPoint = p0 # start from the upper point of plunge
done = False
while not done:
for i, redge in enumerate(rampedges):
if redge.Length >= rampremaining:
# will reach end of ramp within this edge, needs to be split
p1 = self.getSplitPoint(redge, rampremaining)
splitEdge = PathGeom.splitEdgeAt(redge, p1)
PathLog.debug("Got split edge (index: {}) with lengths: {}, {}".format(i, splitEdge[0].Length, splitEdge[1].Length))
# ramp ends to the last point of first edge
p1 = splitEdge[0].valueAt(splitEdge[0].LastParameter)
deltaZ = splitEdge[0].Length / math.tan(math.radians(rampangle))
p1.z = curPoint.z - deltaZ
outedges.append(self.createRampEdge(splitEdge[0], curPoint, p1))
curPoint.z = p1.z - deltaZ
# now we have reached the end of the ramp. Reverse direction of ramp
# start that by going back to the beginning of this splitEdge
outedges.append(self.createRampEdge(splitEdge[0], p1, curPoint))
done = True
break
elif i == len(rampedges) - 1:
# last ramp element but still did not reach the full length?
# Probably a rounding issue on floats.
p1 = redge.valueAt(redge.LastParameter)
deltaZ = redge.Length / math.tan(math.radians(rampangle))
p1.z = curPoint.z - deltaZ
outedges.append(self.createRampEdge(redge, curPoint, p1))
# and go back that edge
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
done = True
else:
deltaZ = redge.Length / math.tan(math.radians(rampangle))
newPoint = FreeCAD.Base.Vector(redge.valueAt(redge.LastParameter).x, redge.valueAt(redge.LastParameter).y, curPoint.z - deltaZ)
outedges.append(self.createRampEdge(redge, curPoint, newPoint))
curPoint = newPoint
rampremaining = rampremaining - redge.Length
returnedges = self.getreversed(rampedges[:i])
# ramp backwards to the plunge position
for i, redge in enumerate(returnedges):
deltaZ = redge.Length / math.tan(math.radians(rampangle))
newPoint = FreeCAD.Base.Vector(redge.valueAt(redge.LastParameter).x, redge.valueAt(redge.LastParameter).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.LastParameter)
outedges.append(self.createRampEdge(redge, curPoint, newPoint))
curPoint = newPoint
return outedges
示例6: createRampMethod1
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import splitEdgeAt [as 别名]
def createRampMethod1(self, rampedges, p0, projectionlen, rampangle):
"""
This method generates ramp with following pattern:
1. Start from the original startpoint of the plunge
2. Ramp down along the path that comes after the plunge
3. When reaching the Z level of the original plunge, return back to the beginning
by going the path backwards until the original plunge end point is reached
4. Continue with the original path
This method causes unecessarily many moves with tool down
"""
outedges = []
rampremaining = projectionlen
curPoint = p0 # start from the upper point of plunge
done = False
goingForward = True
while not done:
for i, redge in enumerate(rampedges):
if redge.Length >= rampremaining:
# will reach end of ramp within this edge, needs to be split
p1 = self.getSplitPoint(redge, rampremaining)
splitEdge = PathGeom.splitEdgeAt(redge, p1)
PathLog.debug("Ramp remaining: {}".format(rampremaining))
PathLog.debug("Got split edge (index: {}) (total len: {}) with lengths: {}, {}".format(i, redge.Length, splitEdge[0].Length, splitEdge[1].Length))
# ramp ends to the last point of first edge
p1 = splitEdge[0].valueAt(splitEdge[0].LastParameter)
outedges.append(self.createRampEdge(splitEdge[0], curPoint, p1))
# now we have reached the end of the ramp. Go back to plunge position with constant Z
# start that by going to the beginning of this splitEdge
if goingForward:
outedges.append(self.createRampEdge(splitEdge[0], p1, redge.valueAt(redge.FirstParameter)))
else:
# if we were reversing, we continue to the same direction as the ramp
outedges.append(self.createRampEdge(splitEdge[0], p1, redge.valueAt(redge.LastParameter)))
done = True
break
else:
deltaZ = redge.Length / math.tan(math.radians(rampangle))
newPoint = FreeCAD.Base.Vector(redge.valueAt(redge.LastParameter).x, redge.valueAt(redge.LastParameter).y, curPoint.z - deltaZ)
outedges.append(self.createRampEdge(redge, curPoint, newPoint))
curPoint = newPoint
rampremaining = rampremaining - redge.Length
if not done:
# we did not reach the end of the ramp going this direction, lets reverse.
rampedges = self.getreversed(rampedges)
PathLog.debug("Reversing")
if goingForward:
goingForward = False
else:
goingForward = True
# now we need to return to original position.
if goingForward:
# if the ramp was going forward, the return edges are the edges we already covered in ramping,
# except the last one, which was already covered inside for loop. Direction needs to be reversed also
returnedges = self.getreversed(rampedges[:i])
else:
# if the ramp was already reversing, the edges needed for return are the ones
# which were not covered in ramp
returnedges = rampedges[(i + 1):]
# add the return edges:
outedges.extend(returnedges)
return outedges