def test_split(self): # # New HalfEdge # v1 = Vertex((0,0)) v2 = Vertex((2,2)) half_edge = HalfEdge(v1, v2) # # Split it # half_edge.split() # # Check if the children behave # child_0, child_1 = half_edge.get_children() self.assertEqual(child_0.head(), child_1.base(),\ 'First child head should equal second child base.') # # Define twin half edge # twin = HalfEdge(v2, v1) half_edge.assign_twin(twin) twin.assign_twin(half_edge) # # Split twin # twin.split() # # Check wether children are twinned # c0, c1 = half_edge.get_children() t0, t1 = twin.get_children() self.assertEqual(c0.base(),t1.head(),\ 'Children have incorrect twins.') self.assertEqual(c0.head(),t1.base(),\ 'Children have incorrect twins.') self.assertEqual(c1.base(),t0.head(),\ 'Children have incorrect twins.') self.assertEqual(c1.head(),t0.base(),\ 'Children have incorrect twins.')
def test_get_parent(self): # # New HalfEdge # v1 = Vertex((0,0)) v2 = Vertex((2,2)) half_edge = HalfEdge(v1, v2) # Split half_edge.split() # Check if half_edge is children's parent for child in half_edge.get_children(): self.assertEqual(half_edge, child.get_parent(),\ 'HalfEdge should be child"s parent')
def test_has_parent(self): # # New HalfEdge # v1 = Vertex((0,0)) v2 = Vertex((2,2)) half_edge = HalfEdge(v1, v2) self.assertFalse(half_edge.has_parent(), \ 'Half Edge should not have a parent.') # Split edge half_edge.split() # Children should have parent for child in half_edge.get_children(): self.assertTrue(child.has_parent(), \ 'HalfEdge children should have a parent.')
def test_mark(self): # # Define a HalfEdge # v1 = Vertex((0,0)) v2 = Vertex((0,1)) h_edge = HalfEdge(v1,v2) # # Mark it # h_edge.mark(1) self.assertTrue(h_edge.is_marked(1),'HalfEdge should be marked.') # # Mark when initializing # h_edge = HalfEdge(v1, v2, flag=1) self.assertTrue(h_edge.is_marked(1),'HalfEdge should be marked.') # # Split and mark recursively # h_edge.split() h_edge.mark(flag=1, recursive=True) for child in h_edge.get_children(): self.assertTrue(child.is_marked(1),'HalfEdge should be marked.')