Started moving base classes into Path.Base module
This commit is contained in:
@@ -10,8 +10,6 @@ set(Path_Scripts
|
||||
Init.py
|
||||
PathCommands.py
|
||||
TestPathApp.py
|
||||
PathMachineState.py
|
||||
PathFeedRate.py
|
||||
)
|
||||
|
||||
if(BUILD_GUI)
|
||||
@@ -28,6 +26,16 @@ INSTALL(
|
||||
SET(PathPython_SRCS
|
||||
Path/__init__.py
|
||||
Path/Log.py
|
||||
Path/Geom.py
|
||||
)
|
||||
|
||||
SET(PathPythonBase_SRCS
|
||||
Path/Base/__init__.py
|
||||
Path/Base/MachineState.py
|
||||
Path/Base/FeedRate.py
|
||||
Path/Base/Property.py
|
||||
Path/Base/PropertyBag.py
|
||||
Path/Base/Util.py
|
||||
)
|
||||
|
||||
SET(PathPythonDressup_SRCS
|
||||
@@ -169,7 +177,6 @@ SET(PathScripts_SRCS
|
||||
PathScripts/PathFeatureExtensions.py
|
||||
PathScripts/PathFeatureExtensionsGui.py
|
||||
PathScripts/PathFixture.py
|
||||
PathScripts/PathGeom.py
|
||||
PathScripts/PathGetPoint.py
|
||||
PathScripts/PathGui.py
|
||||
PathScripts/PathGuiInit.py
|
||||
@@ -183,8 +190,6 @@ SET(PathScripts_SRCS
|
||||
PathScripts/PathPreferences.py
|
||||
PathScripts/PathPreferencesAdvanced.py
|
||||
PathScripts/PathPreferencesPathJob.py
|
||||
PathScripts/PathProperty.py
|
||||
PathScripts/PathPropertyBag.py
|
||||
PathScripts/PathPropertyBagGui.py
|
||||
PathScripts/PathPropertyEditor.py
|
||||
PathScripts/PathSanity.py
|
||||
@@ -197,7 +202,6 @@ SET(PathScripts_SRCS
|
||||
PathScripts/PathSimulatorGui.py
|
||||
PathScripts/PathStock.py
|
||||
PathScripts/PathStop.py
|
||||
PathScripts/PathUtil.py
|
||||
PathScripts/PathUtils.py
|
||||
PathScripts/PathUtilsGui.py
|
||||
PathScripts/__init__.py
|
||||
|
||||
@@ -24,7 +24,6 @@ from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import math
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
@@ -152,7 +151,7 @@ def generate(center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, st
|
||||
z = thread.zStart
|
||||
r = -radius
|
||||
i = 0
|
||||
while not PathGeom.isRoughly(z, thread.zFinal):
|
||||
while not Path.Geom.isRoughly(z, thread.zFinal):
|
||||
if thread.overshoots(z):
|
||||
break
|
||||
if 0 == (i & 0x01):
|
||||
@@ -164,7 +163,7 @@ def generate(center, cmd, zStart, zFinal, pitch, radius, leadInOut, elevator, st
|
||||
i = i + 1
|
||||
z = z + thread.hPitch
|
||||
|
||||
if PathGeom.isRoughly(z, thread.zFinal):
|
||||
if Path.Geom.isRoughly(z, thread.zFinal):
|
||||
x = center.x
|
||||
y = yMin if (i & 0x01) else yMax
|
||||
else:
|
||||
|
||||
@@ -22,10 +22,8 @@
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathMachineState
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Path.Base.MachineState as PathMachineState
|
||||
import Part
|
||||
from PathScripts.PathGeom import CmdMoveRapid, CmdMoveAll
|
||||
|
||||
__title__ = "Feed Rate Helper Utility"
|
||||
__author__ = "sliptonic (Brad Collette)"
|
||||
@@ -69,24 +67,24 @@ def setFeedRate(commandlist, ToolController):
|
||||
endpoint = FreeCAD.Vector(x, y, z)
|
||||
if PathGeom.pointsCoincide(currentposition, endpoint):
|
||||
return True
|
||||
return PathGeom.isVertical(Part.makeLine(currentposition, endpoint))
|
||||
return Path.Geom.isVertical(Part.makeLine(currentposition, endpoint))
|
||||
|
||||
machine = PathMachineState.MachineState()
|
||||
|
||||
for command in commandlist:
|
||||
if command.Name not in CmdMoveAll:
|
||||
if command.Name not in Path.Geom.CmdMoveAll:
|
||||
continue
|
||||
|
||||
if _isVertical(machine.getPosition(), command):
|
||||
rate = (
|
||||
ToolController.VertRapid.Value
|
||||
if command.Name in CmdMoveRapid
|
||||
if command.Name in Path.Geom.CmdMoveRapid
|
||||
else ToolController.VertFeed.Value
|
||||
)
|
||||
else:
|
||||
rate = (
|
||||
ToolController.HorizRapid.Value
|
||||
if command.Name in CmdMoveRapid
|
||||
if command.Name in Path.Geom.CmdMoveRapid
|
||||
else ToolController.HorizFeed.Value
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ __contributors__ = ""
|
||||
|
||||
import Path
|
||||
import FreeCAD
|
||||
from PathScripts.PathGeom import CmdMoveRapid, CmdMoveAll, CmdMoveDrill
|
||||
import Path
|
||||
|
||||
if False:
|
||||
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
|
||||
@@ -92,7 +92,7 @@ class MachineState:
|
||||
self.WCS = command.Name
|
||||
return not oldstate == self.getState()
|
||||
|
||||
if command.Name in CmdMoveDrill:
|
||||
if command.Name in Path.Geom.CmdMoveDrill:
|
||||
oldZ = self.Z
|
||||
for p in command.Parameters:
|
||||
self.__setattr__(p, command.Parameters[p])
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
"""
|
||||
The purpose of this file is to collect some handy functions. The reason they
|
||||
are not in PathUtils (and there is this confusing naming going on) is that
|
||||
are not in Path.Base.Utils (and there is this confusing naming going on) is that
|
||||
PathUtils depends on PathJob. Which makes it impossible to use the functions
|
||||
and classes defined there in PathJob.
|
||||
|
||||
@@ -23,11 +23,9 @@
|
||||
import FreeCAD
|
||||
import Path
|
||||
import math
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import PathScripts.PathGui as PathGui
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from PathScripts.PathGeom import CmdMoveArc
|
||||
|
||||
if False:
|
||||
Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule())
|
||||
@@ -88,11 +86,11 @@ class ObjectDressup:
|
||||
currLocation = {"X": 0, "Y": 0, "Z": 0, "F": 0}
|
||||
|
||||
for p in path:
|
||||
if p.Name in CmdMoveArc:
|
||||
if p.Name in Path.Geom.CmdMoveArc:
|
||||
curVec = FreeCAD.Vector(
|
||||
currLocation["X"], currLocation["Y"], currLocation["Z"]
|
||||
)
|
||||
arcwire = PathGeom.edgeForCmd(p, curVec)
|
||||
arcwire = Path.Geom.edgeForCmd(p, curVec)
|
||||
pointlist = arcwire.discretize(Deflection=d)
|
||||
for point in pointlist:
|
||||
newcommand = Path.Command(
|
||||
@@ -117,7 +115,7 @@ class ObjectDressup:
|
||||
if obj.Base.Path:
|
||||
if obj.Base.Path.Commands:
|
||||
pp = obj.Base.Path.Commands
|
||||
if len([i for i in pp if i.Name in CmdMoveArc]) == 0:
|
||||
if len([i for i in pp if i.Name in Path.Geom.CmdMoveArc]) == 0:
|
||||
pathlist = pp
|
||||
else:
|
||||
pathlist = self._stripArcs(pp, d)
|
||||
|
||||
@@ -26,12 +26,10 @@ from PySide import QtCore
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Dressup.Utils as PathDressup
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import math
|
||||
from PathScripts.PathGeom import CmdMoveCW, CmdMoveStraight, CmdMoveArc, CmdMoveRapid
|
||||
|
||||
# lazily loaded modules
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
@@ -50,7 +48,7 @@ else:
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
|
||||
movecommands = CmdMoveStraight + CmdMoveRapid + CmdMoveArc
|
||||
movecommands = Path.Geom.CmdMoveStraight + Path.Geom.CmdMoveRapid + Path.Geom.CmdMoveArc
|
||||
|
||||
|
||||
def debugMarker(vector, label, color=None, radius=0.5):
|
||||
@@ -118,9 +116,9 @@ def edgesForCommands(cmds, startPt):
|
||||
for cmd in cmds:
|
||||
if cmd.Name in movecommands:
|
||||
pt = pointFromCommand(cmd, lastPt)
|
||||
if cmd.Name in CmdMoveStraight:
|
||||
if cmd.Name in Path.Geom.CmdMoveStraight:
|
||||
edges.append(Part.Edge(Part.LineSegment(lastPt, pt)))
|
||||
elif cmd.Name in CmdMoveArc:
|
||||
elif cmd.Name in Path.Geom.CmdMoveArc:
|
||||
center = lastPt + pointFromCommand(
|
||||
cmd, FreeCAD.Vector(0, 0, 0), "I", "J", "K"
|
||||
)
|
||||
@@ -131,7 +129,7 @@ def edgesForCommands(cmds, startPt):
|
||||
if d == 0:
|
||||
# we're dealing with half a circle here
|
||||
angle = getAngle(A) + math.pi / 2
|
||||
if cmd.Name in CmdMoveCW:
|
||||
if cmd.Name in Path.Geom.CmdMoveCW:
|
||||
angle -= math.pi
|
||||
else:
|
||||
C = A + B
|
||||
@@ -250,7 +248,7 @@ class Chord(object):
|
||||
A = self.asDirection()
|
||||
# if the 2 vectors are identical, they head in the same direction
|
||||
Path.Log.debug(" {}.getDirectionOfVector({})".format(A, B))
|
||||
if PathGeom.pointsCoincide(A, B):
|
||||
if Path.Geom.pointsCoincide(A, B):
|
||||
return "Straight"
|
||||
d = -A.x * B.y + A.y * B.x
|
||||
if d < 0:
|
||||
@@ -306,15 +304,15 @@ class Chord(object):
|
||||
return self.arcCommand("G3", center, f)
|
||||
|
||||
def isAPlungeMove(self):
|
||||
return not PathGeom.isRoughly(self.End.z, self.Start.z)
|
||||
return not Path.Geom.isRoughly(self.End.z, self.Start.z)
|
||||
|
||||
def isANoopMove(self):
|
||||
Path.Log.debug(
|
||||
"{}.isANoopMove(): {}".format(
|
||||
self, PathGeom.pointsCoincide(self.Start, self.End)
|
||||
self, Path.Geom.pointsCoincide(self.Start, self.End)
|
||||
)
|
||||
)
|
||||
return PathGeom.pointsCoincide(self.Start, self.End)
|
||||
return Path.Geom.pointsCoincide(self.Start, self.End)
|
||||
|
||||
def foldsBackOrTurns(self, chord, side):
|
||||
direction = chord.getDirectionOf(self)
|
||||
@@ -322,7 +320,7 @@ class Chord(object):
|
||||
return direction == "Back" or direction == side
|
||||
|
||||
def connectsTo(self, chord):
|
||||
return PathGeom.pointsCoincide(self.End, chord.Start)
|
||||
return Path.Geom.pointsCoincide(self.End, chord.Start)
|
||||
|
||||
|
||||
class Bone(object):
|
||||
@@ -397,7 +395,7 @@ class Bone(object):
|
||||
return 0
|
||||
gamma = math.asin(D)
|
||||
alpha = math.pi - beta - gamma
|
||||
if PathGeom.isRoughly(0.0, math.sin(beta)):
|
||||
if Path.Geom.isRoughly(0.0, math.sin(beta)):
|
||||
# it is not a good idea to divide by 0
|
||||
length = 0.0
|
||||
else:
|
||||
@@ -495,7 +493,7 @@ class ObjectDressup(object):
|
||||
# Answer true if a dogbone could be on either end of the chord, given its command
|
||||
def canAttachDogbone(self, cmd, chord):
|
||||
return (
|
||||
cmd.Name in CmdMoveStraight
|
||||
cmd.Name in Path.Geom.CmdMoveStraight
|
||||
and not chord.isAPlungeMove()
|
||||
and not chord.isANoopMove()
|
||||
)
|
||||
@@ -590,7 +588,7 @@ class ObjectDressup(object):
|
||||
% (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(
|
||||
if not Path.Geom.pointsCoincide(pt, corner) and self.pointIsOnEdge(
|
||||
pt, e
|
||||
):
|
||||
# debugMarker(pt, "candidate-%d-%s" % (self.boneId, d), color, 0.05)
|
||||
@@ -616,7 +614,7 @@ class ObjectDressup(object):
|
||||
)
|
||||
|
||||
commands = []
|
||||
if not PathGeom.pointsCoincide(t1, inChord.Start):
|
||||
if not Path.Geom.pointsCoincide(t1, inChord.Start):
|
||||
Path.Log.debug(" add lead in")
|
||||
commands.append(Chord(inChord.Start, t1).g1Command(bone.F))
|
||||
if bone.obj.Side == Side.Left:
|
||||
@@ -628,7 +626,7 @@ class ObjectDressup(object):
|
||||
% (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):
|
||||
if not Path.Geom.pointsCoincide(t2, outChord.End):
|
||||
Path.Log.debug(" add lead out")
|
||||
commands.append(Chord(t2, outChord.End).g1Command(bone.F))
|
||||
|
||||
@@ -745,7 +743,7 @@ class ObjectDressup(object):
|
||||
def tboneVertical(self, bone):
|
||||
angle = bone.angle()
|
||||
boneAngle = math.pi / 2
|
||||
if PathGeom.isRoughly(angle, math.pi) or angle < 0:
|
||||
if Path.Geom.isRoughly(angle, math.pi) or angle < 0:
|
||||
boneAngle = -boneAngle
|
||||
return self.inOutBoneCommands(bone, boneAngle, self.toolRadius)
|
||||
|
||||
@@ -853,9 +851,9 @@ class ObjectDressup(object):
|
||||
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(
|
||||
if Path.Geom.pointsCoincide(
|
||||
pt, e1.valueAt(e1.LastParameter)
|
||||
) or PathGeom.pointsCoincide(pt, e2.valueAt(e2.FirstParameter)):
|
||||
) or Path.Geom.pointsCoincide(pt, e2.valueAt(e2.FirstParameter)):
|
||||
continue
|
||||
# debugMarker(pt, "it", (0.0, 1.0, 1.0))
|
||||
# 1. remove all redundant commands
|
||||
@@ -868,7 +866,7 @@ class ObjectDressup(object):
|
||||
commands.append(c1)
|
||||
# 3. change where c2 starts, this depends on the command itself
|
||||
c2 = bone2.inCommands[j]
|
||||
if c2.Name in CmdMoveArc:
|
||||
if c2.Name in Path.Geom.CmdMoveArc:
|
||||
center = e2.Curve.Center
|
||||
offset = center - pt
|
||||
c2Params = c2.Parameters
|
||||
@@ -1073,7 +1071,7 @@ class ObjectDressup(object):
|
||||
|
||||
class Marker(object):
|
||||
def __init__(self, pt, r, h):
|
||||
if PathGeom.isRoughly(h, 0):
|
||||
if Path.Geom.isRoughly(h, 0):
|
||||
h = 0.1
|
||||
self.pt = pt
|
||||
self.r = r
|
||||
|
||||
@@ -27,7 +27,6 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Dressup.Utils as PathDressup
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import math
|
||||
import copy
|
||||
@@ -190,7 +189,7 @@ class ObjectDressup:
|
||||
+ "\n"
|
||||
)
|
||||
obj.Length = 0.1
|
||||
self.wire, self.rapids = PathGeom.wireForPath(obj.Base.Path)
|
||||
self.wire, self.rapids = Path.Geom.wireForPath(obj.Base.Path)
|
||||
obj.Path = self.generateLeadInOutCurve(obj)
|
||||
|
||||
def getDirectionOfPath(self, obj):
|
||||
|
||||
@@ -25,7 +25,6 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Dressup.Utils as PathDressup
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import math
|
||||
|
||||
|
||||
@@ -223,7 +222,7 @@ class ObjectDressup:
|
||||
|
||||
self.angle = obj.Angle
|
||||
self.method = obj.Method
|
||||
self.wire, self.rapids = PathGeom.wireForPath(obj.Base.Path)
|
||||
self.wire, self.rapids = Path.Geom.wireForPath(obj.Base.Path)
|
||||
if self.method in ["RampMethod1", "RampMethod2", "RampMethod3"]:
|
||||
self.outedges = self.generateRamps()
|
||||
else:
|
||||
@@ -236,7 +235,7 @@ class ObjectDressup:
|
||||
for edge in edges:
|
||||
israpid = False
|
||||
for redge in self.rapids:
|
||||
if PathGeom.edgesMatch(edge, redge):
|
||||
if Path.Geom.edgesMatch(edge, redge):
|
||||
israpid = True
|
||||
if not israpid:
|
||||
bb = edge.BoundBox
|
||||
@@ -361,7 +360,7 @@ class ObjectDressup:
|
||||
edge = edges[i]
|
||||
israpid = False
|
||||
for redge in self.rapids:
|
||||
if PathGeom.edgesMatch(edge, redge):
|
||||
if Path.Geom.edgesMatch(edge, redge):
|
||||
israpid = True
|
||||
if not israpid:
|
||||
bb = edge.BoundBox
|
||||
@@ -395,7 +394,7 @@ class ObjectDressup:
|
||||
candidate = edges[j]
|
||||
cp0 = candidate.Vertexes[0].Point
|
||||
cp1 = candidate.Vertexes[1].Point
|
||||
if PathGeom.pointsCoincide(p1, cp1):
|
||||
if Path.Geom.pointsCoincide(p1, cp1):
|
||||
# found closed loop
|
||||
loopFound = True
|
||||
rampedges.append(candidate)
|
||||
@@ -413,7 +412,7 @@ class ObjectDressup:
|
||||
outedges.append(edge)
|
||||
else:
|
||||
outedges.extend(self.createHelix(rampedges, p0, p1))
|
||||
if not PathGeom.isRoughly(p1.z, minZ):
|
||||
if not Path.Geom.isRoughly(p1.z, minZ):
|
||||
# the edges covered by the helix not handled again,
|
||||
# unless reached the bottom height
|
||||
i = j
|
||||
@@ -431,11 +430,11 @@ class ObjectDressup:
|
||||
p1 = edge.Vertexes[1].Point
|
||||
if p0.z > self.ignoreAbove and (
|
||||
p1.z > self.ignoreAbove
|
||||
or PathGeom.isRoughly(p1.z, self.ignoreAbove.Value)
|
||||
or Path.Geom.isRoughly(p1.z, self.ignoreAbove.Value)
|
||||
):
|
||||
Path.Log.debug("Whole plunge move above 'ignoreAbove', ignoring")
|
||||
return (edge, True)
|
||||
elif p0.z > self.ignoreAbove and not PathGeom.isRoughly(
|
||||
elif p0.z > self.ignoreAbove and not Path.Geom.isRoughly(
|
||||
p0.z, self.ignoreAbove.Value
|
||||
):
|
||||
Path.Log.debug(
|
||||
@@ -543,7 +542,7 @@ class ObjectDressup:
|
||||
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)
|
||||
splitEdge = Path.Geom.splitEdgeAt(redge, p1)
|
||||
Path.Log.debug("Ramp remaining: {}".format(rampremaining))
|
||||
Path.Log.debug(
|
||||
"Got split edge (index: {}) (total len: {}) with lengths: {}, {}".format(
|
||||
@@ -626,7 +625,7 @@ class ObjectDressup:
|
||||
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)
|
||||
splitEdge = Path.Geom.splitEdgeAt(redge, p1)
|
||||
Path.Log.debug(
|
||||
"Got split edge (index: {}) with lengths: {}, {}".format(
|
||||
i, splitEdge[0].Length, splitEdge[1].Length
|
||||
@@ -702,9 +701,9 @@ class ObjectDressup:
|
||||
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)),
|
||||
if Path.Geom.pointsCoincide(
|
||||
Path.Geom.xy(p0),
|
||||
Path.Geom.xy(rampedges[-1].valueAt(rampedges[-1].LastParameter)),
|
||||
):
|
||||
Path.Log.debug(
|
||||
"The ramp forms a closed wire, needless to move on original Z height"
|
||||
@@ -714,7 +713,7 @@ class ObjectDressup:
|
||||
if redge.Length >= rampremaining:
|
||||
# this edge needs to be split
|
||||
p1 = self.getSplitPoint(redge, rampremaining)
|
||||
splitEdge = PathGeom.splitEdgeAt(redge, p1)
|
||||
splitEdge = Path.Geom.splitEdgeAt(redge, p1)
|
||||
Path.Log.debug(
|
||||
"Got split edges with lengths: {}, {}".format(
|
||||
splitEdge[0].Length, splitEdge[1].Length
|
||||
@@ -785,13 +784,13 @@ class ObjectDressup:
|
||||
for edge in edges:
|
||||
israpid = False
|
||||
for redge in self.rapids:
|
||||
if PathGeom.edgesMatch(edge, redge):
|
||||
if Path.Geom.edgesMatch(edge, redge):
|
||||
israpid = True
|
||||
if israpid:
|
||||
v = edge.valueAt(edge.LastParameter)
|
||||
commands.append(Path.Command("G0", {"X": v.x, "Y": v.y, "Z": v.z}))
|
||||
else:
|
||||
commands.extend(PathGeom.cmdsForEdge(edge))
|
||||
commands.extend(Path.Geom.cmdsForEdge(edge))
|
||||
|
||||
lastCmd = Path.Command("G0", {"X": 0.0, "Y": 0.0, "Z": 0.0})
|
||||
|
||||
@@ -830,7 +829,7 @@ class ObjectDressup:
|
||||
|
||||
if cmd.Name in ["G1", "G2", "G3", "G01", "G02", "G03"]:
|
||||
if zVal is not None and zVal2 != zVal:
|
||||
if PathGeom.isRoughly(xVal, xVal2) and PathGeom.isRoughly(
|
||||
if Path.Geom.isRoughly(xVal, xVal2) and Path.Geom.isRoughly(
|
||||
yVal, yVal2
|
||||
):
|
||||
# this is a straight plunge
|
||||
|
||||
@@ -28,7 +28,6 @@ import FreeCADGui
|
||||
import Path
|
||||
import Path.Dressup.Tags as PathDressupTag
|
||||
import PathGui as PGui # ensure Path/Gui/Resources are loaded
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGetPoint as PathGetPoint
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
@@ -527,7 +526,7 @@ class PathDressupTagViewProvider:
|
||||
z = self.tags[0].point.z
|
||||
p = FreeCAD.Vector(x, y, z)
|
||||
for i, tag in enumerate(self.tags):
|
||||
if PathGeom.pointsCoincide(
|
||||
if Path.Geom.pointsCoincide(
|
||||
p, tag.point, tag.sphere.radius.getValue() * 1.3
|
||||
):
|
||||
return i
|
||||
|
||||
@@ -26,12 +26,10 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
|
||||
from PySide import QtGui
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from PathScripts.PathGeom import CmdMoveArc, CmdMoveStraight
|
||||
|
||||
# lazily loaded modules
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
@@ -176,16 +174,16 @@ class ObjectDressup:
|
||||
Path.Log.debug(" curLoc:{}".format(currLocation))
|
||||
newparams = dict(c.Parameters)
|
||||
zval = newparams.get("Z", currLocation["Z"])
|
||||
if c.Name in CmdMoveStraight + CmdMoveArc:
|
||||
if c.Name in Path.Geom.CmdMoveStraight + Path.Geom.CmdMoveArc:
|
||||
curVec = FreeCAD.Vector(
|
||||
currLocation["X"],
|
||||
currLocation["Y"],
|
||||
currLocation["Z"],
|
||||
)
|
||||
arcwire = PathGeom.edgeForCmd(c, curVec)
|
||||
arcwire = Path.Geom.edgeForCmd(c, curVec)
|
||||
if arcwire is None:
|
||||
continue
|
||||
if c.Name in CmdMoveArc:
|
||||
if c.Name in Path.Geom.CmdMoveArc:
|
||||
pointlist = arcwire.discretize(Deflection=curveD)
|
||||
else:
|
||||
disc_number = int(arcwire.Length / sampleD)
|
||||
|
||||
@@ -23,10 +23,9 @@
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Dressup.Utils as PathDressup
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
|
||||
if False:
|
||||
@@ -127,7 +126,7 @@ class PathBoundary:
|
||||
|
||||
def boundaryCommands(self, begin, end, verticalFeed):
|
||||
Path.Log.track(_vstr(begin), _vstr(end))
|
||||
if end and PathGeom.pointsCoincide(begin, end):
|
||||
if end and Path.Geom.pointsCoincide(begin, end):
|
||||
return []
|
||||
cmds = []
|
||||
if begin.z < self.safeHeight:
|
||||
@@ -172,12 +171,12 @@ class PathBoundary:
|
||||
commands = [cmd]
|
||||
lastExit = None
|
||||
for cmd in self.baseOp.Path.Commands[1:]:
|
||||
if cmd.Name in PathGeom.CmdMoveAll:
|
||||
if cmd.Name in Path.Geom.CmdMoveAll:
|
||||
if bogusX:
|
||||
bogusX = "X" not in cmd.Parameters
|
||||
if bogusY:
|
||||
bogusY = "Y" not in cmd.Parameters
|
||||
edge = PathGeom.edgeForCmd(cmd, pos)
|
||||
edge = Path.Geom.edgeForCmd(cmd, pos)
|
||||
if edge:
|
||||
inside = edge.common(self.boundary).Edges
|
||||
outside = edge.cut(self.boundary).Edges
|
||||
@@ -201,25 +200,25 @@ class PathBoundary:
|
||||
)
|
||||
lastExit = None
|
||||
commands.append(cmd)
|
||||
pos = PathGeom.commandEndPoint(cmd, pos)
|
||||
pos = Path.Geom.commandEndPoint(cmd, pos)
|
||||
elif 0 == len(inside) and 1 == len(outside):
|
||||
Path.Log.track(_vstr(pos), _vstr(lastExit), " - ", cmd)
|
||||
# cmd fully excluded by boundary
|
||||
if not lastExit:
|
||||
lastExit = pos
|
||||
pos = PathGeom.commandEndPoint(cmd, pos)
|
||||
pos = Path.Geom.commandEndPoint(cmd, pos)
|
||||
else:
|
||||
Path.Log.track(
|
||||
_vstr(pos), _vstr(lastExit), len(inside), len(outside), cmd
|
||||
)
|
||||
# cmd pierces boundary
|
||||
while inside or outside:
|
||||
ie = [e for e in inside if PathGeom.edgeConnectsTo(e, pos)]
|
||||
ie = [e for e in inside if Path.Geom.edgeConnectsTo(e, pos)]
|
||||
Path.Log.track(ie)
|
||||
if ie:
|
||||
e = ie[0]
|
||||
LastPt = e.valueAt(e.LastParameter)
|
||||
flip = PathGeom.pointsCoincide(pos, LastPt)
|
||||
flip = Path.Geom.pointsCoincide(pos, LastPt)
|
||||
newPos = e.valueAt(e.FirstParameter) if flip else LastPt
|
||||
# inside edges are taken at this point (see swap of inside/outside
|
||||
# above - so we can just connect the dots ...
|
||||
@@ -236,7 +235,7 @@ class PathBoundary:
|
||||
bogusX or bogusY
|
||||
): # don't insert false paths based on bogus m/c position
|
||||
commands.extend(
|
||||
PathGeom.cmdsForEdge(
|
||||
Path.Geom.cmdsForEdge(
|
||||
e,
|
||||
flip,
|
||||
False,
|
||||
@@ -252,13 +251,13 @@ class PathBoundary:
|
||||
oe = [
|
||||
e
|
||||
for e in outside
|
||||
if PathGeom.edgeConnectsTo(e, pos)
|
||||
if Path.Geom.edgeConnectsTo(e, pos)
|
||||
]
|
||||
Path.Log.track(oe)
|
||||
if oe:
|
||||
e = oe[0]
|
||||
ptL = e.valueAt(e.LastParameter)
|
||||
flip = PathGeom.pointsCoincide(pos, ptL)
|
||||
flip = Path.Geom.pointsCoincide(pos, ptL)
|
||||
newPos = (
|
||||
e.valueAt(e.FirstParameter) if flip else ptL
|
||||
)
|
||||
@@ -280,7 +279,7 @@ class PathBoundary:
|
||||
# Eif
|
||||
# Ewhile
|
||||
# Eif
|
||||
# pos = PathGeom.commandEndPoint(cmd, pos)
|
||||
# pos = Path.Geom.commandEndPoint(cmd, pos)
|
||||
# Eif
|
||||
else:
|
||||
Path.Log.track("no-move", cmd)
|
||||
|
||||
@@ -25,9 +25,8 @@ from PathScripts.PathUtils import waiting_effects
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Dressup.Utils as PathDressup
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import copy
|
||||
import math
|
||||
@@ -164,7 +163,7 @@ class Tag:
|
||||
self.r2 = r1
|
||||
height = self.height * 1.01
|
||||
radius = 0
|
||||
if PathGeom.isRoughly(90, self.angle) and height > 0:
|
||||
if Path.Geom.isRoughly(90, self.angle) and height > 0:
|
||||
# cylinder
|
||||
self.isSquare = True
|
||||
self.solid = Part.makeCylinder(r1, height)
|
||||
@@ -192,10 +191,10 @@ class Tag:
|
||||
# degenerated case - no tag
|
||||
Path.Log.debug("Part.makeSphere(%f / 10000)" % (r1))
|
||||
self.solid = Part.makeSphere(r1 / 10000)
|
||||
if not PathGeom.isRoughly(
|
||||
if not Path.Geom.isRoughly(
|
||||
0, R
|
||||
): # testing is easier if the solid is not rotated
|
||||
angle = -PathGeom.getAngle(self.originAt(0)) * 180 / math.pi
|
||||
angle = -Path.Geom.getAngle(self.originAt(0)) * 180 / math.pi
|
||||
Path.Log.debug("solid.rotate(%f)" % angle)
|
||||
self.solid.rotate(FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(0, 0, 1), angle)
|
||||
orig = self.originAt(z - 0.01 * self.actualHeight)
|
||||
@@ -203,7 +202,7 @@ class Tag:
|
||||
self.solid.translate(orig)
|
||||
radius = min(self.radius, radius)
|
||||
self.realRadius = radius
|
||||
if not PathGeom.isRoughly(0, radius):
|
||||
if not Path.Geom.isRoughly(0, radius):
|
||||
Path.Log.debug("makeFillet(%.4f)" % radius)
|
||||
self.solid = self.solid.makeFillet(radius, [self.solid.Edges[0]])
|
||||
|
||||
@@ -226,7 +225,7 @@ class Tag:
|
||||
pt
|
||||
for pt in pts
|
||||
if (pt - c.Center).Length <= c.Radius
|
||||
or PathGeom.isRoughly((pt - c.Center).Length, c.Radius)
|
||||
or Path.Geom.isRoughly((pt - c.Center).Length, c.Radius)
|
||||
]
|
||||
)
|
||||
Path.Log.error("==== we got a %s" % face.Surface)
|
||||
@@ -237,7 +236,7 @@ class Tag:
|
||||
return True
|
||||
if edge.LastParameter <= param <= edge.FirstParameter:
|
||||
return True
|
||||
if PathGeom.isRoughly(edge.FirstParameter, param) or PathGeom.isRoughly(
|
||||
if Path.Geom.isRoughly(edge.FirstParameter, param) or Path.Geom.isRoughly(
|
||||
edge.LastParameter, param
|
||||
):
|
||||
return True
|
||||
@@ -265,7 +264,7 @@ class Tag:
|
||||
def intersects(self, edge, param):
|
||||
def isDefinitelySmaller(z, zRef):
|
||||
# Eliminate false positives of edges that just brush along the top of the tag
|
||||
return z < zRef and not PathGeom.isRoughly(z, zRef, 0.01)
|
||||
return z < zRef and not Path.Geom.isRoughly(z, zRef, 0.01)
|
||||
|
||||
if self.enabled:
|
||||
zFirst = edge.valueAt(edge.FirstParameter).z
|
||||
@@ -297,20 +296,20 @@ class MapWireToTag:
|
||||
self.maxZ = maxZ
|
||||
self.hSpeed = hSpeed
|
||||
self.vSpeed = vSpeed
|
||||
if PathGeom.pointsCoincide(edge.valueAt(edge.FirstParameter), i):
|
||||
if Path.Geom.pointsCoincide(edge.valueAt(edge.FirstParameter), i):
|
||||
tail = edge
|
||||
self.commands = []
|
||||
debugEdge(tail, ".........=")
|
||||
elif PathGeom.pointsCoincide(edge.valueAt(edge.LastParameter), i):
|
||||
elif Path.Geom.pointsCoincide(edge.valueAt(edge.LastParameter), i):
|
||||
debugEdge(edge, "++++++++ .")
|
||||
self.commands = PathGeom.cmdsForEdge(
|
||||
self.commands = Path.Geom.cmdsForEdge(
|
||||
edge, segm=segm, hSpeed=self.hSpeed, vSpeed=self.vSpeed
|
||||
)
|
||||
tail = None
|
||||
else:
|
||||
e, tail = PathGeom.splitEdgeAt(edge, i)
|
||||
e, tail = Path.Geom.splitEdgeAt(edge, i)
|
||||
debugEdge(e, "++++++++ .")
|
||||
self.commands = PathGeom.cmdsForEdge(
|
||||
self.commands = Path.Geom.cmdsForEdge(
|
||||
e, segm=segm, hSpeed=self.hSpeed, vSpeed=self.vSpeed
|
||||
)
|
||||
debugEdge(tail, ".........-")
|
||||
@@ -344,20 +343,20 @@ class MapWireToTag:
|
||||
self.edges.append(edge)
|
||||
|
||||
def needToFlipEdge(self, edge, p):
|
||||
if PathGeom.pointsCoincide(edge.valueAt(edge.LastParameter), p):
|
||||
if Path.Geom.pointsCoincide(edge.valueAt(edge.LastParameter), p):
|
||||
return True, edge.valueAt(edge.FirstParameter)
|
||||
return False, edge.valueAt(edge.LastParameter)
|
||||
|
||||
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:
|
||||
if Path.Geom.pointsCoincide(p1, self.entry) and p2.z >= self.entry.z:
|
||||
return 1
|
||||
if PathGeom.pointsCoincide(p2, self.entry) and p1.z >= self.entry.z:
|
||||
if Path.Geom.pointsCoincide(p2, self.entry) and p1.z >= self.entry.z:
|
||||
return 1
|
||||
if PathGeom.pointsCoincide(p1, self.exit) and p2.z >= self.exit.z:
|
||||
if Path.Geom.pointsCoincide(p1, self.exit) and p2.z >= self.exit.z:
|
||||
return 2
|
||||
if PathGeom.pointsCoincide(p2, self.exit) and p1.z >= self.exit.z:
|
||||
if Path.Geom.pointsCoincide(p2, self.exit) and p1.z >= self.exit.z:
|
||||
return 2
|
||||
return 0
|
||||
|
||||
@@ -383,16 +382,16 @@ class MapWireToTag:
|
||||
self.edgePoints.append(p1)
|
||||
self.edgePoints.append(p2)
|
||||
if self.tag.solid.isInside(
|
||||
p1, PathGeom.Tolerance, False
|
||||
) or self.tag.solid.isInside(p2, PathGeom.Tolerance, False):
|
||||
p1, Path.Geom.Tolerance, False
|
||||
) or self.tag.solid.isInside(p2, Path.Geom.Tolerance, False):
|
||||
edges.remove(e)
|
||||
debugEdge(e, "......... X0", False)
|
||||
else:
|
||||
if PathGeom.pointsCoincide(p1, self.entry) or PathGeom.pointsCoincide(
|
||||
if Path.Geom.pointsCoincide(p1, self.entry) or Path.Geom.pointsCoincide(
|
||||
p2, self.entry
|
||||
):
|
||||
self.entryEdges.append(e)
|
||||
if PathGeom.pointsCoincide(p1, self.exit) or PathGeom.pointsCoincide(
|
||||
if Path.Geom.pointsCoincide(p1, self.exit) or Path.Geom.pointsCoincide(
|
||||
p2, self.exit
|
||||
):
|
||||
self.exitEdges.append(e)
|
||||
@@ -406,7 +405,7 @@ class MapWireToTag:
|
||||
self.edgePoints, key=lambda p: (p - self.entry).Length
|
||||
)[0]
|
||||
self.entryEdges = list(
|
||||
[e for e in edges if PathGeom.edgeConnectsTo(e, self.realEntry)]
|
||||
[e for e in edges if Path.Geom.edgeConnectsTo(e, self.realEntry)]
|
||||
)
|
||||
edges.append(Part.Edge(Part.LineSegment(self.entry, self.realEntry)))
|
||||
else:
|
||||
@@ -417,7 +416,7 @@ class MapWireToTag:
|
||||
self.edgePoints, key=lambda p: (p - self.exit).Length
|
||||
)[0]
|
||||
self.exitEdges = list(
|
||||
[e for e in edges if PathGeom.edgeConnectsTo(e, self.realExit)]
|
||||
[e for e in edges if Path.Geom.edgeConnectsTo(e, self.realExit)]
|
||||
)
|
||||
edges.append(Part.Edge(Part.LineSegment(self.realExit, self.exit)))
|
||||
else:
|
||||
@@ -471,15 +470,15 @@ class MapWireToTag:
|
||||
for e in copy.copy(edges):
|
||||
p1 = e.valueAt(e.FirstParameter)
|
||||
p2 = e.valueAt(e.LastParameter)
|
||||
if PathGeom.pointsCoincide(p1, p0):
|
||||
if Path.Geom.pointsCoincide(p1, p0):
|
||||
outputEdges.append((e, False))
|
||||
edges.remove(e)
|
||||
lastP = None
|
||||
p0 = p2
|
||||
debugEdge(e, ">>>>> no flip")
|
||||
break
|
||||
elif PathGeom.pointsCoincide(p2, p0):
|
||||
flipped = PathGeom.flipEdge(e)
|
||||
elif Path.Geom.pointsCoincide(p2, p0):
|
||||
flipped = Path.Geom.flipEdge(e)
|
||||
if not flipped is None:
|
||||
outputEdges.append((flipped, True))
|
||||
else:
|
||||
@@ -526,21 +525,21 @@ class MapWireToTag:
|
||||
return outputEdges
|
||||
|
||||
def isStrut(self, edge):
|
||||
p1 = PathGeom.xy(edge.valueAt(edge.FirstParameter))
|
||||
p2 = PathGeom.xy(edge.valueAt(edge.LastParameter))
|
||||
return PathGeom.pointsCoincide(p1, p2)
|
||||
p1 = Path.Geom.xy(edge.valueAt(edge.FirstParameter))
|
||||
p2 = Path.Geom.xy(edge.valueAt(edge.LastParameter))
|
||||
return Path.Geom.pointsCoincide(p1, p2)
|
||||
|
||||
def shell(self):
|
||||
if len(self.edges) > 1:
|
||||
wire = Part.Wire(self.initialEdge)
|
||||
else:
|
||||
edge = self.edges[0]
|
||||
if PathGeom.pointsCoincide(
|
||||
if Path.Geom.pointsCoincide(
|
||||
edge.valueAt(edge.FirstParameter),
|
||||
self.finalEdge.valueAt(self.finalEdge.FirstParameter),
|
||||
):
|
||||
wire = Part.Wire(self.finalEdge)
|
||||
elif hasattr(self, "initialEdge") and PathGeom.pointsCoincide(
|
||||
elif hasattr(self, "initialEdge") and Path.Geom.pointsCoincide(
|
||||
edge.valueAt(edge.FirstParameter),
|
||||
self.initialEdge.valueAt(self.initialEdge.FirstParameter),
|
||||
):
|
||||
@@ -549,7 +548,7 @@ class MapWireToTag:
|
||||
wire = Part.Wire(edge)
|
||||
|
||||
for edge in self.edges[1:]:
|
||||
if PathGeom.pointsCoincide(
|
||||
if Path.Geom.pointsCoincide(
|
||||
edge.valueAt(edge.FirstParameter),
|
||||
self.finalEdge.valueAt(self.finalEdge.FirstParameter),
|
||||
):
|
||||
@@ -558,7 +557,7 @@ class MapWireToTag:
|
||||
wire.add(edge)
|
||||
|
||||
shell = wire.extrude(FreeCAD.Vector(0, 0, self.tag.height + 1))
|
||||
nullFaces = list([f for f in shell.Faces if PathGeom.isRoughly(f.Area, 0)])
|
||||
nullFaces = list([f for f in shell.Faces if Path.Geom.isRoughly(f.Area, 0)])
|
||||
if nullFaces:
|
||||
return shell.removeShape(nullFaces)
|
||||
return shell
|
||||
@@ -575,8 +574,8 @@ class MapWireToTag:
|
||||
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)
|
||||
and (Path.Geom.isRoughly(p1.z, self.maxZ) or p1.z > self.maxZ)
|
||||
and (Path.Geom.isRoughly(p2.z, self.maxZ) or p2.z > self.maxZ)
|
||||
):
|
||||
rapid = p1 if flip else p2
|
||||
else:
|
||||
@@ -588,7 +587,7 @@ class MapWireToTag:
|
||||
)
|
||||
rapid = None
|
||||
commands.extend(
|
||||
PathGeom.cmdsForEdge(
|
||||
Path.Geom.cmdsForEdge(
|
||||
e,
|
||||
False,
|
||||
False,
|
||||
@@ -612,7 +611,7 @@ class MapWireToTag:
|
||||
commands = []
|
||||
for e in self.edges:
|
||||
commands.extend(
|
||||
PathGeom.cmdsForEdge(e, hSpeed=self.hSpeed, vSpeed=self.vSpeed)
|
||||
Path.Geom.cmdsForEdge(e, hSpeed=self.hSpeed, vSpeed=self.vSpeed)
|
||||
)
|
||||
return commands
|
||||
return []
|
||||
@@ -621,7 +620,7 @@ class MapWireToTag:
|
||||
self.tail = None
|
||||
self.finalEdge = edge
|
||||
if self.tag.solid.isInside(
|
||||
edge.valueAt(edge.LastParameter), PathGeom.Tolerance, True
|
||||
edge.valueAt(edge.LastParameter), Path.Geom.Tolerance, True
|
||||
):
|
||||
Path.Log.track("solid.isInside")
|
||||
self.addEdge(edge)
|
||||
@@ -633,12 +632,12 @@ class MapWireToTag:
|
||||
o = self.tag.originAt(self.tag.z)
|
||||
Path.Log.debug("originAt: (%.2f, %.2f, %.2f)" % (o.x, o.y, o.z))
|
||||
i = edge.valueAt(edge.FirstParameter)
|
||||
if PathGeom.pointsCoincide(i, edge.valueAt(edge.FirstParameter)):
|
||||
if Path.Geom.pointsCoincide(i, edge.valueAt(edge.FirstParameter)):
|
||||
Path.Log.track("tail")
|
||||
self.tail = edge
|
||||
else:
|
||||
Path.Log.track("split")
|
||||
e, tail = PathGeom.splitEdgeAt(edge, i)
|
||||
e, tail = Path.Geom.splitEdgeAt(edge, i)
|
||||
self.addEdge(e)
|
||||
self.tail = tail
|
||||
self.exit = i
|
||||
@@ -661,12 +660,12 @@ class _RapidEdges:
|
||||
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)
|
||||
Path.Geom.isRoughly(r0.X, v0.X)
|
||||
and Path.Geom.isRoughly(r0.Y, v0.Y)
|
||||
and Path.Geom.isRoughly(r0.Z, v0.Z)
|
||||
and Path.Geom.isRoughly(r1.X, v1.X)
|
||||
and Path.Geom.isRoughly(r1.Y, v1.Y)
|
||||
and Path.Geom.isRoughly(r1.Z, v1.Z)
|
||||
):
|
||||
return True
|
||||
return False
|
||||
@@ -676,7 +675,7 @@ class PathData:
|
||||
def __init__(self, obj):
|
||||
Path.Log.track(obj.Base.Name)
|
||||
self.obj = obj
|
||||
self.wire, rapid = PathGeom.wireForPath(obj.Base.Path)
|
||||
self.wire, rapid = Path.Geom.wireForPath(obj.Base.Path)
|
||||
self.rapid = _RapidEdges(rapid)
|
||||
if self.wire:
|
||||
self.edges = self.wire.Edges
|
||||
@@ -691,8 +690,8 @@ class PathData:
|
||||
bottom = [
|
||||
e
|
||||
for e in edges
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.z, minZ)
|
||||
and PathGeom.isRoughly(e.Vertexes[1].Point.z, minZ)
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.z, minZ)
|
||||
and Path.Geom.isRoughly(e.Vertexes[1].Point.z, minZ)
|
||||
]
|
||||
self.bottomEdges = bottom
|
||||
try:
|
||||
@@ -746,7 +745,7 @@ class PathData:
|
||||
for i in range(0, len(self.baseWire.Edges)):
|
||||
edge = self.baseWire.Edges[i]
|
||||
Path.Log.debug(" %d: %.2f" % (i, edge.Length))
|
||||
if PathGeom.isRoughly(edge.Length, longestEdge.Length):
|
||||
if Path.Geom.isRoughly(edge.Length, longestEdge.Length):
|
||||
startIndex = i
|
||||
break
|
||||
|
||||
@@ -898,7 +897,7 @@ class PathData:
|
||||
ts = [
|
||||
t
|
||||
for t in tags
|
||||
if PathGeom.isRoughly(
|
||||
if Path.Geom.isRoughly(
|
||||
0, Part.Vertex(t.originAt(self.minZ)).distToShape(edge)[0], 0.1
|
||||
)
|
||||
]
|
||||
@@ -926,7 +925,7 @@ class PathData:
|
||||
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):
|
||||
if Path.Geom.isRoughly(0.0, v.distToShape(e)[0], 0.1):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -1059,11 +1058,11 @@ class ObjectTagDressup:
|
||||
return False
|
||||
|
||||
def isValidTagStartIntersection(self, edge, i):
|
||||
if PathGeom.pointsCoincide(i, edge.valueAt(edge.LastParameter)):
|
||||
if Path.Geom.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 Path.Geom.pointsCoincide(Path.Geom.xy(p1), Path.Geom.xy(p2)):
|
||||
# if this vertical goes up, it can't be the start of a tag intersection
|
||||
if p1.z < p2.z:
|
||||
return False
|
||||
@@ -1141,9 +1140,9 @@ class ObjectTagDressup:
|
||||
v = edge.Vertexes[1]
|
||||
if (
|
||||
not commands
|
||||
and PathGeom.isRoughly(0, v.X)
|
||||
and PathGeom.isRoughly(0, v.Y)
|
||||
and not PathGeom.isRoughly(0, v.Z)
|
||||
and Path.Geom.isRoughly(0, v.X)
|
||||
and Path.Geom.isRoughly(0, v.Y)
|
||||
and not Path.Geom.isRoughly(0, v.Z)
|
||||
):
|
||||
# The very first move is just to move to ClearanceHeight
|
||||
commands.append(
|
||||
@@ -1157,7 +1156,7 @@ class ObjectTagDressup:
|
||||
)
|
||||
else:
|
||||
commands.extend(
|
||||
PathGeom.cmdsForEdge(
|
||||
Path.Geom.cmdsForEdge(
|
||||
edge, segm=segm, hSpeed=horizFeed, vSpeed=vertFeed
|
||||
)
|
||||
)
|
||||
@@ -1203,8 +1202,8 @@ class ObjectTagDressup:
|
||||
p0 = e.valueAt(e.FirstParameter)
|
||||
p1 = e.valueAt(e.LastParameter)
|
||||
if tag.solid.isInside(
|
||||
p0, PathGeom.Tolerance, True
|
||||
) or tag.solid.isInside(p1, PathGeom.Tolerance, True):
|
||||
p0, Path.Geom.Tolerance, True
|
||||
) or tag.solid.isInside(p1, Path.Geom.Tolerance, True):
|
||||
Path.Log.info(
|
||||
"Tag #%d intersects with starting point - disabling\n" % i
|
||||
)
|
||||
@@ -1290,7 +1289,7 @@ class ObjectTagDressup:
|
||||
"x=%s, y=%s, z=%s" % (tag.x, tag.y, self.pathData.minZ)
|
||||
)
|
||||
# debugMarker(FreeCAD.Vector(tag.x, tag.y, self.pathData.minZ), "tag-%02d" % tagID , (1.0, 0.0, 1.0), 0.5)
|
||||
# if not PathGeom.isRoughly(90, tag.angle):
|
||||
# if not Path.Geom.isRoughly(90, tag.angle):
|
||||
# debugCone(tag.originAt(self.pathData.minZ), tag.r1, tag.r2, tag.actualHeight, "tag-%02d" % tagID)
|
||||
# else:
|
||||
# debugCylinder(tag.originAt(self.pathData.minZ), tag.fullWidth()/2, tag.actualHeight, "tag-%02d" % tagID)
|
||||
|
||||
@@ -33,7 +33,7 @@ from lazy_loader.lazy_loader import LazyLoader
|
||||
|
||||
Part = LazyLoader("Part", globals(), "Part")
|
||||
|
||||
__title__ = "PathGeom - geometry utilities for Path"
|
||||
__title__ = "Geom - geometry utilities for Path"
|
||||
__author__ = "sliptonic (Brad Collette)"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
__doc__ = "Functions to extract and convert between Path.Command and Part.Edge and utility functions to reason about them."
|
||||
@@ -709,7 +709,7 @@ def combineHorizontalFaces(faces):
|
||||
The Adaptive op is not concerned with which hole edges belong to which face.
|
||||
|
||||
Attempts to do the same shape connecting failed with TechDraw.findShapeOutline() and
|
||||
PathGeom.combineConnectedShapes(), so this algorithm was created.
|
||||
Path.Geom.combineConnectedShapes(), so this algorithm was created.
|
||||
"""
|
||||
horizontal = list()
|
||||
offset = 10.0
|
||||
@@ -25,7 +25,6 @@
|
||||
import Path
|
||||
import Path.Op.Base as PathOp
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import FreeCAD
|
||||
import time
|
||||
import json
|
||||
@@ -869,7 +868,7 @@ def _get_working_edges(op, obj):
|
||||
all_regions.append(f)
|
||||
|
||||
# Second face-combining method attempted
|
||||
horizontal = PathGeom.combineHorizontalFaces(all_regions)
|
||||
horizontal = Path.Geom.combineHorizontalFaces(all_regions)
|
||||
if horizontal:
|
||||
obj.removalshape = Part.makeCompound(horizontal)
|
||||
for f in horizontal:
|
||||
|
||||
@@ -32,7 +32,6 @@ from lazy_loader.lazy_loader import LazyLoader
|
||||
|
||||
Draft = LazyLoader("Draft", globals(), "Draft")
|
||||
Part = LazyLoader("Part", globals(), "Part")
|
||||
PathGeom = LazyLoader("PathScripts.PathGeom", globals(), "PathScripts.PathGeom")
|
||||
|
||||
|
||||
__title__ = "Base class for PathArea based operations."
|
||||
@@ -315,9 +314,9 @@ class ObjectOp(PathOp.ObjectOp):
|
||||
x = verts[idx].X
|
||||
y = verts[idx].Y
|
||||
# Zero start value adjustments for Path.fromShapes() bug
|
||||
if PathGeom.isRoughly(x, 0.0):
|
||||
if Path.Geom.isRoughly(x, 0.0):
|
||||
x = 0.00001
|
||||
if PathGeom.isRoughly(y, 0.0):
|
||||
if Path.Geom.isRoughly(y, 0.0):
|
||||
y = 0.00001
|
||||
pathParams["start"] = FreeCAD.Vector(x, y, verts[0].Z)
|
||||
else:
|
||||
|
||||
@@ -24,9 +24,8 @@ import FreeCAD
|
||||
from PathScripts.PathUtils import waiting_effects
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import math
|
||||
import time
|
||||
@@ -703,12 +702,12 @@ class ObjectOp(object):
|
||||
|
||||
if FeatureDepths & self.opFeatures(obj):
|
||||
# first set update final depth, it's value is not negotiable
|
||||
if not PathGeom.isRoughly(obj.OpFinalDepth.Value, zmin):
|
||||
if not Path.Geom.isRoughly(obj.OpFinalDepth.Value, zmin):
|
||||
obj.OpFinalDepth = zmin
|
||||
zmin = obj.OpFinalDepth.Value
|
||||
|
||||
def minZmax(z):
|
||||
if hasattr(obj, "StepDown") and not PathGeom.isRoughly(
|
||||
if hasattr(obj, "StepDown") and not Path.Geom.isRoughly(
|
||||
obj.StepDown.Value, 0
|
||||
):
|
||||
return z + obj.StepDown.Value
|
||||
@@ -720,7 +719,7 @@ class ObjectOp(object):
|
||||
zmax = minZmax(zmin)
|
||||
|
||||
# update start depth if requested and required
|
||||
if not PathGeom.isRoughly(obj.OpStartDepth.Value, zmax):
|
||||
if not Path.Geom.isRoughly(obj.OpStartDepth.Value, zmax):
|
||||
obj.OpStartDepth = zmax
|
||||
else:
|
||||
# every obj has a StartDepth
|
||||
|
||||
@@ -26,7 +26,6 @@ import Path
|
||||
import Path.Op.Base as PathOp
|
||||
import Path.Op.EngraveBase as PathEngraveBase
|
||||
import Path.Op.Util as PathOpUtil
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import math
|
||||
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
@@ -61,7 +60,7 @@ def toolDepthAndOffset(width, extraDepth, tool, printInfo):
|
||||
suppressInfo = False
|
||||
if hasattr(tool, "CuttingEdgeAngle"):
|
||||
angle = float(tool.CuttingEdgeAngle)
|
||||
if PathGeom.isRoughly(angle, 180) or PathGeom.isRoughly(angle, 0):
|
||||
if Path.Geom.isRoughly(angle, 180) or Path.Geom.isRoughly(angle, 0):
|
||||
angle = 180
|
||||
toolOffset = float(tool.Diameter) / 2
|
||||
else:
|
||||
@@ -95,7 +94,7 @@ def toolDepthAndOffset(width, extraDepth, tool, printInfo):
|
||||
|
||||
tan = math.tan(math.radians(angle / 2))
|
||||
|
||||
toolDepth = 0 if PathGeom.isRoughly(tan, 0) else width / tan
|
||||
toolDepth = 0 if Path.Geom.isRoughly(tan, 0) else width / tan
|
||||
depth = toolDepth + extraDepth
|
||||
extraOffset = -width if angle == 180 else (extraDepth / tan)
|
||||
offset = toolOffset + extraOffset
|
||||
|
||||
@@ -28,10 +28,10 @@ from Generators import drill_generator as generator
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
import Path.Base.FeedRate as PathFeedRate
|
||||
import Path.Base.MachineState as PathMachineState
|
||||
import Path.Op.Base as PathOp
|
||||
import Path.Op.CircularHoleBase as PathCircularHoleBase
|
||||
import PathFeedRate
|
||||
import PathMachineState
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
import Path
|
||||
import Path.Op.Base as PathOp
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Path.Op.Util as PathOpUtil
|
||||
import copy
|
||||
|
||||
@@ -138,13 +137,13 @@ class ObjectOp(PathOp.ObjectOp):
|
||||
)
|
||||
first = False
|
||||
|
||||
if PathGeom.pointsCoincide(last, edge.valueAt(edge.FirstParameter)):
|
||||
# if PathGeom.pointsCoincide(last, edge.Vertexes[0].Point):
|
||||
for cmd in PathGeom.cmdsForEdge(edge):
|
||||
if Path.Geom.pointsCoincide(last, edge.valueAt(edge.FirstParameter)):
|
||||
# if Path.Geom.pointsCoincide(last, edge.Vertexes[0].Point):
|
||||
for cmd in Path.Geom.cmdsForEdge(edge):
|
||||
self.appendCommand(cmd, z, relZ, self.horizFeed)
|
||||
last = edge.Vertexes[-1].Point
|
||||
else:
|
||||
for cmd in PathGeom.cmdsForEdge(edge, True):
|
||||
for cmd in Path.Geom.cmdsForEdge(edge, True):
|
||||
self.appendCommand(cmd, z, relZ, self.horizFeed)
|
||||
last = edge.Vertexes[0].Point
|
||||
self.commandlist.append(
|
||||
|
||||
@@ -23,16 +23,15 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Op.Base as PathOp
|
||||
import PathGui as PGui # ensure Path/Gui/Resources are loaded
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGetPoint as PathGetPoint
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathSelection as PathSelection
|
||||
import PathScripts.PathSetupSheet as PathSetupSheet
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import importlib
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
@@ -1000,7 +999,7 @@ class TaskPanelDepthsPage(TaskPanelPage):
|
||||
sub = sel[0].SubObjects[0]
|
||||
if "Vertex" == sub.ShapeType:
|
||||
return sub.Z
|
||||
if PathGeom.isHorizontal(sub):
|
||||
if Path.Geom.isHorizontal(sub):
|
||||
if "Edge" == sub.ShapeType:
|
||||
return sub.Vertexes[0].Z
|
||||
if "Face" == sub.ShapeType:
|
||||
|
||||
@@ -27,9 +27,9 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
import Path.Base.FeedRate as PathFeedRate
|
||||
import Path.Op.Base as PathOp
|
||||
import Path.Op.CircularHoleBase as PathCircularHoleBase
|
||||
import PathFeedRate
|
||||
|
||||
|
||||
__title__ = "Path Helix Drill Operation"
|
||||
|
||||
@@ -31,8 +31,6 @@ import PathScripts.PathUtils as PathUtils
|
||||
# lazily loaded modules
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
|
||||
PathGeom = LazyLoader("PathScripts.PathGeom", globals(), "PathScripts.PathGeom")
|
||||
|
||||
__title__ = "Path 3D Pocket Operation"
|
||||
__author__ = "Yorik van Havre <[email protected]>"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
@@ -254,7 +252,7 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
removalSolids = [
|
||||
s
|
||||
for s in rawRemovalShape.Solids
|
||||
if PathGeom.isRoughly(
|
||||
if Path.Geom.isRoughly(
|
||||
s.BoundBox.ZMax, rawRemovalShape.BoundBox.ZMax
|
||||
)
|
||||
]
|
||||
@@ -893,7 +891,7 @@ def _extrudeBaseDown(base):
|
||||
Extrudes and fuses all non-vertical faces downward to a level 1.0 mm below base ZMin."""
|
||||
allExtrusions = list()
|
||||
zMin = base.Shape.BoundBox.ZMin
|
||||
bbFace = PathGeom.makeBoundBoxFace(base.Shape.BoundBox, offset=5.0)
|
||||
bbFace = Path.Geom.makeBoundBoxFace(base.Shape.BoundBox, offset=5.0)
|
||||
bbFace.translate(
|
||||
FreeCAD.Vector(0.0, 0.0, float(int(base.Shape.BoundBox.ZMin - 5.0)))
|
||||
)
|
||||
@@ -902,7 +900,7 @@ def _extrudeBaseDown(base):
|
||||
# Make projections of each non-vertical face and extrude it
|
||||
for f in base.Shape.Faces:
|
||||
fbb = f.BoundBox
|
||||
if not PathGeom.isRoughly(f.normalAt(0, 0).z, 0.0):
|
||||
if not Path.Geom.isRoughly(f.normalAt(0, 0).z, 0.0):
|
||||
pp = bbFace.makeParallelProjection(f.Wires[0], direction)
|
||||
face = Part.Face(Part.Wire(pp.Edges))
|
||||
face.translate(FreeCAD.Vector(0.0, 0.0, fbb.ZMin))
|
||||
|
||||
@@ -25,7 +25,6 @@ import FreeCAD
|
||||
import Path
|
||||
import Path.Op.Base as PathOp
|
||||
import Path.Op.PocketBase as PathPocketBase
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
|
||||
|
||||
# lazily loaded modules
|
||||
@@ -123,16 +122,16 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
|
||||
# Check if selected vertical faces form a loop
|
||||
if len(self.vert) > 0:
|
||||
self.vertical = PathGeom.combineConnectedShapes(self.vert)
|
||||
self.vertical = Path.Geom.combineConnectedShapes(self.vert)
|
||||
self.vWires = [
|
||||
TechDraw.findShapeOutline(shape, 1, FreeCAD.Vector(0, 0, 1))
|
||||
for shape in self.vertical
|
||||
]
|
||||
for wire in self.vWires:
|
||||
w = PathGeom.removeDuplicateEdges(wire)
|
||||
w = Path.Geom.removeDuplicateEdges(wire)
|
||||
face = Part.Face(w)
|
||||
# face.tessellate(0.1)
|
||||
if PathGeom.isRoughly(face.Area, 0):
|
||||
if Path.Geom.isRoughly(face.Area, 0):
|
||||
Path.Log.error("Vertical faces do not form a loop - ignoring")
|
||||
else:
|
||||
self.horiz.append(face)
|
||||
@@ -149,7 +148,7 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
self.exts.append(f)
|
||||
|
||||
# check all faces and see if they are touching/overlapping and combine and simplify
|
||||
self.horizontal = PathGeom.combineHorizontalFaces(self.horiz)
|
||||
self.horizontal = Path.Geom.combineHorizontalFaces(self.horiz)
|
||||
|
||||
# Move all faces to final depth less buffer before extrusion
|
||||
# Small negative buffer is applied to compensate for internal significant digits/rounding issue
|
||||
@@ -202,11 +201,11 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
# Support methods
|
||||
def isVerticalExtrusionFace(self, face):
|
||||
fBB = face.BoundBox
|
||||
if PathGeom.isRoughly(fBB.ZLength, 0.0):
|
||||
if Path.Geom.isRoughly(fBB.ZLength, 0.0):
|
||||
return False
|
||||
extr = face.extrude(FreeCAD.Vector(0.0, 0.0, fBB.ZLength))
|
||||
if hasattr(extr, "Volume"):
|
||||
if PathGeom.isRoughly(extr.Volume, 0.0):
|
||||
if Path.Geom.isRoughly(extr.Volume, 0.0):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -219,13 +218,13 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
|
||||
if type(face.Surface) == Part.Plane:
|
||||
Path.Log.debug("type() == Part.Plane")
|
||||
if PathGeom.isVertical(face.Surface.Axis):
|
||||
if Path.Geom.isVertical(face.Surface.Axis):
|
||||
Path.Log.debug(" -isVertical()")
|
||||
# it's a flat horizontal face
|
||||
self.horiz.append(face)
|
||||
return True
|
||||
|
||||
elif PathGeom.isHorizontal(face.Surface.Axis):
|
||||
elif Path.Geom.isHorizontal(face.Surface.Axis):
|
||||
Path.Log.debug(" -isHorizontal()")
|
||||
self.vert.append(face)
|
||||
return True
|
||||
@@ -233,7 +232,7 @@ class ObjectPocket(PathPocketBase.ObjectPocket):
|
||||
else:
|
||||
return False
|
||||
|
||||
elif type(face.Surface) == Part.Cylinder and PathGeom.isVertical(
|
||||
elif type(face.Surface) == Part.Cylinder and Path.Geom.isVertical(
|
||||
face.Surface.Axis
|
||||
):
|
||||
Path.Log.debug("type() == Part.Cylinder")
|
||||
|
||||
@@ -41,7 +41,6 @@ from lazy_loader.lazy_loader import LazyLoader
|
||||
|
||||
Part = LazyLoader("Part", globals(), "Part")
|
||||
Arcs = LazyLoader("draftgeoutils.arcs", globals(), "draftgeoutils.arcs")
|
||||
PathGeom = LazyLoader("PathScripts.PathGeom", globals(), "PathScripts.PathGeom")
|
||||
if FreeCAD.GuiUp:
|
||||
FreeCADGui = LazyLoader("FreeCADGui", globals(), "FreeCADGui")
|
||||
|
||||
@@ -947,7 +946,7 @@ class ObjectSlot(PathOp.ObjectOp):
|
||||
norm = shape_1.normalAt(0.0, 0.0)
|
||||
Path.Log.debug("{}.normalAt(): {}".format(sub1, norm))
|
||||
|
||||
if PathGeom.isRoughly(shape_1.BoundBox.ZMax, shape_1.BoundBox.ZMin):
|
||||
if Path.Geom.isRoughly(shape_1.BoundBox.ZMax, shape_1.BoundBox.ZMin):
|
||||
# Horizontal face
|
||||
if norm.z == 1 or norm.z == -1:
|
||||
pnts = self._processSingleHorizFace(obj, shape_1)
|
||||
|
||||
@@ -26,7 +26,6 @@ import FreeCAD
|
||||
import Path
|
||||
import Path.Op.Base as PathOp
|
||||
import Path.Op.CircularHoleBase as PathCircularHoleBase
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Generators.threadmilling_generator as threadmilling
|
||||
import math
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import math
|
||||
|
||||
# lazily loaded modules
|
||||
@@ -116,19 +115,19 @@ def _orientEdges(inEdges):
|
||||
if 1 < len(inEdges):
|
||||
last = e0.valueAt(e0.LastParameter)
|
||||
e1 = inEdges[1]
|
||||
if not PathGeom.pointsCoincide(
|
||||
if not Path.Geom.pointsCoincide(
|
||||
last, e1.valueAt(e1.FirstParameter)
|
||||
) and not PathGeom.pointsCoincide(last, e1.valueAt(e1.LastParameter)):
|
||||
) and not Path.Geom.pointsCoincide(last, e1.valueAt(e1.LastParameter)):
|
||||
debugEdge("# _orientEdges - flip first", e0)
|
||||
e0 = PathGeom.flipEdge(e0)
|
||||
e0 = Path.Geom.flipEdge(e0)
|
||||
|
||||
edges = [e0]
|
||||
last = e0.valueAt(e0.LastParameter)
|
||||
for e in inEdges[1:]:
|
||||
edge = (
|
||||
e
|
||||
if PathGeom.pointsCoincide(last, e.valueAt(e.FirstParameter))
|
||||
else PathGeom.flipEdge(e)
|
||||
if Path.Geom.pointsCoincide(last, e.valueAt(e.FirstParameter))
|
||||
else Path.Geom.flipEdge(e)
|
||||
)
|
||||
edges.append(edge)
|
||||
last = edge.valueAt(edge.LastParameter)
|
||||
@@ -172,7 +171,7 @@ def orientWire(w, forward=True):
|
||||
if forward is not None:
|
||||
if forward != _isWireClockwise(wire):
|
||||
Path.Log.track("orientWire - needs flipping")
|
||||
return PathGeom.flipWire(wire)
|
||||
return Path.Geom.flipWire(wire)
|
||||
Path.Log.track("orientWire - ok")
|
||||
return wire
|
||||
|
||||
@@ -196,7 +195,7 @@ def offsetWire(wire, base, offset, forward, Side=None):
|
||||
curve.Radius + offset, curve.Center, FreeCAD.Vector(0, 0, z)
|
||||
)
|
||||
if base.isInside(new_edge.Vertexes[0].Point, offset / 2, True):
|
||||
if offset > curve.Radius or PathGeom.isRoughly(offset, curve.Radius):
|
||||
if offset > curve.Radius or Path.Geom.isRoughly(offset, curve.Radius):
|
||||
# offsetting a hole by its own radius (or more) makes the hole vanish
|
||||
return None
|
||||
if Side:
|
||||
@@ -285,9 +284,9 @@ def offsetWire(wire, base, offset, forward, Side=None):
|
||||
# flip the edge if it's not on the right side of the original edge
|
||||
if forward is not None:
|
||||
v1 = edge.Vertexes[1].Point - p0
|
||||
left = PathGeom.Side.Left == PathGeom.Side.of(v0, v1)
|
||||
left = Path.Geom.Side.Left == Path.Geom.Side.of(v0, v1)
|
||||
if left != forward:
|
||||
edge = PathGeom.flipEdge(edge)
|
||||
edge = Path.Geom.flipEdge(edge)
|
||||
return Part.Wire([edge])
|
||||
|
||||
# if we get to this point the assumption is that makeOffset2D can deal with the edge
|
||||
@@ -342,7 +341,7 @@ def offsetWire(wire, base, offset, forward, Side=None):
|
||||
p0 = edge.firstVertex().Point
|
||||
p1 = edge.lastVertex().Point
|
||||
for p in insideEndpoints:
|
||||
if PathGeom.pointsCoincide(p, p0, 0.01) or PathGeom.pointsCoincide(
|
||||
if Path.Geom.pointsCoincide(p, p0, 0.01) or Path.Geom.pointsCoincide(
|
||||
p, p1, 0.01
|
||||
):
|
||||
return True
|
||||
@@ -361,7 +360,7 @@ def offsetWire(wire, base, offset, forward, Side=None):
|
||||
def isCircleAt(edge, center):
|
||||
"""isCircleAt(edge, center) ... helper function returns True if edge is a circle at the given center."""
|
||||
if Part.Circle == type(edge.Curve) or Part.ArcOfCircle == type(edge.Curve):
|
||||
return PathGeom.pointsCoincide(edge.Curve.Center, center)
|
||||
return Path.Geom.pointsCoincide(edge.Curve.Center, center)
|
||||
return False
|
||||
|
||||
# split offset wire into edges to the left side and edges to the right side
|
||||
@@ -376,7 +375,7 @@ def offsetWire(wire, base, offset, forward, Side=None):
|
||||
# next side, we're done
|
||||
for e in owire.Edges + owire.Edges:
|
||||
if isCircleAt(e, start):
|
||||
if PathGeom.pointsCoincide(e.Curve.Axis, FreeCAD.Vector(0, 0, 1)):
|
||||
if Path.Geom.pointsCoincide(e.Curve.Axis, FreeCAD.Vector(0, 0, 1)):
|
||||
if not collectLeft and leftSideEdges:
|
||||
break
|
||||
collectLeft = True
|
||||
@@ -387,7 +386,7 @@ def offsetWire(wire, base, offset, forward, Side=None):
|
||||
collectLeft = False
|
||||
collectRight = True
|
||||
elif isCircleAt(e, end):
|
||||
if PathGeom.pointsCoincide(e.Curve.Axis, FreeCAD.Vector(0, 0, 1)):
|
||||
if Path.Geom.pointsCoincide(e.Curve.Axis, FreeCAD.Vector(0, 0, 1)):
|
||||
if not collectRight and rightSideEdges:
|
||||
break
|
||||
collectLeft = False
|
||||
@@ -410,7 +409,7 @@ def offsetWire(wire, base, offset, forward, Side=None):
|
||||
edges = leftSideEdges
|
||||
for e in longestWire.Edges:
|
||||
for e0 in rightSideEdges:
|
||||
if PathGeom.edgesMatch(e, e0):
|
||||
if Path.Geom.edgesMatch(e, e0):
|
||||
edges = rightSideEdges
|
||||
Path.Log.debug("#use right side edges")
|
||||
if not forward:
|
||||
|
||||
@@ -26,7 +26,6 @@ import Path
|
||||
import Path.Op.Base as PathOp
|
||||
import Path.Op.EngraveBase as PathEngraveBase
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import math
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
@@ -285,7 +284,7 @@ class ObjectVcarve(PathEngraveBase.ObjectOp):
|
||||
Path.Command("G1 X{} Y{} Z{} F{}".format(p.x, p.y, p.z, vSpeed))
|
||||
)
|
||||
for e in edges:
|
||||
path.extend(PathGeom.cmdsForEdge(e, hSpeed=hSpeed, vSpeed=vSpeed))
|
||||
path.extend(Path.Geom.cmdsForEdge(e, hSpeed=hSpeed, vSpeed=vSpeed))
|
||||
|
||||
return path
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ from __future__ import print_function
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import os
|
||||
import re
|
||||
|
||||
@@ -34,8 +34,7 @@ import FreeCAD
|
||||
import Path
|
||||
import Part
|
||||
|
||||
from PathMachineState import MachineState
|
||||
from PathScripts.PathGeom import CmdMoveArc, edgeForCmd, cmdsForEdge
|
||||
from Path.Base.MachineState import MachineState
|
||||
|
||||
translate = FreeCAD.Qt.translate
|
||||
FreeCADGui = None
|
||||
@@ -216,16 +215,16 @@ def splitArcs(path):
|
||||
machine = MachineState()
|
||||
for command in path.Commands:
|
||||
|
||||
if command.Name not in CmdMoveArc:
|
||||
if command.Name not in Path.Geom.CmdMoveArc:
|
||||
machine.addCommand(command)
|
||||
results.append(command)
|
||||
continue
|
||||
|
||||
edge = edgeForCmd(command, machine.getPosition())
|
||||
edge = Path.Geom.edgeForCmd(command, machine.getPosition())
|
||||
pts = edge.discretize(Deflection=deflection)
|
||||
edges = [Part.makeLine(v1, v2) for v1, v2 in zip(pts, pts[1:])]
|
||||
for edge in edges:
|
||||
results.extend(cmdsForEdge(edge))
|
||||
results.extend(Path.Geom.cmdsForEdge(edge))
|
||||
|
||||
machine.addCommand(command)
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ from __future__ import print_function
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import datetime
|
||||
import importDXF
|
||||
|
||||
@@ -93,8 +92,8 @@ def dxfWrite(objlist, filename):
|
||||
def parse(pathobj):
|
||||
"""accepts a Path object. Returns a list of wires"""
|
||||
|
||||
feedcommands = PathGeom.CmdMove
|
||||
rapidcommands = PathGeom.CmdMoveRapid
|
||||
feedcommands = Path.Geom.CmdMove
|
||||
rapidcommands = Path.Geom.CmdMoveRapid
|
||||
|
||||
edges = []
|
||||
objlist = []
|
||||
@@ -126,7 +125,7 @@ def parse(pathobj):
|
||||
|
||||
# feeding move. Build an edge
|
||||
if flatcommand.Name in feedcommands:
|
||||
edges.append(PathGeom.edgeForCmd(flatcommand, curPoint))
|
||||
edges.append(Path.Geom.edgeForCmd(flatcommand, curPoint))
|
||||
Path.Log.debug("feeding move")
|
||||
|
||||
# update the curpoint
|
||||
|
||||
@@ -26,11 +26,12 @@
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Units
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Post.Utils as PostUtils
|
||||
import argparse
|
||||
import datetime
|
||||
import shlex
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import re
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ import argparse
|
||||
import shlex
|
||||
import FreeCAD
|
||||
from FreeCAD import Units
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Post.Utils as PostUtils
|
||||
|
||||
Revised = "2020-11-03" # Revision date for this file.
|
||||
|
||||
@@ -49,7 +49,8 @@ Many other OpenSBP commands not handled
|
||||
"""
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import os
|
||||
import Path
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ import argparse
|
||||
import shlex
|
||||
import FreeCAD
|
||||
from FreeCAD import Units
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Post.Utils as PostUtils
|
||||
|
||||
Revised = "2021-10-21" # Revision date for this file.
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Base.PropertyBag as PathPropertyBag
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathPropertyBag as PathPropertyBag
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import json
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
from PySide import QtCore, QtGui
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathPropertyEditor as PathPropertyEditor
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Tool.Controller as PathToolController
|
||||
import Path.Tool.Gui.Bit as PathToolBitGui
|
||||
import PathGui as PGui # ensure Path/Gui/Resources are loaded
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
|
||||
# lazily loaded modules
|
||||
from lazy_loader.lazy_loader import LazyLoader
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from PathApp import *
|
||||
|
||||
import Path.Log as Log
|
||||
import Path.Geom as Geom
|
||||
|
||||
@@ -24,7 +24,6 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import math
|
||||
|
||||
# lazily loaded modules
|
||||
@@ -56,7 +55,7 @@ def endPoints(edgeOrWire):
|
||||
pts.extend([e.valueAt(e.LastParameter) for e in edgeOrWire.Edges])
|
||||
unique = []
|
||||
for p in pts:
|
||||
cnt = len([p2 for p2 in pts if PathGeom.pointsCoincide(p, p2)])
|
||||
cnt = len([p2 for p2 in pts if Path.Geom.pointsCoincide(p, p2)])
|
||||
if 1 == cnt:
|
||||
unique.append(p)
|
||||
|
||||
@@ -64,7 +63,7 @@ def endPoints(edgeOrWire):
|
||||
|
||||
pfirst = edgeOrWire.valueAt(edgeOrWire.FirstParameter)
|
||||
plast = edgeOrWire.valueAt(edgeOrWire.LastParameter)
|
||||
if PathGeom.pointsCoincide(pfirst, plast):
|
||||
if Path.Geom.pointsCoincide(pfirst, plast):
|
||||
return None
|
||||
|
||||
return [pfirst, plast]
|
||||
@@ -73,7 +72,7 @@ def endPoints(edgeOrWire):
|
||||
def includesPoint(p, pts):
|
||||
"""includesPoint(p, pts) ... answer True if the collection of pts includes the point p"""
|
||||
for pt in pts:
|
||||
if PathGeom.pointsCoincide(p, pt):
|
||||
if Path.Geom.pointsCoincide(p, pt):
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -246,7 +245,7 @@ class Extension(object):
|
||||
e2 = e0.copy()
|
||||
off = self.length.Value * direction
|
||||
e2.translate(off)
|
||||
e2 = PathGeom.flipEdge(e2)
|
||||
e2 = Path.Geom.flipEdge(e2)
|
||||
e1 = Part.Edge(
|
||||
Part.LineSegment(
|
||||
e0.valueAt(e0.LastParameter), e2.valueAt(e2.FirstParameter)
|
||||
@@ -295,7 +294,7 @@ class Extension(object):
|
||||
tangent = e0.tangentAt(midparam)
|
||||
Path.Log.track("tangent", tangent, self.feature, self.sub)
|
||||
normal = tangent.cross(FreeCAD.Vector(0, 0, 1))
|
||||
if PathGeom.pointsCoincide(normal, FreeCAD.Vector(0, 0, 0)):
|
||||
if Path.Geom.pointsCoincide(normal, FreeCAD.Vector(0, 0, 0)):
|
||||
return None
|
||||
|
||||
return self._getDirectedNormal(e0.valueAt(midparam), normal.normalize())
|
||||
@@ -326,7 +325,7 @@ class Extension(object):
|
||||
Path.Log.track()
|
||||
|
||||
length = self.length.Value
|
||||
if PathGeom.isRoughly(0, length) or not self.sub:
|
||||
if Path.Geom.isRoughly(0, length) or not self.sub:
|
||||
Path.Log.debug("no extension, length=%.2f, sub=%s" % (length, self.sub))
|
||||
return None
|
||||
|
||||
@@ -347,7 +346,7 @@ class Extension(object):
|
||||
if direction is None:
|
||||
return None
|
||||
|
||||
if PathGeom.pointsCoincide(normal, direction):
|
||||
if Path.Geom.pointsCoincide(normal, direction):
|
||||
r = circle.Radius - length
|
||||
else:
|
||||
r = circle.Radius + length
|
||||
@@ -365,7 +364,7 @@ class Extension(object):
|
||||
|
||||
# Determine if rotational alignment is necessary for new arc
|
||||
rotationAdjustment = arcAdjustmentAngle(edge, e3)
|
||||
if not PathGeom.isRoughly(rotationAdjustment, 0.0):
|
||||
if not Path.Geom.isRoughly(rotationAdjustment, 0.0):
|
||||
e3.rotate(
|
||||
edge.Curve.Center,
|
||||
FreeCAD.Vector(0.0, 0.0, 1.0),
|
||||
@@ -424,7 +423,7 @@ class Extension(object):
|
||||
subFace = Part.Face(sub)
|
||||
featFace = Part.Face(feature.Wires[0])
|
||||
isOutside = True
|
||||
if not PathGeom.isRoughly(featFace.Area, subFace.Area):
|
||||
if not Path.Geom.isRoughly(featFace.Area, subFace.Area):
|
||||
length = -1.0 * length
|
||||
isOutside = False
|
||||
|
||||
@@ -560,9 +559,9 @@ def getExtendOutlineFace(
|
||||
bbx = f.BoundBox
|
||||
zNorm = abs(f.normalAt(0.0, 0.0).z)
|
||||
if (
|
||||
PathGeom.isRoughly(zNorm, 1.0)
|
||||
and PathGeom.isRoughly(bbx.ZMax - bbx.ZMin, 0.0)
|
||||
and PathGeom.isRoughly(bbx.ZMin, face.BoundBox.ZMin)
|
||||
Path.Geom.isRoughly(zNorm, 1.0)
|
||||
and Path.Geom.isRoughly(bbx.ZMax - bbx.ZMin, 0.0)
|
||||
and Path.Geom.isRoughly(bbx.ZMin, face.BoundBox.ZMin)
|
||||
):
|
||||
if bbx.ZMin < zmin:
|
||||
bottom_faces.append(f)
|
||||
@@ -610,7 +609,7 @@ def getWaterlineFace(base_shape, face):
|
||||
# Get top face(s) of envelope at face height
|
||||
rawList = list()
|
||||
for f in env.Faces:
|
||||
if PathGeom.isRoughly(f.BoundBox.ZMin, faceHeight):
|
||||
if Path.Geom.isRoughly(f.BoundBox.ZMin, faceHeight):
|
||||
rawList.append(f)
|
||||
# make compound and extrude downward
|
||||
rawComp = Part.makeCompound(rawList)
|
||||
|
||||
@@ -27,7 +27,6 @@ import FreeCADGui
|
||||
import Path
|
||||
import Path.Op.Gui.Base as PathOpGui
|
||||
import PathScripts.PathFeatureExtensions as FeatureExtensions
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGui as PathGui
|
||||
|
||||
# lazily loaded modules
|
||||
@@ -361,13 +360,13 @@ class TaskPanelExtensionPage(PathOpGui.TaskPanelPage):
|
||||
if extendCorners:
|
||||
|
||||
def edgesMatchShape(e0, e1):
|
||||
flipped = PathGeom.flipEdge(e1)
|
||||
flipped = Path.Geom.flipEdge(e1)
|
||||
if flipped:
|
||||
return PathGeom.edgesMatch(e0, e1) or PathGeom.edgesMatch(
|
||||
return Path.Geom.edgesMatch(e0, e1) or Path.Geom.edgesMatch(
|
||||
e0, flipped
|
||||
)
|
||||
else:
|
||||
return PathGeom.edgesMatch(e0, e1)
|
||||
return Path.Geom.edgesMatch(e0, e1)
|
||||
|
||||
self.extensionEdges = extensionEdges
|
||||
Path.Log.debug("extensionEdges.values(): {}".format(extensionEdges.values()))
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import Path.Base.Util as PathUtil
|
||||
from PySide import QtGui, QtCore
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
@@ -75,7 +74,7 @@ def updateInputField(obj, prop, widget, onBeforeChange=None):
|
||||
attrValue = attr.Value if hasattr(attr, "Value") else attr
|
||||
|
||||
isDiff = False
|
||||
if not PathGeom.isRoughly(attrValue, value):
|
||||
if not Path.Geom.isRoughly(attrValue, value):
|
||||
isDiff = True
|
||||
else:
|
||||
if hasattr(obj, "ExpressionEngine"):
|
||||
@@ -85,7 +84,7 @@ def updateInputField(obj, prop, widget, onBeforeChange=None):
|
||||
exprSet = True
|
||||
Path.Log.debug('prop = "expression": {} = "{}"'.format(prp, expr))
|
||||
value = FreeCAD.Units.Quantity(obj.evalExpression(expr)).Value
|
||||
if not PathGeom.isRoughly(attrValue, value):
|
||||
if not Path.Geom.isRoughly(attrValue, value):
|
||||
isDiff = True
|
||||
break
|
||||
if exprSet:
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathGui
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import importlib
|
||||
|
||||
__title__ = "Path Icon ViewProvider"
|
||||
|
||||
@@ -24,12 +24,12 @@ from PySide import QtCore
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
from Path.Post.Processor import PostProcessor
|
||||
import Path.Tool.Controller as PathToolController
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathSetupSheet as PathSetupSheet
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import json
|
||||
import time
|
||||
import Path
|
||||
|
||||
@@ -25,11 +25,11 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathJobDlg as PathJobDlg
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ from collections import Counter
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import glob
|
||||
import os
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ from pivy import coin
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Tool.Gui.Bit as PathToolBitGui
|
||||
import Path.Tool.Gui.Controller as PathToolControllerGui
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathGuiInit as PathGuiInit
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathJobCmd as PathJobCmd
|
||||
@@ -38,7 +38,6 @@ import PathScripts.PathJobDlg as PathJobDlg
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
import PathScripts.PathSetupSheetGui as PathSetupSheetGui
|
||||
import PathScripts.PathStock as PathStock
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import json
|
||||
import math
|
||||
@@ -1087,7 +1086,7 @@ class TaskPanel:
|
||||
if flip:
|
||||
v = axis.negative()
|
||||
|
||||
if PathGeom.pointsCoincide(abs(v), abs(normal)):
|
||||
if Path.Geom.pointsCoincide(abs(v), abs(normal)):
|
||||
# Selection is already aligned with the axis of rotation leading
|
||||
# to a (0,0,0) cross product for rotation.
|
||||
# --> Need to flip the object around one of the "other" axis.
|
||||
@@ -1128,9 +1127,9 @@ class TaskPanel:
|
||||
% (normal.x, normal.y, normal.z, sub.Orientation)
|
||||
)
|
||||
|
||||
if PathGeom.pointsCoincide(axis, normal):
|
||||
if Path.Geom.pointsCoincide(axis, normal):
|
||||
alignSel(sel, normal, True)
|
||||
elif PathGeom.pointsCoincide(axis, FreeCAD.Vector() - normal):
|
||||
elif Path.Geom.pointsCoincide(axis, FreeCAD.Vector() - normal):
|
||||
alignSel(sel, FreeCAD.Vector() - normal, True)
|
||||
else:
|
||||
alignSel(sel, normal)
|
||||
@@ -1139,9 +1138,9 @@ class TaskPanel:
|
||||
normal = (
|
||||
sub.Vertexes[1].Point - sub.Vertexes[0].Point
|
||||
).normalize()
|
||||
if PathGeom.pointsCoincide(
|
||||
if Path.Geom.pointsCoincide(
|
||||
axis, normal
|
||||
) or PathGeom.pointsCoincide(axis, FreeCAD.Vector() - normal):
|
||||
) or Path.Geom.pointsCoincide(axis, FreeCAD.Vector() - normal):
|
||||
# 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
|
||||
alignSel(sel, normal, True)
|
||||
|
||||
@@ -24,10 +24,10 @@ from PySide import QtCore, QtGui
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.PropertyBag as PathPropertyBag
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts.PathIconViewProvider as PathIconViewProvider
|
||||
import PathScripts.PathPropertyBag as PathPropertyBag
|
||||
import PathScripts.PathPropertyEditor as PathPropertyEditor
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import re
|
||||
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ from PySide import QtCore, QtGui
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathPreferences as PathPreferences
|
||||
from collections import Counter
|
||||
from datetime import datetime
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathScripts.PathSetupSheetOpPrototype as PathSetupSheetOpPrototype
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
|
||||
__title__ = "Setup Sheet for a Job."
|
||||
@@ -234,7 +233,7 @@ class SetupSheet:
|
||||
return None
|
||||
|
||||
def hasDefaultToolRapids(self):
|
||||
return PathGeom.isRoughly(self.obj.VertRapid.Value, 0) and PathGeom.isRoughly(
|
||||
return Path.Geom.isRoughly(self.obj.VertRapid.Value, 0) and Path.Geom.isRoughly(
|
||||
self.obj.HorizRapid.Value, 0
|
||||
)
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import PathGui as PGui # ensure Path/Gui/Resources are loaded
|
||||
import PathScripts.PathGui as PathGui
|
||||
import PathScripts.PathIconViewProvider as PathIconViewProvider
|
||||
import PathScripts.PathSetupSheet as PathSetupSheet
|
||||
import PathScripts.PathSetupSheetOpPrototypeGui as PathSetupSheetOpPrototypeGui
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
|
||||
from PySide import QtCore, QtGui
|
||||
|
||||
|
||||
@@ -22,10 +22,9 @@
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Dressup.Utils as PathDressup
|
||||
import PathGui as PGui # ensure Path/Gui/Resources are loaded
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathSimulator
|
||||
import math
|
||||
@@ -399,14 +398,14 @@ class PathSimulation:
|
||||
self.PerformCutBoolean()
|
||||
|
||||
def RapidMove(self, cmd, curpos):
|
||||
path = PathGeom.edgeForCmd(cmd, curpos) # hack to overcome occ bug
|
||||
path = Path.Geom.edgeForCmd(cmd, curpos) # hack to overcome occ bug
|
||||
if path is None:
|
||||
return curpos
|
||||
return path.valueAt(path.LastParameter)
|
||||
|
||||
# get a solid representation of a tool going along path
|
||||
def GetPathSolid(self, tool, cmd, pos):
|
||||
toolPath = PathGeom.edgeForCmd(cmd, pos)
|
||||
toolPath = Path.Geom.edgeForCmd(cmd, pos)
|
||||
startDir = toolPath.tangentAt(0)
|
||||
startDir[2] = 0.0
|
||||
endPos = toolPath.valueAt(toolPath.LastParameter)
|
||||
|
||||
@@ -25,7 +25,6 @@ import FreeCAD
|
||||
from FreeCAD import Vector
|
||||
from PySide import QtCore
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathJob as PathJob
|
||||
import math
|
||||
from numpy import linspace
|
||||
@@ -122,8 +121,8 @@ def horizontalEdgeLoop(obj, edge):
|
||||
loops = [
|
||||
w
|
||||
for w in wires
|
||||
if all(PathGeom.isHorizontal(e) for e in w.Edges)
|
||||
and PathGeom.isHorizontal(Part.Face(w))
|
||||
if all(Path.Geom.isHorizontal(e) for e in w.Edges)
|
||||
and Path.Geom.isHorizontal(Part.Face(w))
|
||||
]
|
||||
if len(loops) == 1:
|
||||
return loops[0]
|
||||
@@ -146,7 +145,7 @@ def horizontalFaceLoop(obj, face, faceList=None):
|
||||
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 any(e.hashCode() in hashes for e in f.Edges) and Path.Geom.isVertical(f)
|
||||
]
|
||||
|
||||
if faceList and not all(f in faces for f in faceList):
|
||||
@@ -161,7 +160,7 @@ def horizontalFaceLoop(obj, face, faceList=None):
|
||||
# trace-backs single edge spikes don't contribute to the bound box
|
||||
uniqueEdges = []
|
||||
for edge in outline.Edges:
|
||||
if any(PathGeom.edgesMatch(edge, e) for e in uniqueEdges):
|
||||
if any(Path.Geom.edgesMatch(edge, e) for e in uniqueEdges):
|
||||
continue
|
||||
uniqueEdges.append(edge)
|
||||
w = Part.Wire(uniqueEdges)
|
||||
@@ -172,10 +171,10 @@ def horizontalFaceLoop(obj, face, faceList=None):
|
||||
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)
|
||||
and Path.Geom.isRoughly(bb1.XMin, bb2.XMin)
|
||||
and Path.Geom.isRoughly(bb1.XMax, bb2.XMax)
|
||||
and Path.Geom.isRoughly(bb1.YMin, bb2.YMin)
|
||||
and Path.Geom.isRoughly(bb1.YMax, bb2.YMax)
|
||||
):
|
||||
return faces
|
||||
return None
|
||||
@@ -721,7 +720,7 @@ class depth_params(object):
|
||||
|
||||
def __filter_roughly_equal_depths(self, depths):
|
||||
"""Depths arrive sorted from largest to smallest, positive to negative.
|
||||
Return unique list of depths, using PathGeom.isRoughly() method to determine
|
||||
Return unique list of depths, using Path.Geom.isRoughly() method to determine
|
||||
if the two values are equal. Only one of two consecutive equals are removed.
|
||||
|
||||
The assumption is that there are not enough consecutively roughly-equal depths
|
||||
@@ -731,7 +730,7 @@ class depth_params(object):
|
||||
depthcopy = sorted(depths) # make a copy and sort low to high
|
||||
keep = [depthcopy[0]]
|
||||
for depth in depthcopy[1:]:
|
||||
if not PathGeom.isRoughly(depth, keep[-1]):
|
||||
if not Path.Geom.isRoughly(depth, keep[-1]):
|
||||
keep.append(depth)
|
||||
keep.reverse() # reverse results back high to low
|
||||
return keep
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
import FreeCAD
|
||||
import Part
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Path
|
||||
import math
|
||||
import unittest
|
||||
|
||||
@@ -73,11 +73,11 @@ class PathTestBase(unittest.TestCase):
|
||||
self.assertCoincide(edge.valueAt(edge.FirstParameter), pt1)
|
||||
self.assertCoincide(edge.valueAt(edge.LastParameter), pt2)
|
||||
ptm = edge.valueAt((edge.LastParameter + edge.FirstParameter) / 2)
|
||||
side = PathGeom.Side.of(pt2 - pt1, ptm - pt1)
|
||||
side = Path.Geom.Side.of(pt2 - pt1, ptm - pt1)
|
||||
if "CW" == direction:
|
||||
self.assertEqual(side, PathGeom.Side.Left)
|
||||
self.assertEqual(side, Path.Geom.Side.Left)
|
||||
else:
|
||||
self.assertEqual(side, PathGeom.Side.Right)
|
||||
self.assertEqual(side, Path.Geom.Side.Right)
|
||||
|
||||
def assertCircle(self, edge, pt, r):
|
||||
"""Verivy that edge is a circle at given location."""
|
||||
@@ -162,7 +162,7 @@ class PathTestBase(unittest.TestCase):
|
||||
e.FirstParameter + (e.LastParameter - e.FirstParameter) * fraction
|
||||
)
|
||||
|
||||
if PathGeom.pointsCoincide(e1.Vertexes[0].Point, e2.Vertexes[0].Point):
|
||||
if Path.Geom.pointsCoincide(e1.Vertexes[0].Point, e2.Vertexes[0].Point):
|
||||
self.assertCoincide(e1.Vertexes[-1].Point, e2.Vertexes[-1].Point)
|
||||
self.assertCoincide(valueAt(e1, 0.10), valueAt(e2, 0.10))
|
||||
self.assertCoincide(valueAt(e1, 0.20), valueAt(e2, 0.20))
|
||||
|
||||
@@ -26,7 +26,6 @@ import FreeCAD
|
||||
import Part
|
||||
import Path.Op.Adaptive as PathAdaptive
|
||||
import PathScripts.PathJob as PathJob
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
from PathTests.PathTestUtils import PathTestBase
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
import Part
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import math
|
||||
|
||||
from FreeCAD import Vector
|
||||
@@ -34,186 +33,186 @@ class TestPathGeom(PathTestBase):
|
||||
|
||||
def test00(self):
|
||||
"""Verify getAngle functionality."""
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(1, 0, 0)), 0)
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(1, 1, 0)), math.pi / 4)
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(0, 1, 0)), math.pi / 2)
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(-1, 1, 0)), 3 * math.pi / 4)
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(-1, 0, 0)), math.pi)
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(-1, -1, 0)), -3 * math.pi / 4)
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(0, -1, 0)), -math.pi / 2)
|
||||
self.assertRoughly(PathGeom.getAngle(Vector(1, -1, 0)), -math.pi / 4)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(1, 0, 0)), 0)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(1, 1, 0)), math.pi / 4)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(0, 1, 0)), math.pi / 2)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(-1, 1, 0)), 3 * math.pi / 4)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(-1, 0, 0)), math.pi)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(-1, -1, 0)), -3 * math.pi / 4)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(0, -1, 0)), -math.pi / 2)
|
||||
self.assertRoughly(Path.Geom.getAngle(Vector(1, -1, 0)), -math.pi / 4)
|
||||
|
||||
def test01(self):
|
||||
"""Verify diffAngle functionality."""
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, +0 * math.pi / 4, "CW") / math.pi, 0 / 4.0
|
||||
Path.Geom.diffAngle(0, +0 * math.pi / 4, "CW") / math.pi, 0 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, +3 * math.pi / 4, "CW") / math.pi, 5 / 4.0
|
||||
Path.Geom.diffAngle(0, +3 * math.pi / 4, "CW") / math.pi, 5 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, -3 * math.pi / 4, "CW") / math.pi, 3 / 4.0
|
||||
Path.Geom.diffAngle(0, -3 * math.pi / 4, "CW") / math.pi, 3 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, +4 * math.pi / 4, "CW") / math.pi, 4 / 4.0
|
||||
Path.Geom.diffAngle(0, +4 * math.pi / 4, "CW") / math.pi, 4 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, +0 * math.pi / 4, "CCW") / math.pi, 0 / 4.0
|
||||
Path.Geom.diffAngle(0, +0 * math.pi / 4, "CCW") / math.pi, 0 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, +3 * math.pi / 4, "CCW") / math.pi, 3 / 4.0
|
||||
Path.Geom.diffAngle(0, +3 * math.pi / 4, "CCW") / math.pi, 3 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, -3 * math.pi / 4, "CCW") / math.pi, 5 / 4.0
|
||||
Path.Geom.diffAngle(0, -3 * math.pi / 4, "CCW") / math.pi, 5 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(0, +4 * math.pi / 4, "CCW") / math.pi, 4 / 4.0
|
||||
Path.Geom.diffAngle(0, +4 * math.pi / 4, "CCW") / math.pi, 4 / 4.0
|
||||
)
|
||||
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(+math.pi / 4, +0 * math.pi / 4, "CW") / math.pi, 1 / 4.0
|
||||
Path.Geom.diffAngle(+math.pi / 4, +0 * math.pi / 4, "CW") / math.pi, 1 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(+math.pi / 4, +3 * math.pi / 4, "CW") / math.pi, 6 / 4.0
|
||||
Path.Geom.diffAngle(+math.pi / 4, +3 * math.pi / 4, "CW") / math.pi, 6 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(+math.pi / 4, -1 * math.pi / 4, "CW") / math.pi, 2 / 4.0
|
||||
Path.Geom.diffAngle(+math.pi / 4, -1 * math.pi / 4, "CW") / math.pi, 2 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(-math.pi / 4, +0 * math.pi / 4, "CW") / math.pi, 7 / 4.0
|
||||
Path.Geom.diffAngle(-math.pi / 4, +0 * math.pi / 4, "CW") / math.pi, 7 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(-math.pi / 4, +3 * math.pi / 4, "CW") / math.pi, 4 / 4.0
|
||||
Path.Geom.diffAngle(-math.pi / 4, +3 * math.pi / 4, "CW") / math.pi, 4 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(-math.pi / 4, -1 * math.pi / 4, "CW") / math.pi, 0 / 4.0
|
||||
Path.Geom.diffAngle(-math.pi / 4, -1 * math.pi / 4, "CW") / math.pi, 0 / 4.0
|
||||
)
|
||||
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(+math.pi / 4, +0 * math.pi / 4, "CCW") / math.pi, 7 / 4.0
|
||||
Path.Geom.diffAngle(+math.pi / 4, +0 * math.pi / 4, "CCW") / math.pi, 7 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(+math.pi / 4, +3 * math.pi / 4, "CCW") / math.pi, 2 / 4.0
|
||||
Path.Geom.diffAngle(+math.pi / 4, +3 * math.pi / 4, "CCW") / math.pi, 2 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(+math.pi / 4, -1 * math.pi / 4, "CCW") / math.pi, 6 / 4.0
|
||||
Path.Geom.diffAngle(+math.pi / 4, -1 * math.pi / 4, "CCW") / math.pi, 6 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(-math.pi / 4, +0 * math.pi / 4, "CCW") / math.pi, 1 / 4.0
|
||||
Path.Geom.diffAngle(-math.pi / 4, +0 * math.pi / 4, "CCW") / math.pi, 1 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(-math.pi / 4, +3 * math.pi / 4, "CCW") / math.pi, 4 / 4.0
|
||||
Path.Geom.diffAngle(-math.pi / 4, +3 * math.pi / 4, "CCW") / math.pi, 4 / 4.0
|
||||
)
|
||||
self.assertRoughly(
|
||||
PathGeom.diffAngle(-math.pi / 4, -1 * math.pi / 4, "CCW") / math.pi, 0 / 4.0
|
||||
Path.Geom.diffAngle(-math.pi / 4, -1 * math.pi / 4, "CCW") / math.pi, 0 / 4.0
|
||||
)
|
||||
|
||||
def test02(self):
|
||||
"""Verify isVertical/isHorizontal for Vector"""
|
||||
self.assertTrue(PathGeom.isVertical(Vector(0, 0, 1)))
|
||||
self.assertTrue(PathGeom.isVertical(Vector(0, 0, -1)))
|
||||
self.assertFalse(PathGeom.isVertical(Vector(1, 0, 1)))
|
||||
self.assertFalse(PathGeom.isVertical(Vector(1, 0, -1)))
|
||||
self.assertTrue(Path.Geom.isVertical(Vector(0, 0, 1)))
|
||||
self.assertTrue(Path.Geom.isVertical(Vector(0, 0, -1)))
|
||||
self.assertFalse(Path.Geom.isVertical(Vector(1, 0, 1)))
|
||||
self.assertFalse(Path.Geom.isVertical(Vector(1, 0, -1)))
|
||||
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(1, 0, 0)))
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(-1, 0, 0)))
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(0, 1, 0)))
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(0, -1, 0)))
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(1, 1, 0)))
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(-1, 1, 0)))
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(1, -1, 0)))
|
||||
self.assertTrue(PathGeom.isHorizontal(Vector(-1, -1, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(1, 0, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(-1, 0, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(0, 1, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(0, -1, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(1, 1, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(-1, 1, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(1, -1, 0)))
|
||||
self.assertTrue(Path.Geom.isHorizontal(Vector(-1, -1, 0)))
|
||||
|
||||
self.assertFalse(PathGeom.isHorizontal(Vector(0, 1, 1)))
|
||||
self.assertFalse(PathGeom.isHorizontal(Vector(0, -1, 1)))
|
||||
self.assertFalse(PathGeom.isHorizontal(Vector(0, 1, -1)))
|
||||
self.assertFalse(PathGeom.isHorizontal(Vector(0, -1, -1)))
|
||||
self.assertFalse(Path.Geom.isHorizontal(Vector(0, 1, 1)))
|
||||
self.assertFalse(Path.Geom.isHorizontal(Vector(0, -1, 1)))
|
||||
self.assertFalse(Path.Geom.isHorizontal(Vector(0, 1, -1)))
|
||||
self.assertFalse(Path.Geom.isHorizontal(Vector(0, -1, -1)))
|
||||
|
||||
def test03(self):
|
||||
"""Verify isVertical/isHorizontal for Edges"""
|
||||
|
||||
# lines
|
||||
self.assertTrue(
|
||||
PathGeom.isVertical(
|
||||
Path.Geom.isVertical(
|
||||
Part.Edge(Part.LineSegment(Vector(-1, -1, -1), Vector(-1, -1, 8)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isVertical(
|
||||
Path.Geom.isVertical(
|
||||
Part.Edge(Part.LineSegment(Vector(-1, -1, -1), Vector(1, -1, 8)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isVertical(
|
||||
Path.Geom.isVertical(
|
||||
Part.Edge(Part.LineSegment(Vector(-1, -1, -1), Vector(-1, 1, 8)))
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.LineSegment(Vector(1, -1, -1), Vector(-1, -1, -1)))
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.LineSegment(Vector(-1, 1, -1), Vector(-1, -1, -1)))
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.LineSegment(Vector(1, 1, -1), Vector(-1, -1, -1)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.LineSegment(Vector(1, -1, -1), Vector(1, -1, 8)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.LineSegment(Vector(-1, 1, -1), Vector(-1, 1, 8)))
|
||||
)
|
||||
)
|
||||
|
||||
# circles
|
||||
self.assertTrue(
|
||||
PathGeom.isVertical(
|
||||
Path.Geom.isVertical(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(0, 1, 0)))
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
PathGeom.isVertical(
|
||||
Path.Geom.isVertical(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(1, 0, 0)))
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
PathGeom.isVertical(
|
||||
Path.Geom.isVertical(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(1, 1, 0)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isVertical(
|
||||
Path.Geom.isVertical(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(1, 1, 1)))
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(0, 0, 1)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(0, 1, 1)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(1, 0, 1)))
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.isHorizontal(
|
||||
Path.Geom.isHorizontal(
|
||||
Part.Edge(Part.makeCircle(4, Vector(), Vector(1, 1, 1)))
|
||||
)
|
||||
)
|
||||
@@ -223,21 +222,21 @@ class TestPathGeom(PathTestBase):
|
||||
# and now I disable the tests because they seem to fail on OCE
|
||||
# bezier = Part.BezierCurve()
|
||||
# bezier.setPoles([Vector(), Vector(1,1,0), Vector(2,1,0), Vector(2,2,0)])
|
||||
# self.assertTrue(PathGeom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(PathGeom.isVertical(Part.Edge(bezier)))
|
||||
# self.assertTrue(Path.Geom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isVertical(Part.Edge(bezier)))
|
||||
# bezier.setPoles([Vector(), Vector(1,1,1), Vector(2,1,0), Vector(2,2,0)])
|
||||
# self.assertFalse(PathGeom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(PathGeom.isVertical(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isVertical(Part.Edge(bezier)))
|
||||
# bezier.setPoles([Vector(), Vector(1,1,0), Vector(2,1,1), Vector(2,2,0)])
|
||||
# self.assertFalse(PathGeom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(PathGeom.isVertical(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isVertical(Part.Edge(bezier)))
|
||||
# bezier.setPoles([Vector(), Vector(1,1,0), Vector(2,1,0), Vector(2,2,1)])
|
||||
# self.assertFalse(PathGeom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(PathGeom.isVertical(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isVertical(Part.Edge(bezier)))
|
||||
#
|
||||
# bezier.setPoles([Vector(), Vector(1,1,1), Vector(2,2,2), Vector(0,0,3)])
|
||||
# self.assertFalse(PathGeom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertTrue(PathGeom.isVertical(Part.Edge(bezier)))
|
||||
# self.assertFalse(Path.Geom.isHorizontal(Part.Edge(bezier)))
|
||||
# self.assertTrue(Path.Geom.isVertical(Part.Edge(bezier)))
|
||||
|
||||
def test04(self):
|
||||
"""Verify isVertical/isHorizontal for faces"""
|
||||
@@ -250,19 +249,19 @@ class TestPathGeom(PathTestBase):
|
||||
xzPlane = Part.makePlane(100, 100, Vector(), Vector(1, 0, 1))
|
||||
yzPlane = Part.makePlane(100, 100, Vector(), Vector(0, 1, 1))
|
||||
|
||||
self.assertTrue(PathGeom.isVertical(xPlane))
|
||||
self.assertTrue(PathGeom.isVertical(yPlane))
|
||||
self.assertFalse(PathGeom.isVertical(zPlane))
|
||||
self.assertTrue(PathGeom.isVertical(xyPlane))
|
||||
self.assertFalse(PathGeom.isVertical(xzPlane))
|
||||
self.assertFalse(PathGeom.isVertical(yzPlane))
|
||||
self.assertTrue(Path.Geom.isVertical(xPlane))
|
||||
self.assertTrue(Path.Geom.isVertical(yPlane))
|
||||
self.assertFalse(Path.Geom.isVertical(zPlane))
|
||||
self.assertTrue(Path.Geom.isVertical(xyPlane))
|
||||
self.assertFalse(Path.Geom.isVertical(xzPlane))
|
||||
self.assertFalse(Path.Geom.isVertical(yzPlane))
|
||||
|
||||
self.assertFalse(PathGeom.isHorizontal(xPlane))
|
||||
self.assertFalse(PathGeom.isHorizontal(yPlane))
|
||||
self.assertTrue(PathGeom.isHorizontal(zPlane))
|
||||
self.assertFalse(PathGeom.isHorizontal(xyPlane))
|
||||
self.assertFalse(PathGeom.isHorizontal(xzPlane))
|
||||
self.assertFalse(PathGeom.isHorizontal(yzPlane))
|
||||
self.assertFalse(Path.Geom.isHorizontal(xPlane))
|
||||
self.assertFalse(Path.Geom.isHorizontal(yPlane))
|
||||
self.assertTrue(Path.Geom.isHorizontal(zPlane))
|
||||
self.assertFalse(Path.Geom.isHorizontal(xyPlane))
|
||||
self.assertFalse(Path.Geom.isHorizontal(xzPlane))
|
||||
self.assertFalse(Path.Geom.isHorizontal(yzPlane))
|
||||
|
||||
# cylinders
|
||||
xCylinder = [
|
||||
@@ -296,92 +295,92 @@ class TestPathGeom(PathTestBase):
|
||||
if type(f.Surface) == Part.Cylinder
|
||||
][0]
|
||||
|
||||
self.assertTrue(PathGeom.isHorizontal(xCylinder))
|
||||
self.assertTrue(PathGeom.isHorizontal(yCylinder))
|
||||
self.assertFalse(PathGeom.isHorizontal(zCylinder))
|
||||
self.assertTrue(PathGeom.isHorizontal(xyCylinder))
|
||||
self.assertFalse(PathGeom.isHorizontal(xzCylinder))
|
||||
self.assertFalse(PathGeom.isHorizontal(yzCylinder))
|
||||
self.assertTrue(Path.Geom.isHorizontal(xCylinder))
|
||||
self.assertTrue(Path.Geom.isHorizontal(yCylinder))
|
||||
self.assertFalse(Path.Geom.isHorizontal(zCylinder))
|
||||
self.assertTrue(Path.Geom.isHorizontal(xyCylinder))
|
||||
self.assertFalse(Path.Geom.isHorizontal(xzCylinder))
|
||||
self.assertFalse(Path.Geom.isHorizontal(yzCylinder))
|
||||
|
||||
def test07(self):
|
||||
"""Verify speed interpolation works for different pitches"""
|
||||
# horizontal
|
||||
self.assertRoughly(
|
||||
100, PathGeom.speedBetweenPoints(Vector(), Vector(1, 1, 0), 100, 50)
|
||||
100, Path.Geom.speedBetweenPoints(Vector(), Vector(1, 1, 0), 100, 50)
|
||||
)
|
||||
self.assertRoughly(
|
||||
100, PathGeom.speedBetweenPoints(Vector(1, 1, 0), Vector(), 100, 50)
|
||||
100, Path.Geom.speedBetweenPoints(Vector(1, 1, 0), Vector(), 100, 50)
|
||||
)
|
||||
# vertical
|
||||
self.assertRoughly(
|
||||
50, PathGeom.speedBetweenPoints(Vector(), Vector(0, 0, 1), 100, 50)
|
||||
50, Path.Geom.speedBetweenPoints(Vector(), Vector(0, 0, 1), 100, 50)
|
||||
)
|
||||
self.assertRoughly(
|
||||
50, PathGeom.speedBetweenPoints(Vector(0, 0, 1), Vector(), 100, 50)
|
||||
50, Path.Geom.speedBetweenPoints(Vector(0, 0, 1), Vector(), 100, 50)
|
||||
)
|
||||
# 45°
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(), Vector(1, 0, 1), 100, 50)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(), Vector(1, 0, 1), 100, 50)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(), Vector(0, 1, 1), 100, 50)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(), Vector(0, 1, 1), 100, 50)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0.707, 0.707, 1), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0.707, 0.707, 1), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(1, 0, 1), Vector(), 100, 50)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(1, 0, 1), Vector(), 100, 50)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(0, 1, 1), Vector(), 100, 50)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(0, 1, 1), Vector(), 100, 50)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75,
|
||||
PathGeom.speedBetweenPoints(Vector(0.707, 0.707, 1), Vector(), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(0.707, 0.707, 1), Vector(), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
# 30°
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0.5774, 0, 1), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0.5774, 0, 1), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0, 0.5774, 1), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0, 0.5774, 1), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(0.5774, 0, 1), Vector(), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(0.5774, 0, 1), Vector(), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(0, 0.5774, 1), Vector(), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(0, 0.5774, 1), Vector(), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
# 60°
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(1, 0, 0.5774), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(1, 0, 0.5774), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0, 1, 0.5774), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0, 1, 0.5774), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(1, 0, 0.5774), Vector(), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(1, 0, 0.5774), Vector(), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(0, 1, 0.5774), Vector(), 100, 50),
|
||||
Path.Geom.speedBetweenPoints(Vector(0, 1, 0.5774), Vector(), 100, 50),
|
||||
0.01,
|
||||
)
|
||||
|
||||
@@ -389,81 +388,81 @@ class TestPathGeom(PathTestBase):
|
||||
"""Verify speed interpolation works for different pitches if vSpeed > hSpeed"""
|
||||
# horizontal
|
||||
self.assertRoughly(
|
||||
50, PathGeom.speedBetweenPoints(Vector(), Vector(1, 1, 0), 50, 100)
|
||||
50, Path.Geom.speedBetweenPoints(Vector(), Vector(1, 1, 0), 50, 100)
|
||||
)
|
||||
self.assertRoughly(
|
||||
50, PathGeom.speedBetweenPoints(Vector(1, 1, 0), Vector(), 50, 100)
|
||||
50, Path.Geom.speedBetweenPoints(Vector(1, 1, 0), Vector(), 50, 100)
|
||||
)
|
||||
# vertical
|
||||
self.assertRoughly(
|
||||
100, PathGeom.speedBetweenPoints(Vector(), Vector(0, 0, 1), 50, 100)
|
||||
100, Path.Geom.speedBetweenPoints(Vector(), Vector(0, 0, 1), 50, 100)
|
||||
)
|
||||
self.assertRoughly(
|
||||
100, PathGeom.speedBetweenPoints(Vector(0, 0, 1), Vector(), 50, 100)
|
||||
100, Path.Geom.speedBetweenPoints(Vector(0, 0, 1), Vector(), 50, 100)
|
||||
)
|
||||
# 45°
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(), Vector(1, 0, 1), 50, 100)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(), Vector(1, 0, 1), 50, 100)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(), Vector(0, 1, 1), 50, 100)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(), Vector(0, 1, 1), 50, 100)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0.707, 0.707, 1), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0.707, 0.707, 1), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(1, 0, 1), Vector(), 50, 100)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(1, 0, 1), Vector(), 50, 100)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75, PathGeom.speedBetweenPoints(Vector(0, 1, 1), Vector(), 50, 100)
|
||||
75, Path.Geom.speedBetweenPoints(Vector(0, 1, 1), Vector(), 50, 100)
|
||||
)
|
||||
self.assertRoughly(
|
||||
75,
|
||||
PathGeom.speedBetweenPoints(Vector(0.707, 0.707, 1), Vector(), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(0.707, 0.707, 1), Vector(), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
# 30°
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0.5774, 0, 1), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0.5774, 0, 1), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0, 0.5774, 1), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0, 0.5774, 1), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(0.5774, 0, 1), Vector(), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(0.5774, 0, 1), Vector(), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
83.33,
|
||||
PathGeom.speedBetweenPoints(Vector(0, 0.5774, 1), Vector(), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(0, 0.5774, 1), Vector(), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
# 60°
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(1, 0, 0.5774), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(1, 0, 0.5774), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(), Vector(0, 1, 0.5774), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(), Vector(0, 1, 0.5774), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(1, 0, 0.5774), Vector(), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(1, 0, 0.5774), Vector(), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
self.assertRoughly(
|
||||
66.66,
|
||||
PathGeom.speedBetweenPoints(Vector(0, 1, 0.5774), Vector(), 50, 100),
|
||||
Path.Geom.speedBetweenPoints(Vector(0, 1, 0.5774), Vector(), 50, 100),
|
||||
0.01,
|
||||
)
|
||||
|
||||
@@ -471,12 +470,12 @@ class TestPathGeom(PathTestBase):
|
||||
"""Verify proper geometry objects for G1 and G01 commands are created."""
|
||||
spt = Vector(1, 2, 3)
|
||||
self.assertLine(
|
||||
PathGeom.edgeForCmd(Path.Command("G1", {"X": 7, "Y": 2, "Z": 3}), spt),
|
||||
Path.Geom.edgeForCmd(Path.Command("G1", {"X": 7, "Y": 2, "Z": 3}), spt),
|
||||
spt,
|
||||
Vector(7, 2, 3),
|
||||
)
|
||||
self.assertLine(
|
||||
PathGeom.edgeForCmd(Path.Command("G01", {"X": 1, "Y": 3, "Z": 5}), spt),
|
||||
Path.Geom.edgeForCmd(Path.Command("G01", {"X": 1, "Y": 3, "Z": 5}), spt),
|
||||
spt,
|
||||
Vector(1, 3, 5),
|
||||
)
|
||||
@@ -486,7 +485,7 @@ class TestPathGeom(PathTestBase):
|
||||
p1 = Vector(0, -1, 2)
|
||||
p2 = Vector(-1, 0, 2)
|
||||
self.assertArc(
|
||||
PathGeom.edgeForCmd(
|
||||
Path.Geom.edgeForCmd(
|
||||
Path.Command(
|
||||
"G2", {"X": p2.x, "Y": p2.y, "Z": p2.z, "I": 0, "J": 1, "K": 0}
|
||||
),
|
||||
@@ -497,7 +496,7 @@ class TestPathGeom(PathTestBase):
|
||||
"CW",
|
||||
)
|
||||
self.assertArc(
|
||||
PathGeom.edgeForCmd(
|
||||
Path.Geom.edgeForCmd(
|
||||
Path.Command(
|
||||
"G3", {"X": p1.x, "Y": p1.y, "z": p1.z, "I": -1, "J": 0, "K": 0}
|
||||
),
|
||||
@@ -514,7 +513,7 @@ class TestPathGeom(PathTestBase):
|
||||
p1 = Vector(0, 1, 0)
|
||||
p2 = Vector(1, 0, 2)
|
||||
self.assertCurve(
|
||||
PathGeom.edgeForCmd(
|
||||
Path.Geom.edgeForCmd(
|
||||
Path.Command(
|
||||
"G2", {"X": p2.x, "Y": p2.y, "Z": p2.z, "I": 0, "J": -1, "K": 1}
|
||||
),
|
||||
@@ -527,7 +526,7 @@ class TestPathGeom(PathTestBase):
|
||||
p1 = Vector(-1, 0, 0)
|
||||
p2 = Vector(0, -1, 2)
|
||||
self.assertCurve(
|
||||
PathGeom.edgeForCmd(
|
||||
Path.Geom.edgeForCmd(
|
||||
Path.Command(
|
||||
"G3", {"X": p2.x, "Y": p2.y, "Z": p2.z, "I": 1, "J": 0, "K": 1}
|
||||
),
|
||||
@@ -542,7 +541,7 @@ class TestPathGeom(PathTestBase):
|
||||
p1 = Vector(0, -1, 2)
|
||||
p2 = Vector(-1, 0, 0)
|
||||
self.assertCurve(
|
||||
PathGeom.edgeForCmd(
|
||||
Path.Geom.edgeForCmd(
|
||||
Path.Command(
|
||||
"G2", {"X": p2.x, "Y": p2.y, "Z": p2.z, "I": 0, "J": 1, "K": -1}
|
||||
),
|
||||
@@ -555,7 +554,7 @@ class TestPathGeom(PathTestBase):
|
||||
p1 = Vector(-1, 0, 2)
|
||||
p2 = Vector(0, -1, 0)
|
||||
self.assertCurve(
|
||||
PathGeom.edgeForCmd(
|
||||
Path.Geom.edgeForCmd(
|
||||
Path.Command(
|
||||
"G3", {"X": p2.x, "Y": p2.y, "Z": p2.z, "I": 1, "J": 0, "K": -1}
|
||||
),
|
||||
@@ -574,7 +573,7 @@ class TestPathGeom(PathTestBase):
|
||||
p4 = Vector(+10, 0, 0)
|
||||
|
||||
def cmds(pa, pb, pc, flip):
|
||||
return PathGeom.cmdsForEdge(Part.Edge(Part.Arc(pa, pb, pc)), flip)[0]
|
||||
return Path.Geom.cmdsForEdge(Part.Edge(Part.Arc(pa, pb, pc)), flip)[0]
|
||||
|
||||
def cmd(g, end, off):
|
||||
return Path.Command(
|
||||
@@ -608,7 +607,7 @@ class TestPathGeom(PathTestBase):
|
||||
|
||||
def cmds(center, radius, up=True):
|
||||
norm = Vector(0, 0, 1) if up else Vector(0, 0, -1)
|
||||
return PathGeom.cmdsForEdge(Part.Edge(Part.Circle(center, norm, radius)))[0]
|
||||
return Path.Geom.cmdsForEdge(Part.Edge(Part.Circle(center, norm, radius)))[0]
|
||||
|
||||
def cmd(g, end, off):
|
||||
return Path.Command(
|
||||
@@ -633,7 +632,7 @@ class TestPathGeom(PathTestBase):
|
||||
def test42(self):
|
||||
"""Verify ellipsis results in a proper segmentation of G1 commands."""
|
||||
ellipse = Part.Edge(Part.Ellipse())
|
||||
cmds = PathGeom.cmdsForEdge(ellipse)
|
||||
cmds = Path.Geom.cmdsForEdge(ellipse)
|
||||
# let's make sure all commands are G1 and there are more than 20 of those
|
||||
self.assertGreater(len(cmds), 20)
|
||||
self.assertTrue(all([cmd.Name == "G1" for cmd in cmds]))
|
||||
@@ -646,16 +645,16 @@ class TestPathGeom(PathTestBase):
|
||||
commands.append(Path.Command("G0", {"X": 0}))
|
||||
commands.append(Path.Command("G1", {"Y": 0}))
|
||||
|
||||
wire, rapid = PathGeom.wireForPath(Path.Path(commands))
|
||||
wire, rapid = Path.Geom.wireForPath(Path.Path(commands))
|
||||
self.assertEqual(len(wire.Edges), 4)
|
||||
self.assertLine(wire.Edges[0], Vector(0, 0, 0), Vector(1, 0, 0))
|
||||
self.assertLine(wire.Edges[1], Vector(1, 0, 0), Vector(1, 1, 0))
|
||||
self.assertLine(wire.Edges[2], Vector(1, 1, 0), Vector(0, 1, 0))
|
||||
self.assertLine(wire.Edges[3], Vector(0, 1, 0), Vector(0, 0, 0))
|
||||
self.assertEqual(len(rapid), 1)
|
||||
self.assertTrue(PathGeom.edgesMatch(rapid[0], wire.Edges[2]))
|
||||
self.assertTrue(Path.Geom.edgesMatch(rapid[0], wire.Edges[2]))
|
||||
|
||||
wires = PathGeom.wiresForPath(Path.Path(commands))
|
||||
wires = Path.Geom.wiresForPath(Path.Path(commands))
|
||||
self.assertEqual(len(wires), 2)
|
||||
self.assertEqual(len(wires[0].Edges), 2)
|
||||
self.assertLine(wires[0].Edges[0], Vector(0, 0, 0), Vector(1, 0, 0))
|
||||
@@ -669,15 +668,15 @@ class TestPathGeom(PathTestBase):
|
||||
p2 = Vector(0, 0, 0)
|
||||
p3 = Vector(10, 10, 0)
|
||||
|
||||
e = PathGeom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 0, 2)
|
||||
e = Path.Geom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 0, 2)
|
||||
self.assertCurve(e, p1, p2 + Vector(0, 0, 1), p3 + Vector(0, 0, 2))
|
||||
|
||||
e = PathGeom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 3, 7)
|
||||
e = Path.Geom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 3, 7)
|
||||
self.assertCurve(
|
||||
e, p1 + Vector(0, 0, 3), p2 + Vector(0, 0, 5), p3 + Vector(0, 0, 7)
|
||||
)
|
||||
|
||||
e = PathGeom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 9, 1)
|
||||
e = Path.Geom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 9, 1)
|
||||
self.assertCurve(
|
||||
e, p1 + Vector(0, 0, 9), p2 + Vector(0, 0, 5), p3 + Vector(0, 0, 1)
|
||||
)
|
||||
@@ -687,16 +686,16 @@ class TestPathGeom(PathTestBase):
|
||||
p12 = p2 + dz
|
||||
p13 = p3 + dz
|
||||
|
||||
e = PathGeom.arcToHelix(Part.Edge(Part.Arc(p11, p12, p13)), 0, 8)
|
||||
e = Path.Geom.arcToHelix(Part.Edge(Part.Arc(p11, p12, p13)), 0, 8)
|
||||
self.assertCurve(e, p1, p2 + Vector(0, 0, 4), p3 + Vector(0, 0, 8))
|
||||
|
||||
e = PathGeom.arcToHelix(Part.Edge(Part.Arc(p11, p12, p13)), 2, -2)
|
||||
e = Path.Geom.arcToHelix(Part.Edge(Part.Arc(p11, p12, p13)), 2, -2)
|
||||
self.assertCurve(e, p1 + Vector(0, 0, 2), p2, p3 + Vector(0, 0, -2))
|
||||
|
||||
p1 = Vector(10, -10, 1)
|
||||
p2 = Vector(10 - 10 * math.sin(math.pi / 4), -10 * math.cos(math.pi / 4), 1)
|
||||
p3 = Vector(0, 0, 1)
|
||||
e = PathGeom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 0, 5)
|
||||
e = Path.Geom.arcToHelix(Part.Edge(Part.Arc(p1, p2, p3)), 0, 5)
|
||||
self.assertCurve(
|
||||
e, Vector(10, -10, 0), Vector(p2.x, p2.y, 2.5), Vector(0, 0, 5)
|
||||
)
|
||||
@@ -713,7 +712,7 @@ class TestPathGeom(PathTestBase):
|
||||
p12 = Vector(10 - o, -o, 0)
|
||||
p23 = Vector(10 - o, +o, 0)
|
||||
|
||||
e = PathGeom.splitArcAt(arc, p2)
|
||||
e = Path.Geom.splitArcAt(arc, p2)
|
||||
self.assertCurve(e[0], p1, p12, p2)
|
||||
self.assertCurve(e[1], p2, p23, p3)
|
||||
|
||||
@@ -724,7 +723,7 @@ class TestPathGeom(PathTestBase):
|
||||
10 - 10 * math.sin(5 * math.pi / 8), -10 * math.cos(5 * math.pi / 8), 0
|
||||
)
|
||||
|
||||
e = PathGeom.splitArcAt(arc, p12)
|
||||
e = Path.Geom.splitArcAt(arc, p12)
|
||||
self.assertCurve(e[0], p1, p34, p12)
|
||||
self.assertCurve(e[1], p12, p45, p3)
|
||||
|
||||
@@ -732,7 +731,7 @@ class TestPathGeom(PathTestBase):
|
||||
"""Verify splitEdgeAt."""
|
||||
|
||||
# split a line segment
|
||||
e = PathGeom.splitEdgeAt(
|
||||
e = Path.Geom.splitEdgeAt(
|
||||
Part.Edge(Part.LineSegment(Vector(), Vector(2, 4, 6))), Vector(1, 2, 3)
|
||||
)
|
||||
self.assertLine(e[0], Vector(), Vector(1, 2, 3))
|
||||
@@ -743,7 +742,7 @@ class TestPathGeom(PathTestBase):
|
||||
p2 = Vector(0, 0, 1)
|
||||
p3 = Vector(10, 10, 1)
|
||||
arc = Part.Edge(Part.Arc(p1, p2, p3))
|
||||
e = PathGeom.splitEdgeAt(arc, p2)
|
||||
e = Path.Geom.splitEdgeAt(arc, p2)
|
||||
o = 10 * math.sin(math.pi / 4)
|
||||
p12 = Vector(10 - o, -o, 1)
|
||||
p23 = Vector(10 - o, +o, 1)
|
||||
@@ -754,10 +753,10 @@ class TestPathGeom(PathTestBase):
|
||||
p1 = Vector(10, -10, 0)
|
||||
p2 = Vector(0, 0, 5)
|
||||
p3 = Vector(10, 10, 10)
|
||||
h = PathGeom.arcToHelix(arc, 0, 10)
|
||||
h = Path.Geom.arcToHelix(arc, 0, 10)
|
||||
self.assertCurve(h, p1, p2, p3)
|
||||
|
||||
e = PathGeom.splitEdgeAt(h, p2)
|
||||
e = Path.Geom.splitEdgeAt(h, p2)
|
||||
o = 10 * math.sin(math.pi / 4)
|
||||
p12 = Vector(10 - o, -o, 2.5)
|
||||
p23 = Vector(10 - o, +o, 7.5)
|
||||
@@ -774,7 +773,7 @@ class TestPathGeom(PathTestBase):
|
||||
ac = arc.Curve.Center
|
||||
|
||||
s = Vector(434.54, 378.26, 1)
|
||||
head, tail = PathGeom.splitEdgeAt(arc, s)
|
||||
head, tail = Path.Geom.splitEdgeAt(arc, s)
|
||||
|
||||
# make sure the arcs connect as they should
|
||||
self.assertCoincide(
|
||||
@@ -802,59 +801,59 @@ class TestPathGeom(PathTestBase):
|
||||
def test70(self):
|
||||
"""Flip a line."""
|
||||
edge = Part.Edge(Part.Line(Vector(0, 0, 0), Vector(3, 2, 1)))
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
edge = Part.Edge(Part.Line(Vector(0, 0, 0), Vector(-3, -2, -1)))
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
def test71(self):
|
||||
"""Flip a line segment."""
|
||||
edge = Part.Edge(Part.LineSegment(Vector(0, 0, 0), Vector(3, 2, 1)))
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
edge = Part.Edge(Part.LineSegment(Vector(4, 2, 1), Vector(-3, -7, 9)))
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
edge = Part.makeLine(Vector(1, 0, 3), Vector(3, 2, 1))
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
def test72(self):
|
||||
"""Flip a circle"""
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, 1))
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, -1))
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
def test73(self):
|
||||
"""Flip an arc"""
|
||||
# make sure all 4 quadrants work
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, 1), 45, 90)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, 1), 100, 170)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, 1), 200, 250)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, 1), 300, 340)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
# and the other way around too
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, -1), 45, 90)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, -1), 100, 170)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, -1), 200, 250)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, -1), 300, 340)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
def test74(self):
|
||||
"""Flip a rotated arc"""
|
||||
# oh yes ...
|
||||
edge = Part.makeCircle(3, Vector(1, 3, 2), Vector(0, 0, 1), 45, 90)
|
||||
edge.rotate(edge.Curve.Center, Vector(0, 0, 1), -90)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
def test75(self):
|
||||
"""Flip a B-spline"""
|
||||
@@ -863,7 +862,7 @@ class TestPathGeom(PathTestBase):
|
||||
[Vector(1, 2, 3), Vector(-3, 0, 7), Vector(-3, 1, 9), Vector(1, 3, 5)]
|
||||
)
|
||||
edge = Part.Edge(spline)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
edge = Part.Edge(
|
||||
Part.BSplineCurve(
|
||||
@@ -876,7 +875,7 @@ class TestPathGeom(PathTestBase):
|
||||
weights=[2, 3, 5, 7],
|
||||
)
|
||||
)
|
||||
self.assertEdgeShapesMatch(edge, PathGeom.flipEdge(edge))
|
||||
self.assertEdgeShapesMatch(edge, Path.Geom.flipEdge(edge))
|
||||
|
||||
def test76(self):
|
||||
"""Flip an offset wire"""
|
||||
@@ -896,7 +895,7 @@ class TestPathGeom(PathTestBase):
|
||||
e2 = Part.Edge(Part.LineSegment(Vector(0, -7, 0), Vector(-8, 4, 0)))
|
||||
w0 = Part.Wire([e0, e1, e2])
|
||||
w1 = w0.makeOffset2D(1)
|
||||
w2 = PathGeom.flipWire(w1)
|
||||
w2 = Path.Geom.flipWire(w1)
|
||||
# do some sanity checks
|
||||
self.assertTrue(w2.isValid())
|
||||
self.assertTrue(w2.isClosed())
|
||||
|
||||
@@ -23,11 +23,10 @@
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
import Path.Base.FeedRate as PathFeedRate
|
||||
import Path.Base.MachineState as PathMachineState
|
||||
import Path.Tool.Bit as PathToolBit
|
||||
import Path.Tool.Controller as PathToolController
|
||||
import PathFeedRate
|
||||
import PathMachineState
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
|
||||
from PathTests.PathTestUtils import PathTestBase
|
||||
@@ -134,7 +133,7 @@ class TestPathHelpers(PathTestBase):
|
||||
self.assertTrue(len(results) == 2)
|
||||
e1 = results[0]
|
||||
self.assertTrue(isinstance(e1.Curve, Part.Circle))
|
||||
self.assertTrue(PathGeom.pointsCoincide(edge.Curve.Location, e1.Curve.Location))
|
||||
self.assertTrue(Path.Geom.pointsCoincide(edge.Curve.Location, e1.Curve.Location))
|
||||
self.assertTrue(edge.Curve.Radius == e1.Curve.Radius)
|
||||
|
||||
# filter a 180 degree arc
|
||||
|
||||
@@ -24,7 +24,6 @@ import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
import Path.Op.Util as PathOpUtil
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathTests.PathTestUtils as PathTestUtils
|
||||
import math
|
||||
|
||||
@@ -208,14 +207,14 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
w
|
||||
for w in obj.Shape.Wires
|
||||
if 1 == len(w.Edges)
|
||||
and PathGeom.isRoughly(0, w.Edges[0].Vertexes[0].Point.z)
|
||||
and Path.Geom.isRoughly(0, w.Edges[0].Vertexes[0].Point.z)
|
||||
]
|
||||
self.assertEqual(2, len(wires))
|
||||
w = wires[1] if wires[0].BoundBox.isInside(wires[1].BoundBox) else wires[0]
|
||||
|
||||
self.assertRoughly(10, w.Edges[0].Curve.Radius)
|
||||
# make sure there is a placement and I didn't mess up the model
|
||||
self.assertFalse(PathGeom.pointsCoincide(Vector(), w.Edges[0].Placement.Base))
|
||||
self.assertFalse(Path.Geom.pointsCoincide(Vector(), w.Edges[0].Placement.Base))
|
||||
|
||||
wire = PathOpUtil.offsetWire(w, obj.Shape, 2, True)
|
||||
self.assertIsNotNone(wire)
|
||||
@@ -232,14 +231,14 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
w
|
||||
for w in obj.Shape.Wires
|
||||
if 1 == len(w.Edges)
|
||||
and PathGeom.isRoughly(0, w.Edges[0].Vertexes[0].Point.z)
|
||||
and Path.Geom.isRoughly(0, w.Edges[0].Vertexes[0].Point.z)
|
||||
]
|
||||
self.assertEqual(2, len(wires))
|
||||
w = wires[0] if wires[0].BoundBox.isInside(wires[1].BoundBox) else wires[1]
|
||||
|
||||
self.assertRoughly(20, w.Edges[0].Curve.Radius)
|
||||
# make sure there is a placement and I didn't mess up the model
|
||||
self.assertFalse(PathGeom.pointsCoincide(Vector(), w.Edges[0].Placement.Base))
|
||||
self.assertFalse(Path.Geom.pointsCoincide(Vector(), w.Edges[0].Placement.Base))
|
||||
|
||||
wire = PathOpUtil.offsetWire(w, obj.Shape, 2, True)
|
||||
self.assertIsNotNone(wire)
|
||||
@@ -335,16 +334,16 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
begin = e.Vertexes[0].Point
|
||||
end = e.Vertexes[1].Point
|
||||
v = end - begin
|
||||
angle = PathGeom.getAngle(v)
|
||||
if PathGeom.isRoughly(0, angle) or PathGeom.isRoughly(
|
||||
angle = Path.Geom.getAngle(v)
|
||||
if Path.Geom.isRoughly(0, angle) or Path.Geom.isRoughly(
|
||||
math.pi, math.fabs(angle)
|
||||
):
|
||||
if lastAngle:
|
||||
self.assertRoughly(-refAngle, lastAngle)
|
||||
elif PathGeom.isRoughly(+refAngle, angle):
|
||||
elif Path.Geom.isRoughly(+refAngle, angle):
|
||||
if lastAngle:
|
||||
self.assertRoughly(math.pi, math.fabs(lastAngle))
|
||||
elif PathGeom.isRoughly(-refAngle, angle):
|
||||
elif Path.Geom.isRoughly(-refAngle, angle):
|
||||
if lastAngle:
|
||||
self.assertRoughly(+refAngle, lastAngle)
|
||||
else:
|
||||
@@ -385,9 +384,9 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
)
|
||||
for e in wire.Edges:
|
||||
if Part.Line == type(e.Curve):
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
self.assertEqual(40, e.Length)
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
self.assertEqual(60, e.Length)
|
||||
if Part.Circle == type(e.Curve):
|
||||
self.assertRoughly(3, e.Curve.Radius)
|
||||
@@ -405,9 +404,9 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
)
|
||||
for e in wire.Edges:
|
||||
if Part.Line == type(e.Curve):
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
self.assertEqual(40, e.Length)
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
self.assertEqual(60, e.Length)
|
||||
if Part.Circle == type(e.Curve):
|
||||
self.assertRoughly(3, e.Curve.Radius)
|
||||
@@ -512,9 +511,9 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
self.assertEqual(4, len(wire.Edges))
|
||||
self.assertEqual(4, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
||||
for e in wire.Edges:
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
self.assertRoughly(34, e.Length)
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
self.assertRoughly(54, e.Length)
|
||||
self.assertFalse(PathOpUtil.isWireClockwise(wire))
|
||||
|
||||
@@ -525,9 +524,9 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
self.assertEqual(4, len(wire.Edges))
|
||||
self.assertEqual(4, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
||||
for e in wire.Edges:
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.x, e.Vertexes[1].Point.x):
|
||||
self.assertRoughly(34, e.Length)
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y):
|
||||
self.assertRoughly(54, e.Length)
|
||||
self.assertTrue(PathOpUtil.isWireClockwise(wire))
|
||||
|
||||
@@ -601,7 +600,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
hEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
|
||||
x = length / 2
|
||||
@@ -620,7 +619,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
self.assertCoincide(Vector(-x, y, 0), wire.Edges[0].Vertexes[1].Point)
|
||||
|
||||
# make sure we get the same result even if the edge is oriented the other way
|
||||
edge = PathGeom.flipEdge(edge)
|
||||
edge = Path.Geom.flipEdge(edge)
|
||||
wire = PathOpUtil.offsetWire(Part.Wire([edge]), obj.Shape, 5, True)
|
||||
self.assertEqual(1, len(wire.Edges))
|
||||
|
||||
@@ -640,7 +639,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
hEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
|
||||
x = length / 2
|
||||
@@ -658,7 +657,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
self.assertCoincide(Vector(+x, y, 0), wire.Edges[0].Vertexes[1].Point)
|
||||
|
||||
# make sure we get the same result on a reversed edge
|
||||
edge = PathGeom.flipEdge(edge)
|
||||
edge = Path.Geom.flipEdge(edge)
|
||||
wire = PathOpUtil.offsetWire(Part.Wire([edge]), obj.Shape, 5, False)
|
||||
self.assertEqual(1, len(wire.Edges))
|
||||
|
||||
@@ -678,7 +677,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
lEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if not PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if not Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
self.assertEqual(2, len(lEdges))
|
||||
|
||||
@@ -721,11 +720,11 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
lEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if not PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if not Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
self.assertEqual(2, len(lEdges))
|
||||
|
||||
w = PathGeom.flipWire(Part.Wire(lEdges))
|
||||
w = Path.Geom.flipWire(Part.Wire(lEdges))
|
||||
wire = PathOpUtil.offsetWire(w, obj.Shape, 2, True)
|
||||
|
||||
x = length / 2 + 2 * math.cos(math.pi / 6)
|
||||
@@ -765,7 +764,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
hEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
|
||||
x = length / 2
|
||||
@@ -784,7 +783,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
self.assertCoincide(Vector(+x, y, 0), wire.Edges[0].Vertexes[1].Point)
|
||||
|
||||
# make sure we get the same result even if the edge is oriented the other way
|
||||
edge = PathGeom.flipEdge(edge)
|
||||
edge = Path.Geom.flipEdge(edge)
|
||||
wire = PathOpUtil.offsetWire(Part.Wire([edge]), obj.Shape, 2, True)
|
||||
self.assertEqual(1, len(wire.Edges))
|
||||
|
||||
@@ -804,7 +803,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
hEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
|
||||
x = length / 2
|
||||
@@ -823,7 +822,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
self.assertCoincide(Vector(-x, y, 0), wire.Edges[0].Vertexes[1].Point)
|
||||
|
||||
# make sure we get the same result even if the edge is oriented the other way
|
||||
edge = PathGeom.flipEdge(edge)
|
||||
edge = Path.Geom.flipEdge(edge)
|
||||
wire = PathOpUtil.offsetWire(Part.Wire([edge]), obj.Shape, 2, False)
|
||||
self.assertEqual(1, len(wire.Edges))
|
||||
|
||||
@@ -841,7 +840,7 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
lEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if not PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if not Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
self.assertEqual(2, len(lEdges))
|
||||
|
||||
@@ -878,11 +877,11 @@ class TestPathOpUtil(PathTestUtils.PathTestBase):
|
||||
lEdges = [
|
||||
e
|
||||
for e in w.Edges
|
||||
if not PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
if not Path.Geom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)
|
||||
]
|
||||
self.assertEqual(2, len(lEdges))
|
||||
|
||||
w = PathGeom.flipWire(Part.Wire(lEdges))
|
||||
w = Path.Geom.flipWire(Part.Wire(lEdges))
|
||||
wire = PathOpUtil.offsetWire(w, obj.Shape, 2, True)
|
||||
|
||||
x = length / 2 - 2 * math.cos(math.pi / 6)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import PathScripts.PathPropertyBag as PathPropertyBag
|
||||
import Path.Base.PropertyBag as PathPropertyBag
|
||||
import PathTests.PathTestUtils as PathTestUtils
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Path
|
||||
import Path.Op.ThreadMilling as PathThreadMilling
|
||||
import math
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import Generators.threadmilling_generator as threadmilling
|
||||
import math
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import Path.Base.Util as PathUtil
|
||||
import TestSketcherApp
|
||||
|
||||
from PathTests.PathTestUtils import PathTestBase
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
import FreeCAD
|
||||
import Path.Op.Vcarve as PathVcarve
|
||||
import Path.Tool.Bit as PathToolBit
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import math
|
||||
|
||||
from PathTests.PathTestUtils import PathTestBase
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path
|
||||
import PathScripts.PathGeom as PathGeom
|
||||
import PathTests.PathTestUtils as PathTestUtils
|
||||
|
||||
vd = None
|
||||
@@ -110,7 +109,7 @@ class TestPathVoronoi(PathTestUtils.PathTestBase):
|
||||
e = e0.toShape()
|
||||
self.assertTrue(type(e.Curve) == Part.LineSegment or type(e.Curve) == Part.Line)
|
||||
self.assertFalse(
|
||||
PathGeom.pointsCoincide(
|
||||
Path.Geom.pointsCoincide(
|
||||
e.valueAt(e.FirstParameter), e.valueAt(e.LastParameter)
|
||||
)
|
||||
)
|
||||
@@ -127,7 +126,7 @@ class TestPathVoronoi(PathTestUtils.PathTestBase):
|
||||
e = e0.toShape(13.7)
|
||||
self.assertTrue(type(e.Curve) == Part.LineSegment or type(e.Curve) == Part.Line)
|
||||
self.assertFalse(
|
||||
PathGeom.pointsCoincide(
|
||||
Path.Geom.pointsCoincide(
|
||||
e.valueAt(e.FirstParameter), e.valueAt(e.LastParameter)
|
||||
)
|
||||
)
|
||||
@@ -144,7 +143,7 @@ class TestPathVoronoi(PathTestUtils.PathTestBase):
|
||||
e = e0.toShape(2.37, 5.14)
|
||||
self.assertTrue(type(e.Curve) == Part.LineSegment or type(e.Curve) == Part.Line)
|
||||
self.assertFalse(
|
||||
PathGeom.pointsCoincide(
|
||||
Path.Geom.pointsCoincide(
|
||||
e.valueAt(e.FirstParameter), e.valueAt(e.LastParameter)
|
||||
)
|
||||
)
|
||||
@@ -163,7 +162,7 @@ class TestPathVoronoi(PathTestUtils.PathTestBase):
|
||||
type(e.Curve) == Part.Parabola or type(e.Curve) == Part.BSplineCurve
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.pointsCoincide(
|
||||
Path.Geom.pointsCoincide(
|
||||
e.valueAt(e.FirstParameter), e.valueAt(e.LastParameter)
|
||||
)
|
||||
)
|
||||
@@ -182,7 +181,7 @@ class TestPathVoronoi(PathTestUtils.PathTestBase):
|
||||
type(e.Curve) == Part.Parabola or type(e.Curve) == Part.BSplineCurve
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.pointsCoincide(
|
||||
Path.Geom.pointsCoincide(
|
||||
e.valueAt(e.FirstParameter), e.valueAt(e.LastParameter)
|
||||
)
|
||||
)
|
||||
@@ -201,7 +200,7 @@ class TestPathVoronoi(PathTestUtils.PathTestBase):
|
||||
type(e.Curve) == Part.Parabola or type(e.Curve) == Part.BSplineCurve
|
||||
)
|
||||
self.assertFalse(
|
||||
PathGeom.pointsCoincide(
|
||||
Path.Geom.pointsCoincide(
|
||||
e.valueAt(e.FirstParameter), e.valueAt(e.LastParameter)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -93,8 +93,8 @@ if args.freecad:
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import PathScripts.PathPropertyBag as PathPropertyBag
|
||||
import PathScripts.PathUtil as PathUtil
|
||||
import Path.Base.PropertyBag as PathPropertyBag
|
||||
import Path.Base.Util as PathUtil
|
||||
|
||||
set_var = None
|
||||
set_val = None
|
||||
|
||||
Reference in New Issue
Block a user