本文整理汇总了Python中PathScripts.PathGeom.PathGeom.isRoughly方法的典型用法代码示例。如果您正苦于以下问题:Python PathGeom.isRoughly方法的具体用法?Python PathGeom.isRoughly怎么用?Python PathGeom.isRoughly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathScripts.PathGeom.PathGeom
的用法示例。
在下文中一共展示了PathGeom.isRoughly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: isRapid
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def isRapid(self, edge):
if type(edge.Curve) == Part.Line or type(edge.Curve) == Part.LineSegment:
v0 = edge.Vertexes[0]
v1 = edge.Vertexes[1]
for r in self.rapid:
r0 = r.Vertexes[0]
r1 = r.Vertexes[1]
if PathGeom.isRoughly(r0.X, v0.X) and PathGeom.isRoughly(r0.Y, v0.Y) and PathGeom.isRoughly(r0.Z, v0.Z) and PathGeom.isRoughly(r1.X, v1.X) and PathGeom.isRoughly(r1.Y, v1.Y) and PathGeom.isRoughly(r1.Z, v1.Z):
return True
return False
示例2: updateDepths
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def updateDepths(self, obj, ignoreErrors=False):
'''updateDepths(obj) ... base implementation calculating depths depending on base geometry.
Should not be overwritten.'''
def faceZmin(bb, fbb):
if fbb.ZMax == fbb.ZMin and fbb.ZMax == bb.ZMax: # top face
return fbb.ZMin
elif fbb.ZMax > fbb.ZMin and fbb.ZMax == bb.ZMax: # vertical face, full cut
return fbb.ZMin
elif fbb.ZMax > fbb.ZMin and fbb.ZMin > bb.ZMin: # internal vertical wall
return fbb.ZMin
elif fbb.ZMax == fbb.ZMin and fbb.ZMax > bb.ZMin: # face/shelf
return fbb.ZMin
return bb.ZMin
if not self._setBaseAndStock(obj, ignoreErrors):
return False
stockBB = self.stock.Shape.BoundBox
zmin = stockBB.ZMin
zmax = stockBB.ZMax
if hasattr(obj, 'Base') and obj.Base:
for base, sublist in obj.Base:
bb = base.Shape.BoundBox
zmax = max(zmax, bb.ZMax)
for sub in sublist:
fbb = base.Shape.getElement(sub).BoundBox
zmin = max(zmin, faceZmin(bb, fbb))
zmax = max(zmax, fbb.ZMax)
else:
# clearing with stock boundaries
job = PathUtils.findParentJob(obj)
zmax = stockBB.ZMax
zmin = job.Base.Shape.BoundBox.ZMax
if FeatureDepths & self.opFeatures(obj):
# first set update final depth, it's value is not negotiable
if not PathGeom.isRoughly(obj.OpFinalDepth.Value, zmin):
obj.OpFinalDepth = zmin
zmin = obj.OpFinalDepth.Value
def minZmax(z):
if hasattr(obj, 'StepDown') and not PathGeom.isRoughly(obj.StepDown.Value, 0):
return z + obj.StepDown.Value
else:
return z + 1
# ensure zmax is higher than zmin
if (zmax - 0.0001) <= zmin:
zmax = minZmax(zmin)
# update start depth if requested and required
if not PathGeom.isRoughly(obj.OpStartDepth.Value, zmax):
obj.OpStartDepth = zmax
示例3: isPointOnEdge
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def isPointOnEdge(self, pt, edge):
param = edge.Curve.parameter(pt)
if edge.FirstParameter <= param <= edge.LastParameter:
return True
if edge.LastParameter <= param <= edge.FirstParameter:
return True
if PathGeom.isRoughly(edge.FirstParameter, param) or PathGeom.isRoughly(edge.LastParameter, param):
return True
# print("-------- X %.2f <= %.2f <=%.2f (%.2f, %.2f, %.2f) %.2f:%.2f" % (edge.FirstParameter, param, edge.LastParameter, pt.x, pt.y, pt.z, edge.Curve.parameter(edge.valueAt(edge.FirstParameter)), edge.Curve.parameter(edge.valueAt(edge.LastParameter))))
# p1 = edge.Vertexes[0]
# f1 = edge.Curve.parameter(FreeCAD.Vector(p1.X, p1.Y, p1.Z))
# p2 = edge.Vertexes[1]
# f2 = edge.Curve.parameter(FreeCAD.Vector(p2.X, p2.Y, p2.Z))
return False
示例4: checkIgnoreAbove
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def checkIgnoreAbove(self, edge):
if self.ignoreAboveEnabled:
p0 = edge.Vertexes[0].Point
p1 = edge.Vertexes[1].Point
if p0.z > self.ignoreAbove and (p1.z > self.ignoreAbove or PathGeom.isRoughly(p1.z, self.ignoreAbove.Value)):
PathLog.debug("Whole plunge move above 'ignoreAbove', ignoring")
return (edge, True)
elif p0.z > self.ignoreAbove and not PathGeom.isRoughly(p0.z, self.ignoreAbove.Value):
PathLog.debug("Plunge move partially above 'ignoreAbove', splitting into two")
newPoint = FreeCAD.Base.Vector(p0.x, p0.y, self.ignoreAbove)
return (Part.makeLine(p0, newPoint), False)
else:
return None, False
else:
return None, False
示例5: onDocumentRestored
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def onDocumentRestored(self, obj):
features = self.opFeatures(obj)
if FeatureBaseGeometry & features and 'App::PropertyLinkSubList' == obj.getTypeIdOfProperty('Base'):
PathLog.info("Replacing link property with global link (%s)." % obj.State)
base = obj.Base
obj.removeProperty('Base')
self.addBaseProperty(obj)
obj.Base = base
obj.touch()
obj.Document.recompute()
if FeatureTool & features and not hasattr(obj, 'OpToolDiameter'):
self.addOpValues(obj, ['tooldia'])
if FeatureStepDown & features and not hasattr(obj, 'OpStartDepth'):
if PathGeom.isRoughly(obj.StepDown.Value, 1):
obj.setExpression('StepDown', 'OpToolDiameter')
if FeatureDepths & features and not hasattr(obj, 'OpStartDepth'):
self.addOpValues(obj, ['start', 'final'])
if not hasattr(obj, 'StartDepthLock') or not obj.StartDepthLock:
obj.setExpression('StartDepth', 'OpStartDepth')
if FeatureNoFinalDepth & features:
obj.setEditorMode('OpFinalDepth', 2)
elif not hasattr(obj, 'FinalDepthLock') or not obj.FinalDepthLock:
obj.setExpression('FinalDepth', 'OpFinalDepth')
示例6: commandsForEdges
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def commandsForEdges(self):
if self.edges:
try:
shape = self.shell().common(self.tag.solid)
commands = []
rapid = None
for e, flip in self.orderAndFlipEdges(self.cleanupEdges(shape.Edges)):
debugEdge(e, '++++++++ %s' % ('<' if flip else '>'), False)
p1 = e.valueAt(e.FirstParameter)
p2 = e.valueAt(e.LastParameter)
if self.tag.isSquare and (PathGeom.isRoughly(p1.z, self.maxZ) or p1.z > self.maxZ) and (PathGeom.isRoughly(p2.z, self.maxZ) or p2.z > self.maxZ):
rapid = p1 if flip else p2
else:
if rapid:
commands.append(Path.Command('G0', {'X': rapid.x, 'Y': rapid.y, 'Z': rapid.z}))
rapid = None
commands.extend(PathGeom.cmdsForEdge(e, flip, False, self.segm))
if rapid:
commands.append(Path.Command('G0', {'X': rapid.x, 'Y': rapid.y, 'Z': rapid.z}))
rapid = None
return commands
except Exception as e:
PathLog.error("Exception during processing tag @(%.2f, %.2f) (%s) - disabling the tag" % (self.tag.x, self.tag.y, e.args[0]))
self.tag.enabled = False
commands = []
for e in self.edges:
commands.extend(PathGeom.cmdsForEdge(e))
return commands
return []
示例7: pointIsOnPath
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def pointIsOnPath(self, p):
v = Part.Vertex(self.pointAtBottom(p))
PathLog.debug("pt = (%f, %f, %f)" % (v.X, v.Y, v.Z))
for e in self.bottomEdges:
indent = "{} ".format(e.distToShape(v)[0])
debugEdge(e, indent, True)
if PathGeom.isRoughly(0.0, v.distToShape(e)[0], 0.1):
return True
return False
示例8: filterIntersections
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def filterIntersections(self, pts, face):
if type(face.Surface) == Part.Cone or type(face.Surface) == Part.Cylinder or type(face.Surface) == Part.Toroid:
PathLog.track("it's a cone/cylinder, checking z")
return filter(lambda pt: pt.z >= self.bottom() and pt.z <= self.top(), pts)
if type(face.Surface) == Part.Plane:
PathLog.track("it's a plane, checking R")
c = face.Edges[0].Curve
if (type(c) == Part.Circle):
return filter(lambda pt: (pt - c.Center).Length <= c.Radius or PathGeom.isRoughly((pt - c.Center).Length, c.Radius), pts)
print("==== we got a %s" % face.Surface)
示例9: generateHelix
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [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
示例10: findBottomWire
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def findBottomWire(self, edges):
(minZ, maxZ) = self.findZLimits(edges)
self.minZ = minZ
self.maxZ = maxZ
bottom = [e for e in edges if PathGeom.isRoughly(e.Vertexes[0].Point.z, minZ) and PathGeom.isRoughly(e.Vertexes[1].Point.z, minZ)]
self.bottomEdges = bottom
try:
wire = Part.Wire(bottom)
if wire.isClosed():
return wire
except:
return None
示例11: horizontalFaceLoop
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def horizontalFaceLoop(obj, face, faceList=None):
'''horizontalFaceLoop(obj, face, faceList=None) ... returns a list of face names which form the walls of a vertical hole face is a part of.
All face names listed in faceList must be part of the hole for the solution to be returned.'''
wires = [horizontalEdgeLoop(obj, e) for e in face.Edges]
# Not sure if sorting by Area is a premature optimization - but it seems
# the loop we're looking for is typically the biggest of the them all.
wires = sorted([w for w in wires if w], key=lambda w: Part.Face(w).Area)
for wire in wires:
hashes = [e.hashCode() for e in wire.Edges]
#find all faces that share a an edge with the wire and are vertical
faces = ["Face%d"%(i+1) for i,f in enumerate(obj.Shape.Faces) if any(e.hashCode() in hashes for e in f.Edges) and PathGeom.isVertical(f)]
if faceList and not all(f in faces for f in faceList):
continue
# verify they form a valid hole by getting the outline and comparing
# the resulting XY footprint with that of the faces
comp = Part.makeCompound([obj.Shape.getElement(f) for f in faces])
outline = TechDraw.findShapeOutline(comp, 1, FreeCAD.Vector(0,0,1))
# findShapeOutline always returns closed wires, by removing the
# trace-backs single edge spikes don't contriubte to the bound box
uniqueEdges = []
for edge in outline.Edges:
if any(PathGeom.edgesMatch(edge, e) for e in uniqueEdges):
continue
uniqueEdges.append(edge)
w = Part.Wire(uniqueEdges)
# if the faces really form the walls of a hole then the resulting
# wire is still closed and it still has the same footprint
bb1 = comp.BoundBox
bb2 = w.BoundBox
if w.isClosed() and PathGeom.isRoughly(bb1.XMin, bb2.XMin) and PathGeom.isRoughly(bb1.XMax, bb2.XMax) and PathGeom.isRoughly(bb1.YMin, bb2.YMin) and PathGeom.isRoughly(bb1.YMax, bb2.YMax):
return faces
return None
示例12: sortedTags
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def sortedTags(self, tags):
ordered = []
for edge in self.bottomEdges:
ts = [t for t in tags if PathGeom.isRoughly(0, Part.Vertex(t.originAt(self.minZ)).distToShape(edge)[0], 0.1)]
for t in sorted(ts, key=lambda t: (t.originAt(self.minZ) - edge.valueAt(edge.FirstParameter)).Length):
tags.remove(t)
ordered.append(t)
# disable all tags that are not on the base wire.
for tag in tags:
PathLog.info("Tag #%d (%.2f, %.2f, %.2f) not on base wire - disabling\n" % (len(ordered), tag.x, tag.y, self.minZ))
tag.enabled = False
ordered.append(tag)
return ordered
示例13: updateInputField
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def updateInputField(obj, prop, widget, onBeforeChange=None):
'''updateInputField(obj, prop, widget) ... update obj's property prop with the value of widget.
The property's value is only assigned if the new value differs from the current value.
This prevents onChanged notifications where the value didn't acutally change.
Gui::InputField and Gui::QuantitySpinBox widgets are supported - and the property can
be of type Quantity or Float.
If onBeforeChange is specified it is called before a new value is assigned to the property.
Returns True if a new value was assigned, False otherwise (new value is the same as the current).
'''
value = FreeCAD.Units.Quantity(widget.text()).Value
attr = getProperty(obj, prop)
attrValue = attr.Value if hasattr(attr, 'Value') else attr
if not PathGeom.isRoughly(attrValue, value):
PathLog.debug("updateInputField(%s, %s): %.2f -> %.2f" % (obj.Label, prop, attr, value))
if onBeforeChange:
onBeforeChange(obj)
setProperty(obj, prop, value)
return True
return False
示例14: shell
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [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))
示例15: isAPlungeMove
# 需要导入模块: from PathScripts.PathGeom import PathGeom [as 别名]
# 或者: from PathScripts.PathGeom.PathGeom import isRoughly [as 别名]
def isAPlungeMove(self):
return not PathGeom.isRoughly(self.End.z, self.Start.z)