|
|
|
|
@@ -26,7 +26,7 @@ import FreeCAD
|
|
|
|
|
import Part
|
|
|
|
|
import Path
|
|
|
|
|
import PathScripts.PathGeom as PathGeom
|
|
|
|
|
import PathScripts.PathGeomOp as PathGeomOp
|
|
|
|
|
import PathScripts.PathOpTools as PathOpTools
|
|
|
|
|
import PathScripts.PathLog as PathLog
|
|
|
|
|
import PathTests.PathTestUtils as PathTestUtils
|
|
|
|
|
import math
|
|
|
|
|
@@ -74,7 +74,7 @@ def makeWire(pts):
|
|
|
|
|
return Part.Wire(edges)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
class TestPathOpTools(PathTestUtils.PathTestBase):
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def setUpClass(cls):
|
|
|
|
|
@@ -107,13 +107,13 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
small = getWireInside(obj)
|
|
|
|
|
self.assertRoughly(10, small.Edges[0].Curve.Radius)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(small, obj.Shape, 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(small, obj.Shape, 3, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
self.assertRoughly(7, wire.Edges[0].Curve.Radius)
|
|
|
|
|
self.assertCoincide(Vector(0, 0, 1), wire.Edges[0].Curve.Axis)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(small, obj.Shape, 9.9, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(small, obj.Shape, 9.9, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
self.assertRoughly(0.1, wire.Edges[0].Curve.Radius)
|
|
|
|
|
@@ -125,10 +125,10 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
|
|
|
|
|
small = getWireInside(obj)
|
|
|
|
|
self.assertRoughly(10, small.Edges[0].Curve.Radius)
|
|
|
|
|
wire = PathGeomOp.offsetWire(small, obj.Shape, 10, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(small, obj.Shape, 10, True)
|
|
|
|
|
self.assertIsNone(wire)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(small, obj.Shape, 15, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(small, obj.Shape, 15, True)
|
|
|
|
|
self.assertIsNone(wire)
|
|
|
|
|
|
|
|
|
|
def test03(self):
|
|
|
|
|
@@ -138,13 +138,13 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
big = getWireOutside(obj)
|
|
|
|
|
self.assertRoughly(20, big.Edges[0].Curve.Radius)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(big, obj.Shape, 10, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(big, obj.Shape, 10, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
self.assertRoughly(30, wire.Edges[0].Curve.Radius)
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), wire.Edges[0].Curve.Axis)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(big, obj.Shape, 20, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(big, obj.Shape, 20, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
self.assertRoughly(40, wire.Edges[0].Curve.Radius)
|
|
|
|
|
@@ -162,7 +162,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
# make sure there is a placement and I didn't mess up the model
|
|
|
|
|
self.assertFalse(PathGeom.pointsCoincide(Vector(), w.Edges[0].Placement.Base))
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
self.assertRoughly(8, wire.Edges[0].Curve.Radius)
|
|
|
|
|
@@ -181,7 +181,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
# make sure there is a placement and I didn't mess up the model
|
|
|
|
|
self.assertFalse(PathGeom.pointsCoincide(Vector(), w.Edges[0].Placement.Base))
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
self.assertRoughly(22, wire.Edges[0].Curve.Radius)
|
|
|
|
|
@@ -198,7 +198,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
x = 10 * math.cos(math.pi/6)
|
|
|
|
|
self.assertLines(small.Edges, False, [Vector(0, y, 0), Vector(-x, -y/2, 0), Vector(x, -y/2, 0), Vector(0, y, 0)])
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(small, obj.Shape, 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(small, obj.Shape, 3, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(3, len(wire.Edges))
|
|
|
|
|
self.assertTrue(wire.isClosed())
|
|
|
|
|
@@ -217,7 +217,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
y = 10
|
|
|
|
|
x = 10 * math.cos(math.pi/6)
|
|
|
|
|
self.assertLines(small.Edges, False, [Vector(0, y, 0), Vector(-x, -y/2, 0), Vector(x, -y/2, 0), Vector(0, y, 0)])
|
|
|
|
|
wire = PathGeomOp.offsetWire(small, obj.Shape, 5, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(small, obj.Shape, 5, True)
|
|
|
|
|
self.assertIsNone(wire)
|
|
|
|
|
|
|
|
|
|
def test12(self):
|
|
|
|
|
@@ -230,7 +230,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
x = 20 * math.cos(math.pi/6)
|
|
|
|
|
self.assertLines(big.Edges, False, [Vector(0, y, 0), Vector(-x, -y/2, 0), Vector(x, -y/2, 0), Vector(0, y, 0)])
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(big, obj.Shape, 5, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(big, obj.Shape, 5, True)
|
|
|
|
|
self.assertIsNotNone(wire)
|
|
|
|
|
self.assertEqual(6, len(wire.Edges))
|
|
|
|
|
lastAngle = None
|
|
|
|
|
@@ -264,7 +264,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a cylinder.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('circle-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
edge = wire.Edges[0]
|
|
|
|
|
self.assertCoincide(Vector(), edge.Curve.Center)
|
|
|
|
|
@@ -272,7 +272,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertRoughly(33, edge.Curve.Radius)
|
|
|
|
|
|
|
|
|
|
# the other way around everything's the same except the axis is negative
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
edge = wire.Edges[0]
|
|
|
|
|
self.assertCoincide(Vector(), edge.Curve.Center)
|
|
|
|
|
@@ -284,7 +284,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a box.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('square-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
self.assertEqual(8, len(wire.Edges))
|
|
|
|
|
self.assertEqual(4, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(4, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -299,7 +299,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), e.Curve.Axis)
|
|
|
|
|
|
|
|
|
|
# change offset orientation
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
self.assertEqual(8, len(wire.Edges))
|
|
|
|
|
self.assertEqual(4, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(4, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -318,7 +318,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a triangle.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('triangle-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
self.assertEqual(6, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -331,7 +331,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), e.Curve.Axis)
|
|
|
|
|
|
|
|
|
|
# change offset orientation
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
self.assertEqual(6, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -346,7 +346,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a shape.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('shape-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, True)
|
|
|
|
|
self.assertEqual(6, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -360,7 +360,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), e.Curve.Axis)
|
|
|
|
|
|
|
|
|
|
# change offset orientation
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getPositiveShape(obj), 3, False)
|
|
|
|
|
self.assertEqual(6, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -375,7 +375,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a cylindrical hole.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('circle-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
edge = wire.Edges[0]
|
|
|
|
|
self.assertCoincide(Vector(), edge.Curve.Center)
|
|
|
|
|
@@ -383,7 +383,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertRoughly(27, edge.Curve.Radius)
|
|
|
|
|
|
|
|
|
|
# the other way around everything's the same except the axis is negative
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
edge = wire.Edges[0]
|
|
|
|
|
self.assertCoincide(Vector(), edge.Curve.Center)
|
|
|
|
|
@@ -395,7 +395,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a square hole.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('square-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
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:
|
|
|
|
|
@@ -405,7 +405,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertRoughly(54, e.Length)
|
|
|
|
|
|
|
|
|
|
# change offset orientation
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
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:
|
|
|
|
|
@@ -419,7 +419,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a triangular holee.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('triangle-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
self.assertEqual(3, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
length = 48 * math.sin(math.radians(60))
|
|
|
|
|
@@ -429,7 +429,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), f.Surface.Axis)
|
|
|
|
|
|
|
|
|
|
# change offset orientation
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
self.assertEqual(3, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
for e in wire.Edges:
|
|
|
|
|
@@ -441,7 +441,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
'''Check offsetting a shape hole.'''
|
|
|
|
|
obj = doc.getObjectsByLabel('shape-cut')[0]
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, True)
|
|
|
|
|
self.assertEqual(6, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -455,7 +455,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), e.Curve.Axis)
|
|
|
|
|
|
|
|
|
|
# change offset orientation
|
|
|
|
|
wire = PathGeomOp.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(getWire(obj.Tool), getNegativeShape(obj), 3, False)
|
|
|
|
|
self.assertEqual(6, len(wire.Edges))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Line == type(e.Curve)]))
|
|
|
|
|
self.assertEqual(3, len([e for e in wire.Edges if Part.Circle == type(e.Curve)]))
|
|
|
|
|
@@ -487,7 +487,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), edge.Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), edge.Vertexes[1].Point)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 5, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 5, True)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
y = y - 5
|
|
|
|
|
@@ -496,7 +496,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
|
|
|
|
|
# make sure we get the same result even if the edge is oriented the other way
|
|
|
|
|
edge = PathGeom.flipEdge(edge)
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 5, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 5, True)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
@@ -521,7 +521,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), edge.Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), edge.Vertexes[1].Point)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 5, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 5, False)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
y = y - 5
|
|
|
|
|
@@ -530,7 +530,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
|
|
|
|
|
# make sure we get the same result on a reversed edge
|
|
|
|
|
edge = PathGeom.flipEdge(edge)
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 5, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 5, False)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
@@ -547,7 +547,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
lEdges = [e for e in w.Edges if not PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)]
|
|
|
|
|
self.assertEqual(2, len(lEdges))
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire(lEdges), obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire(lEdges), obj.Shape, 2, True)
|
|
|
|
|
|
|
|
|
|
x = length/2 + 2 * math.cos(math.pi/6)
|
|
|
|
|
y = -10 + 2 * math.sin(math.pi/6)
|
|
|
|
|
@@ -562,7 +562,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), rEdges[0].Curve.Axis)
|
|
|
|
|
|
|
|
|
|
#offset the other way
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), wire.Edges[-1].Vertexes[1].Point)
|
|
|
|
|
@@ -587,7 +587,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertEqual(2, len(lEdges))
|
|
|
|
|
|
|
|
|
|
w = PathGeom.flipWire(Part.Wire(lEdges))
|
|
|
|
|
wire = PathGeomOp.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
|
|
|
|
|
x = length/2 + 2 * math.cos(math.pi/6)
|
|
|
|
|
y = -10 + 2 * math.sin(math.pi/6)
|
|
|
|
|
@@ -602,7 +602,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(0, 0, -1), rEdges[0].Curve.Axis)
|
|
|
|
|
|
|
|
|
|
#offset the other way
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), wire.Edges[-1].Vertexes[1].Point)
|
|
|
|
|
@@ -633,7 +633,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), edge.Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), edge.Vertexes[1].Point)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 2, True)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
y = y + 2
|
|
|
|
|
@@ -642,7 +642,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
|
|
|
|
|
# make sure we get the same result even if the edge is oriented the other way
|
|
|
|
|
edge = PathGeom.flipEdge(edge)
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 2, True)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
@@ -668,7 +668,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), edge.Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), edge.Vertexes[1].Point)
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 2, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 2, False)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
y = y + 2
|
|
|
|
|
@@ -677,7 +677,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
|
|
|
|
|
# make sure we get the same result even if the edge is oriented the other way
|
|
|
|
|
edge = PathGeom.flipEdge(edge)
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire([edge]), obj.Shape, 2, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire([edge]), obj.Shape, 2, False)
|
|
|
|
|
self.assertEqual(1, len(wire.Edges))
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
@@ -694,7 +694,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
lEdges = [e for e in w.Edges if not PathGeom.isRoughly(e.Vertexes[0].Point.y, e.Vertexes[1].Point.y)]
|
|
|
|
|
self.assertEqual(2, len(lEdges))
|
|
|
|
|
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire(lEdges), obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire(lEdges), obj.Shape, 2, True)
|
|
|
|
|
|
|
|
|
|
x = length/2 - 2 * math.cos(math.pi/6)
|
|
|
|
|
y = -5 - 2 * math.sin(math.pi/6)
|
|
|
|
|
@@ -706,7 +706,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertEqual(0, len(rEdges))
|
|
|
|
|
|
|
|
|
|
#offset the other way
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), wire.Edges[-1].Vertexes[1].Point)
|
|
|
|
|
@@ -728,7 +728,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertEqual(2, len(lEdges))
|
|
|
|
|
|
|
|
|
|
w = PathGeom.flipWire(Part.Wire(lEdges))
|
|
|
|
|
wire = PathGeomOp.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
wire = PathOpTools.offsetWire(w, obj.Shape, 2, True)
|
|
|
|
|
|
|
|
|
|
x = length/2 - 2 * math.cos(math.pi/6)
|
|
|
|
|
y = -5 - 2 * math.sin(math.pi/6)
|
|
|
|
|
@@ -740,7 +740,7 @@ class TestPathGeomOp(PathTestUtils.PathTestBase):
|
|
|
|
|
self.assertEqual(0, len(rEdges))
|
|
|
|
|
|
|
|
|
|
#offset the other way
|
|
|
|
|
wire = PathGeomOp.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
wire = PathOpTools.offsetWire(Part.Wire(lEdges), obj.Shape, 2, False)
|
|
|
|
|
|
|
|
|
|
self.assertCoincide(Vector(-x, y, 0), wire.Edges[0].Vertexes[0].Point)
|
|
|
|
|
self.assertCoincide(Vector(+x, y, 0), wire.Edges[-1].Vertexes[1].Point)
|