Commit c1243f5d authored by Alexander Dielen's avatar Alexander Dielen

fixes most of the python2 unit tests

parent 697be987
Pipeline #6120 failed with stage
in 1 minute and 35 seconds
......@@ -89,7 +89,6 @@ void expose_circulator(py::module& m, const char *_name) {
.def(py::init<PolyMesh&, CenterEntityHandle>())
.def("__iter__", &CirculatorWrapperT<Circulator, CenterEntityHandle>::iter)
.def("__next__", &CirculatorWrapperT<Circulator, CenterEntityHandle>::next)
.def("next", &CirculatorWrapperT<Circulator, CenterEntityHandle>::next)
;
}
......
......@@ -114,7 +114,6 @@ void expose_iterator(py::module& m, const char *_name) {
.def("__iter__", &IteratorWrapperT<Iterator, n_items>::iter)
.def("__next__", &IteratorWrapperT<Iterator, n_items>::next)
.def("__len__", &IteratorWrapperT<Iterator, n_items>::len)
.def("next", &IteratorWrapperT<Iterator, n_items>::next)
;
}
......
......@@ -52,26 +52,26 @@ class Property(unittest.TestCase):
# Check if property it is ok
v_it = self.mesh.vertices()
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 0)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 3)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 0)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 3)
# Check vertex positions
v_it = self.mesh.vertices()
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
......@@ -79,52 +79,52 @@ class Property(unittest.TestCase):
# Copy from vertex 1 to 0, with skipping build in properties
self.mesh.copy_all_properties(self.vhandle[1], self.vhandle[0])
v_it = self.mesh.vertices()
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
v_it = self.mesh.vertices()
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 3)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 3)
# Copy from vertex 2 to 3, including build in properties
self.mesh.copy_all_properties(self.vhandle[2], self.vhandle[3], True)
v_it = self.mesh.vertices()
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
v_it = self.mesh.vertices()
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
def test_check_status_properties_halfedge_edge_all_deleted(self):
self.mesh.request_vertex_status()
......@@ -212,26 +212,26 @@ class Property(unittest.TestCase):
# Check if property it is ok
v_it = self.mesh.vertices()
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 0)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 3)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 0)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 3)
# Check vertex positions
v_it = self.mesh.vertices()
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
......@@ -239,52 +239,52 @@ class Property(unittest.TestCase):
# Copy from vertex 1 to 0, with skipping build in properties
self.mesh.copy_all_properties(self.vhandle[1], self.vhandle[0])
v_it = self.mesh.vertices()
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
v_it = self.mesh.vertices()
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 3)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 3)
# Copy from vertex 2 to 3, including build in properties
self.mesh.copy_all_properties(self.vhandle[2], self.vhandle[3], True)
v_it = self.mesh.vertices()
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 0)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 0)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
vh = v_it.next()
vh = next(v_it)
self.assertEqual(self.mesh.point(vh)[0], 1)
self.assertEqual(self.mesh.point(vh)[1], 1)
self.assertEqual(self.mesh.point(vh)[2], 0)
v_it = self.mesh.vertices()
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 1)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, v_it.next()), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 1)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
self.assertEqual(self.mesh.property(intHandle, next(v_it)), 2)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(Property)
......
......@@ -41,10 +41,11 @@ class TriMeshCirculatorFaceEdge(unittest.TestCase):
def test_face_edge_iter_without_holes_increment(self):
# Iterate around face 1 at the middle
fe_it = openmesh.FaceEdgeIter(self.mesh, self.mesh.face_handle(1))
self.assertEqual(fe_it.__next__().idx(), 4)
self.assertEqual(fe_it.__next__().idx(), 1)
self.assertEqual(fe_it.__next__().idx(), 3)
self.assertRaises(StopIteration, fe_it.__next__)
self.assertEqual(next(fe_it).idx(), 4)
self.assertEqual(next(fe_it).idx(), 1)
self.assertEqual(next(fe_it).idx(), 3)
with self.assertRaises(StopIteration):
next(fe_it)
if __name__ == '__main__':
......
......@@ -49,9 +49,10 @@ class TrimeshCirculatorFaceFace(unittest.TestCase):
ff_it = self.mesh.ff(self.mesh.face_handle(1))
self.assertEqual(ff_it.__next__().idx(), 2)
self.assertEqual(ff_it.__next__().idx(), 0)
self.assertRaises(StopIteration, ff_it.__next__)
self.assertEqual(next(ff_it).idx(), 2)
self.assertEqual(next(ff_it).idx(), 0)
with self.assertRaises(StopIteration):
next(ff_it)
def test_face_face_iter_without_holes(self):
# Add some vertices
......@@ -106,10 +107,11 @@ class TrimeshCirculatorFaceFace(unittest.TestCase):
ff_it = self.mesh.ff(self.mesh.face_handle(1))
self.assertEqual(ff_it.__next__().idx(), 2)
self.assertEqual(ff_it.__next__().idx(), 0)
self.assertEqual(ff_it.__next__().idx(), 3)
self.assertRaises(StopIteration, ff_it.__next__)
self.assertEqual(next(ff_it).idx(), 2)
self.assertEqual(next(ff_it).idx(), 0)
self.assertEqual(next(ff_it).idx(), 3)
with self.assertRaises(StopIteration):
next(ff_it)
def test_face_face_iter_without_holes(self):
# Add some vertices
......@@ -147,7 +149,7 @@ class TrimeshCirculatorFaceFace(unittest.TestCase):
face_iter = self.mesh.ff(fh1)
# Get the face via the handle
faceHandle1 = face_iter.__next__()
faceHandle1 = next(face_iter)
face1 = self.mesh.face(faceHandle1)
self.assertEqual(faceHandle1.idx(), 1)
......
......@@ -41,10 +41,11 @@ class TriMeshCirculatorFaceHalfEdge(unittest.TestCase):
def test_face_halfedge_iter_without_holes_increment(self):
# Iterate around face 1 at the middle
fh_it = openmesh.FaceHalfedgeIter(self.mesh, self.mesh.face_handle(1))
self.assertEqual(fh_it.__next__().idx(), 8)
self.assertEqual(fh_it.__next__().idx(), 3)
self.assertEqual(fh_it.__next__().idx(), 6)
self.assertRaises(StopIteration, fh_it.__next__)
self.assertEqual(next(fh_it).idx(), 8)
self.assertEqual(next(fh_it).idx(), 3)
self.assertEqual(next(fh_it).idx(), 6)
with self.assertRaises(StopIteration):
next(fh_it)
if __name__ == '__main__':
......
......@@ -39,10 +39,11 @@ class TriMeshCirculatorFaceVertex(unittest.TestCase):
# Iterate around face 0 at the top
fv_it = openmesh.FaceVertexIter(self.mesh, self.fh0)
self.assertEqual(fv_it.__next__().idx(), 0)
self.assertEqual(fv_it.__next__().idx(), 1)
self.assertEqual(fv_it.__next__().idx(), 2)
self.assertRaises(StopIteration, fv_it.__next__)
self.assertEqual(next(fv_it).idx(), 0)
self.assertEqual(next(fv_it).idx(), 1)
self.assertEqual(next(fv_it).idx(), 2)
with self.assertRaises(StopIteration):
next(fv_it)
if __name__ == '__main__':
......
......@@ -66,10 +66,11 @@ class TrimeshCirculatorHalfedgeLoop(unittest.TestCase):
# Circle around face 1
hl_it = self.mesh.hl(self.mesh.halfedge_handle(3))
self.assertEqual(hl_it.__next__().idx(), 3)
self.assertEqual(hl_it.__next__().idx(), 6)
self.assertEqual(hl_it.__next__().idx(), 8)
self.assertRaises(StopIteration, hl_it.__next__)
self.assertEqual(next(hl_it).idx(), 3)
self.assertEqual(next(hl_it).idx(), 6)
self.assertEqual(next(hl_it).idx(), 8)
with self.assertRaises(StopIteration):
next(hl_it)
def test_halfedge_loop_without_face(self):
# Add some vertices
......@@ -122,10 +123,11 @@ class TrimeshCirculatorHalfedgeLoop(unittest.TestCase):
# Circle around the hole
hl_it = self.mesh.hl(self.mesh.halfedge_handle(3))
self.assertEqual(hl_it.__next__().idx(), 3)
self.assertEqual(hl_it.__next__().idx(), 17)
self.assertEqual(hl_it.__next__().idx(), 7)
self.assertRaises(StopIteration, hl_it.__next__)
self.assertEqual(next(hl_it).idx(), 3)
self.assertEqual(next(hl_it).idx(), 17)
self.assertEqual(next(hl_it).idx(), 7)
with self.assertRaises(StopIteration):
next(hl_it)
if __name__ == '__main__':
......
......@@ -37,19 +37,21 @@ class TriMeshCirculatorVertexEdge(unittest.TestCase):
def test_vertex_edge_iter_without_holes_increment(self):
# Iterate around vertex 1 at the middle
ve_it = openmesh.VertexEdgeIter(self.mesh, self.vhandle[1])
self.assertEqual(ve_it.__next__().idx(), 5)
self.assertEqual(ve_it.__next__().idx(), 3)
self.assertEqual(ve_it.__next__().idx(), 0)
self.assertEqual(ve_it.__next__().idx(), 1)
self.assertRaises(StopIteration, ve_it.__next__)
self.assertEqual(next(ve_it).idx(), 5)
self.assertEqual(next(ve_it).idx(), 3)
self.assertEqual(next(ve_it).idx(), 0)
self.assertEqual(next(ve_it).idx(), 1)
with self.assertRaises(StopIteration):
next(ve_it)
def test_vertex_edge_iter_boundary_increment(self):
# Iterate around vertex 2 at the boundary
ve_it = openmesh.VertexEdgeIter(self.mesh, self.vhandle[2])
self.assertEqual(ve_it.__next__().idx(), 7)
self.assertEqual(ve_it.__next__().idx(), 1)
self.assertEqual(ve_it.__next__().idx(), 2)
self.assertRaises(StopIteration, ve_it.__next__)
self.assertEqual(next(ve_it).idx(), 7)
self.assertEqual(next(ve_it).idx(), 1)
self.assertEqual(next(ve_it).idx(), 2)
with self.assertRaises(StopIteration):
next(ve_it)
if __name__ == '__main__':
......
......@@ -35,9 +35,10 @@ class TriMeshCirculatorVertexFace(unittest.TestCase):
# Iterate around vertex 1 at the middle (with holes in between)
vf_it = openmesh.VertexFaceIter(self.mesh, self.vhandle[1])
self.assertEqual(vf_it.__next__().idx(), 0)
self.assertEqual(vf_it.__next__().idx(), 1)
self.assertRaises(StopIteration, vf_it.__next__)
self.assertEqual(next(vf_it).idx(), 0)
self.assertEqual(next(vf_it).idx(), 1)
with self.assertRaises(StopIteration):
next(vf_it)
def test_vertex_face_iter_without_holes_increment(self):
# Add four faces
......@@ -59,11 +60,12 @@ class TriMeshCirculatorVertexFace(unittest.TestCase):
# Iterate around vertex 1 at the middle (without holes in between)
vf_it = openmesh.VertexFaceIter(self.mesh, self.vhandle[1])
self.assertEqual(vf_it.__next__().idx(), 3)
self.assertEqual(vf_it.__next__().idx(), 1)
self.assertEqual(vf_it.__next__().idx(), 2)
self.assertEqual(vf_it.__next__().idx(), 0)
self.assertRaises(StopIteration, vf_it.__next__)
self.assertEqual(next(vf_it).idx(), 3)
self.assertEqual(next(vf_it).idx(), 1)
self.assertEqual(next(vf_it).idx(), 2)
self.assertEqual(next(vf_it).idx(), 0)
with self.assertRaises(StopIteration):
next(vf_it)
def test_vertex_face_iter_boundary_increment(self):
# Add four faces
......@@ -85,9 +87,10 @@ class TriMeshCirculatorVertexFace(unittest.TestCase):
# Iterate around vertex 2 at the boundary (without holes in between)
vf_it = openmesh.VertexFaceIter(self.mesh, self.vhandle[2])
self.assertEqual(vf_it.__next__().idx(), 3)
self.assertEqual(vf_it.__next__().idx(), 0)
self.assertRaises(StopIteration, vf_it.__next__)
self.assertEqual(next(vf_it).idx(), 3)
self.assertEqual(next(vf_it).idx(), 0)
with self.assertRaises(StopIteration):
next(vf_it)
if __name__ == '__main__':
......
......@@ -38,38 +38,40 @@ class TriMeshCirculatorVertexIHalfEdge(unittest.TestCase):
def test_vertex_incoming_halfedge_without_holes_increment(self):
# Iterate around vertex 1 at the middle
vih_it = openmesh.VertexIHalfedgeIter(self.mesh, self.vhandle[1])
heh = vih_it.__next__()
heh = next(vih_it)
self.assertEqual(heh.idx(), 10)
self.assertEqual(self.mesh.face_handle(heh).idx(), 1)
heh = vih_it.__next__()
heh = next(vih_it)
self.assertEqual(heh.idx(), 7)
self.assertEqual(self.mesh.face_handle(heh).idx(), 2)
heh = vih_it.__next__()
heh = next(vih_it)
self.assertEqual(heh.idx(), 0)
self.assertEqual(self.mesh.face_handle(heh).idx(), 0)
heh = vih_it.__next__()
heh = next(vih_it)
self.assertEqual(heh.idx(), 3)
self.assertEqual(self.mesh.face_handle(heh).idx(), 3)
self.assertRaises(StopIteration, vih_it.__next__)
with self.assertRaises(StopIteration):
next(vih_it)
def test_vertex_incoming_halfedge_boundary_increment(self):
# Iterate around vertex 2 at the boundary
vih_it = openmesh.VertexIHalfedgeIter(self.mesh, self.vhandle[2])
heh = vih_it.__next__()
heh = next(vih_it)
self.assertEqual(heh.idx(), 14)
self.assertEqual(self.mesh.face_handle(heh).idx(), 3)
heh = vih_it.__next__()
heh = next(vih_it)
self.assertEqual(heh.idx(), 2)
self.assertEqual(self.mesh.face_handle(heh).idx(), 0)
heh = vih_it.__next__()
heh = next(vih_it)
self.assertEqual(heh.idx(), 5)
self.assertEqual(self.mesh.face_handle(heh).idx(), -1)
self.assertRaises(StopIteration, vih_it.__next__)
with self.assertRaises(StopIteration):
next(vih_it)
def test_vertex_incoming_halfedge_dereference_increment(self):
# Iterate around vertex 1 at the middle
vih_it = openmesh.VertexIHalfedgeIter(self.mesh, self.vhandle[1])
heh = vih_it.__next__()
heh = next(vih_it)
eh = self.mesh.edge_handle(heh)
vh = self.mesh.to_vertex_handle(heh)
self.assertEqual(heh.idx(), 10)
......
......@@ -38,38 +38,40 @@ class TriMeshCirculatorVertexOHalfEdge(unittest.TestCase):
def test_vertex_outgoing_halfedge_without_holes_increment(self):
# Iterate around vertex 1 at the middle
voh_it = openmesh.VertexOHalfedgeIter(self.mesh, self.vhandle[1])
heh = voh_it.__next__()
heh = next(voh_it)
self.assertEqual(heh.idx(), 11)
self.assertEqual(self.mesh.face_handle(heh).idx(), 3)
heh = voh_it.__next__()
heh = next(voh_it)
self.assertEqual(heh.idx(), 6)
self.assertEqual(self.mesh.face_handle(heh).idx(), 1)
heh = voh_it.__next__()
heh = next(voh_it)
self.assertEqual(heh.idx(), 1)
self.assertEqual(self.mesh.face_handle(heh).idx(), 2)
heh = voh_it.__next__()
heh = next(voh_it)
self.assertEqual(heh.idx(), 2)
self.assertEqual(self.mesh.face_handle(heh).idx(), 0)
self.assertRaises(StopIteration, voh_it.__next__)
with self.assertRaises(StopIteration):
next(voh_it)
def test_vertex_outgoing_halfedge_boundary_increment(self):
# Iterate around vertex 2 at the boundary
voh_it = openmesh.VertexOHalfedgeIter(self.mesh, self.vhandle[2])
heh = voh_it.__next__()
heh = next(voh_it)
self.assertEqual(heh.idx(), 15)
self.assertEqual(self.mesh.face_handle(heh).idx(), -1)
heh = voh_it.__next__()
heh = next(voh_it)
self.assertEqual(heh.idx(), 3)
self.assertEqual(self.mesh.face_handle(heh).idx(), 3)
heh = voh_it.__next__()
heh = next(voh_it)
self.assertEqual(heh.idx(), 4)
self.assertEqual(self.mesh.face_handle(heh).idx(), 0)
self.assertRaises(StopIteration, voh_it.__next__)
with self.assertRaises(StopIteration):
next(voh_it)
def test_vertex_outgoing_halfedge_dereference_increment(self):
# Iterate around vertex 1 at the middle
voh_it = openmesh.VertexOHalfedgeIter(self.mesh, self.vhandle[1])
heh = voh_it.__next__()
heh = next(voh_it)
eh = self.mesh.edge_handle(heh)
vh = self.mesh.to_vertex_handle(heh)
self.assertEqual(heh.idx(), 11)
......
......@@ -38,19 +38,21 @@ class TriMeshCirculatorVertexVertex(unittest.TestCase):
def test_vertex_vertex_increment(self):
# Iterate around vertex 1 at the middle
vv_it = openmesh.VertexVertexIter(self.mesh, self.vhandle[1])
self.assertEqual(vv_it.__next__().idx(), 4)
self.assertEqual(vv_it.__next__().idx(), 3)
self.assertEqual(vv_it.__next__().idx(), 0)
self.assertEqual(vv_it.__next__().idx(), 2)
self.assertRaises(StopIteration, vv_it.__next__)
self.assertEqual(next(vv_it).idx(), 4)
self.assertEqual(next(vv_it).idx(), 3)
self.assertEqual(next(vv_it).idx(), 0)
self.assertEqual(next(vv_it).idx(), 2)
with self.assertRaises(StopIteration):
next(vv_it)
def test_vertex_vertex_boundary_increment(self):
# Iterate around vertex 2 at the boundary
vv_it = openmesh.VertexVertexIter(self.mesh, self.vhandle[2])
self.assertEqual(vv_it.__next__().idx(), 4)
self.assertEqual(vv_it.__next__().idx(), 1)
self.assertEqual(vv_it.__next__().idx(), 0)
self.assertRaises(StopIteration, vv_it.__next__)
self.assertEqual(next(vv_it).idx(), 4)
self.assertEqual(next(vv_it).idx(), 1)
self.assertEqual(next(vv_it).idx(), 0)
with self.assertRaises(StopIteration):
next(vv_it)
if __name__ == '__main__':
......
......@@ -197,15 +197,15 @@ class Collapse(unittest.TestCase):
fv_it = self.mesh.fv(fh_1)
self.assertTrue(fv_it.__next__().idx(), 1)
self.assertTrue(fv_it.__next__().idx(), 2)
self.assertTrue(fv_it.__next__().idx(), 3)
self.assertEqual(next(fv_it).idx(), 1)
self.assertEqual(next(fv_it).idx(), 2)
self.assertEqual(next(fv_it).idx(), 3)
fv_it = self.mesh.fv(fh_2)
self.assertTrue(fv_it.__next__().idx(), 2)
self.assertTrue(fv_it.__next__().idx(), 1)
self.assertTrue(fv_it.__next__().idx(), 3)
self.assertEqual(next(fv_it).idx(), 2)
self.assertEqual(next(fv_it).idx(), 1)
self.assertEqual(next(fv_it).idx(), 3)
# Get the first halfedge of face 1
fh_1_he = self.mesh.halfedge_handle(fh_1)
......@@ -213,13 +213,13 @@ class Collapse(unittest.TestCase):
self.assertEqual(fh_1_he.idx(), 11)
self.assertEqual(self.mesh.to_vertex_handle(fh_1_he).idx(), 1)
next = self.mesh.next_halfedge_handle(fh_1_he)
self.assertEqual(next.idx(), 2)
self.assertEqual(self.mesh.to_vertex_handle(next).idx(), 2)
next_he = self.mesh.next_halfedge_handle(fh_1_he)
self.assertEqual(next_he.idx(), 2)
self.assertEqual(self.mesh.to_vertex_handle(next_he).idx(), 2)
next = self.mesh.next_halfedge_handle(next)
self.assertEqual(next.idx(), 6)
self.assertEqual(self.mesh.to_vertex_handle(next).idx(), 3)
next_he = self.mesh.next_halfedge_handle(next_he)
self.assertEqual(next_he.idx(), 6)
self.assertEqual(self.mesh.to_vertex_handle(next_he).idx(), 3)
# Get the first halfedge of face 2
fh_2_he = self.mesh.halfedge_handle(fh_2)
......@@ -227,31 +227,34 @@ class Collapse(unittest.TestCase):
self.assertEqual(fh_2_he.idx(), 7)
self.assertEqual(self.mesh.to_vertex_handle(fh_2_he).idx(), 2)
next = self.mesh.next_halfedge_handle(fh_2_he)
self.assertEqual(next.idx(), 3)
self.assertEqual(self.mesh.to_vertex_handle(next).idx(), 1)
next_he = self.mesh.next_halfedge_handle(fh_2_he)
self.assertEqual(next_he.idx(), 3)
self.assertEqual(self.mesh.to_vertex_handle(next_he).idx(), 1)
next = self.mesh.next_halfedge_handle(next)
self.assertEqual(next.idx(), 10)
self.assertEqual(self.mesh.to_vertex_handle(next).idx(), 3)
next_he = self.mesh.next_halfedge_handle(next_he)
self.assertEqual(next_he.idx(), 10)
self.assertEqual(self.mesh.to_vertex_handle(next_he).idx(), 3)
# Vertex 1 outgoing
voh_it = self.mesh.voh(self.mesh.vertex_handle(1))
self.assertEqual(voh_it.__next__().idx(), 10)
self.assertEqual(voh_it.__next__().idx(), 2)
self.assertRaises(StopIteration, voh_it.__next__)
self.assertEqual(next(voh_it).idx(), 10)
self.assertEqual(next(voh_it).idx(), 2)
with self.assertRaises(StopIteration):
next(voh_it)
# Vertex 2 outgoing
voh_it = self.mesh.voh(self.mesh.vertex_handle(2))
self.assertEqual(voh_it.__next__().idx(), 3)
self.assertEqual(voh_it.__next__().idx(), 6)
self.assertRaises(StopIteration, voh_it.__next__)
self.assertEqual(next(voh_it).idx(), 3)
self.assertEqual(next(voh_it).idx(), 6)
with self.assertRaises(StopIteration):
next(voh_it)
# Vertex 2 outgoing
voh_it = self.mesh.voh(self.mesh.vertex_handle(3))
self.assertEqual(voh_it.__next__().idx(), 11)
self.assertEqual(voh_it.__next__().idx(), 7)
self.assertRaises(StopIteration, voh_it.__next__)
self.assertEqual(next(voh_it).idx(), 11)
self.assertEqual(next(voh_it).idx(), 7)
with self.assertRaises(StopIteration):
next(voh_it)