Skip to content

Commit 2c8a852

Browse files
committed
added tests for Shape.split
1 parent 6615c2a commit 2c8a852

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_cadquery.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4490,3 +4490,23 @@ def testEdgeClose(self):
44904490
e2 = e1.close()
44914491
self.assertTrue(e2.IsClosed())
44924492
self.assertEqual(type(e1), type(e2))
4493+
4494+
def testSplitShape(self):
4495+
"""
4496+
Testing the Shape.split method.
4497+
"""
4498+
# split an edge with a vertex
4499+
e0 = Edge.makeCircle(1, (0, 0, 0), (0, 0, 1))
4500+
v0 = Vertex.makeVertex(0, 1, 0)
4501+
list_of_edges = e0.split(v0).Edges()
4502+
self.assertEqual(len(list_of_edges), 2)
4503+
self.assertTrue(Vector(0, 1, 0) in [e.endPoint() for e in list_of_edges])
4504+
4505+
# split a circle with multiple vertices
4506+
angles = [2 * math.pi * idx / 10 for idx in range(10)]
4507+
vecs = [Vector(math.sin(a), math.cos(a), 0) for a in angles]
4508+
vertices = [Vertex.makeVertex(*v.toTuple()) for v in vecs]
4509+
edges = e0.split(*vertices).Edges()
4510+
self.assertEqual(len(edges), len(vertices) + 1)
4511+
endpoints = [e.endPoint() for e in edges]
4512+
self.assertTrue(all([v in endpoints for v in vecs]))

0 commit comments

Comments
 (0)