def test_hasPlane(self): eq = self.assertEqual aeq = self.almostEqual e5 = Edge().createCircle(center=(0.,0.,0.),normal=(0.,0.,1.),radius = 1.) eq(e5.hasPlane(), True) pnt = Point(-1.,-1.,-1.) vec = Vector(-1.,-1.,-1.) e5.hasPlane(pnt, vec) aeq(pnt, (0.,0.,0.)) aeq(vec, (0.,0.,1.))
def test_hasPlane(self): eq = self.assertEqual aeq = self.almostEqual e5 = Edge().createCircle(center=(0., 0., 0.), normal=(0., 0., 1.), radius=1.) eq(e5.hasPlane(), True) pnt = Point(-1., -1., -1.) vec = Vector(-1., -1., -1.) e5.hasPlane(pnt, vec) aeq(pnt, (0., 0., 0.)) aeq(vec, (0., 0., 1.))
def test_createLine(self): eq = self.assertEqual aeq = self.assertAlmostEqual self.assertRaises(OCCError, Edge().createLine, (0., 0., 0.), (0., 0., 0.)) args = \ ( (Vertex(1.,0.,0.), Vertex(-1.,0.,0.)), ((1.,0.,0.), (-1.,0.,0.)), ((0.,1.,0.), (0.,-1.,0.)), ((0.,0.,1.), (0.,0.,-1.)), ) for start, end in args: e1 = Edge().createLine(start, end) eq(len(e1), 2) eq(e1.isNull(), False) eq(e1.isValid(), True) eq(e1.isDegenerated(), False) eq(e1.hasPlane(), False) aeq(e1.length(), 2)
def test_empty(self): eq = self.assertEqual e1 = Edge() self.assertRaises(OCCError, e1.shapeType) eq(e1.isNull(), True) eq(e1.isValid(), False) eq(e1.isDegenerated(), True) eq(e1.hasPlane(), False) eq(len(e1), 0) eq(tuple(e1), ()) m = Transform().translate(1., 2., 3.) self.assertRaises(OCCError, e1.transform, m) self.assertRaises(OCCError, e1.translate, (1., 2., 3.)) self.assertRaises(OCCError, e1.rotate, pi, (0., 1., 0.)) self.assertRaises(OCCError, e1.scale, (0., 0., 0.), 2.)
def test_empty(self): eq = self.assertEqual e1 = Edge() self.assertRaises(OCCError, e1.shapeType) eq(e1.isNull(), True) eq(e1.isValid(), False) eq(e1.isDegenerated(), True) eq(e1.hasPlane(), False) eq(len(e1), 0) eq(tuple(e1), ()) m = Transform().translate(1.,2.,3.) self.assertRaises(OCCError, e1.transform, m) self.assertRaises(OCCError, e1.translate, (1.,2.,3.)) self.assertRaises(OCCError, e1.rotate, pi, (0.,1.,0.)) self.assertRaises(OCCError, e1.scale, (0.,0.,0.), 2.)
def test_base(self): eq = self.assertEqual start, end = Vertex(1., 0., 0.), Vertex(-1., 0., 0.) e1 = Edge().createLine(start, end) eq(e1.shapeType() is Edge, True) eq(e1.isNull(), False) eq(e1.isValid(), True) eq(e1.isDegenerated(), False) eq(e1.hasPlane(), False) e2 = e1.copy() eq(e2.isNull(), False) eq(e2.isValid(), True) eq(e2.isDegenerated(), False) eq(e2.hasPlane(), False) # test hallow copy equallity eq(e2.isEqual(e1), True) eq(e2 == e1, True) eq(e2 != e1, False) eq(e1.hashCode() == e2.hashCode(), True) # test copy of underlying geometry e3 = e1.copy(deepCopy=True) eq(e3.isEqual(e1), False) eq(e1.hashCode() == e3.hashCode(), False) # test serialize e4 = Edge().fromString(e1.toString()) eq(e4.isEqual(e1), False) eq(e1.hashCode() == e4.hashCode(), False) eq(len(e1), 2) vertices = set((start.hashCode(), end.hashCode())) for vertex in e1: hid = vertex.hashCode() if hid in vertices: vertices.remove(hid) eq(len(vertices), 0)
def test_base(self): eq = self.assertEqual start, end = Vertex(1.,0.,0.), Vertex(-1.,0.,0.) e1 = Edge().createLine(start, end) eq(e1.shapeType() is Edge, True) eq(e1.isNull(), False) eq(e1.isValid(), True) eq(e1.isDegenerated(), False) eq(e1.hasPlane(), False) e2 = e1.copy() eq(e2.isNull(), False) eq(e2.isValid(), True) eq(e2.isDegenerated(), False) eq(e2.hasPlane(), False) # test hallow copy equallity eq(e2.isEqual(e1), True) eq(e2 == e1, True) eq(e2 != e1, False) eq(e1.hashCode() == e2.hashCode(), True) # test copy of underlying geometry e3 = e1.copy(deepCopy = True) eq(e3.isEqual(e1), False) eq(e1.hashCode() == e3.hashCode(), False) # test serialize e4 = Edge().fromString(e1.toString()) eq(e4.isEqual(e1), False) eq(e1.hashCode() == e4.hashCode(), False) eq(len(e1), 2) vertices = set((start.hashCode(), end.hashCode())) for vertex in e1: hid = vertex.hashCode() if hid in vertices: vertices.remove(hid) eq(len(vertices), 0)
def test_createLine(self): eq = self.assertEqual aeq = self.assertAlmostEqual self.assertRaises(OCCError, Edge().createLine, (0.,0.,0.), (0.,0.,0.)) args = \ ( (Vertex(1.,0.,0.), Vertex(-1.,0.,0.)), ((1.,0.,0.), (-1.,0.,0.)), ((0.,1.,0.), (0.,-1.,0.)), ((0.,0.,1.), (0.,0.,-1.)), ) for start, end in args: e1 = Edge().createLine(start, end) eq(len(e1), 2) eq(e1.isNull(), False) eq(e1.isValid(), True) eq(e1.isDegenerated(), False) eq(e1.hasPlane(), False) aeq(e1.length(), 2)