def test_base(self): # # Retrieve base # v1 = Vertex((0,0)) v2 = Vertex((1,1)) half_edge = HalfEdge(v1,v2) self.assertEqual(half_edge.base(), v1, 'Incorrect base.')
def test_make_twin(self): # # New HalfEdge # v1 = Vertex((0,0)) v2 = Vertex((2,2)) h12 = HalfEdge(v1,v2) h21 = h12.make_twin() self.assertIsNotNone(h12.twin()) self.assertIsNotNone(h21.twin()) self.assertEqual(h12.base(),h21.head()) self.assertEqual(h21.base(),h12.head())
def test_assign_twin(self): # # New half-edge # v1 = Vertex((0,0)) v2 = Vertex((1,1)) half_edge = HalfEdge(v1, v2) # # Try to assign incorrect twin # false_twin = HalfEdge(v1, v2) self.assertRaises(Exception, half_edge.assign_twin, false_twin,\ 'This twin should not be assignable.') # # Assign a good twin and check # good_twin = HalfEdge(v2, v1) half_edge.assign_twin(good_twin) self.assertEqual(good_twin.base(),half_edge.head(), \ 'Heads and bases do not match.') self.assertEqual(good_twin.head(),half_edge.base(), \ 'Heads and bases do not match.')
def test_assign_previous(self): # # New HalfEdge # v1 = Vertex((0,0)) v2 = Vertex((2,2)) v3 = Vertex((3,4)) h = HalfEdge(v1, v2) # # Incompatible previous half_edge # bad_h_prev = HalfEdge(v1, v3) self.assertRaises(Exception, h.assign_previous, (bad_h_prev)) # # Assign good next half-edge # good_h_previous = HalfEdge(v2, v1) h.assign_previous(good_h_previous) # Check self.assertEqual(h.previous(),good_h_previous,\ 'Next HalfEdge incorrect.') self.assertEqual(h.base(), h.previous().head(), \ 'Bases and heads should align.')