def test_delete_polygon( polygonal_surface, builder ): to_delete = [False] * polygonal_surface.nb_polygons() to_delete[0] = True builder.delete_polygons( to_delete ) if polygonal_surface.nb_polygons() != 1: raise ValueError( "[Test] PolygonalSurface should have 1 polygon" ) if polygonal_surface.polygon_vertex( mesh.PolygonVertex( 0, 0 ) ) != 4: raise ValueError( "[Test] PolygonalSurface edge vertex index is not correct" ) if polygonal_surface.polygon_vertex( mesh.PolygonVertex( 0, 1 ) ) != 2: raise ValueError( "[Test] PolygonalSurface edge vertex index is not correct" ) if polygonal_surface.polygon_vertex( mesh.PolygonVertex( 0, 2 ) ) != 0: raise ValueError( "[Test] PolygonalSurface edge vertex index is not correct" ) builder.edges_builder().delete_isolated_edges() if polygonal_surface.edges().nb_edges() != 3: raise ValueError( "[Test] PolygonalSurface should have 3 edges" ) attribute = polygonal_surface.edges().edge_attribute_manager().find_attribute_uint( "test" ) if attribute.value( 0 ) != 0: raise ValueError( "[Test] Update of edge attributes after " "polygon deletion is not correct" ) if attribute.value( 1 ) != 1: raise ValueError( "[Test] Update of edge attributes after " "polygon deletion is not correct" ) if attribute.value( 2 ) != 2: raise ValueError( "[Test] Update of edge attributes after " "polygon deletion is not correct" )
def test_set_polygon_vertex( polygonal_surface, builder ): builder.set_polygon_vertex( mesh.PolygonVertex( 0, 2 ), 1 ) builder.edges_builder().delete_isolated_edges() if polygonal_surface.polygon_vertex( mesh.PolygonVertex( 0, 2 ) ) != 1: raise ValueError( "[Test] PolygonVertex after set_polygon_vertex is wrong" ) vertices = polygonal_surface.edges().edge_vertices( 1 ) if vertices[0] != 1 and vertices[1] != 4: raise ValueError( "[Test] Edge vertices after set_polygon_vertex is wrong" )
def test_delete_polygon( surface, builder ): to_delete = [False] * surface.nb_polygons() to_delete[0] = True builder.delete_polygons( to_delete ) if surface.nb_polygons() != 1: raise ValueError( "[Test] TriangulatedSurface should have 1 polygon" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 0 ) ) != 2: raise ValueError( "[Test] TriangulatedSurface edge vertex index is not correct" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 1 ) ) != 3: raise ValueError( "[Test] TriangulatedSurface edge vertex index is not correct" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 2 ) ) != 1: raise ValueError( "[Test] TriangulatedSurface edge vertex index is not correct" ) if surface.nb_edges() != 3: raise ValueError( "[Test] TriangulatedSurface should have 3 edges" )
def test_delete_polygon(polygonal_surface, builder): to_delete = [False] * polygonal_surface.nb_polygons() to_delete[0] = True builder.delete_polygons(to_delete) if polygonal_surface.nb_polygons() != 1: raise ValueError("[Test] PolygonalSurface should have 1 polygon") if polygonal_surface.polygon_vertex(mesh.PolygonVertex(0, 0)) != 0: raise ValueError( "[Test] PolygonalSurface edge vertex index is not correct") if polygonal_surface.polygon_vertex(mesh.PolygonVertex(0, 1)) != 4: raise ValueError( "[Test] PolygonalSurface edge vertex index is not correct") if polygonal_surface.polygon_vertex(mesh.PolygonVertex(0, 2)) != 5: raise ValueError( "[Test] PolygonalSurface edge vertex index is not correct") if polygonal_surface.polygon_vertex(mesh.PolygonVertex(0, 3)) != 2: raise ValueError( "[Test] PolygonalSurface edge vertex index is not correct") if polygonal_surface.nb_edges() != 4: raise ValueError("[Test] PolygonalSurface should have 4 edges") attribute = polygonal_surface.edge_attribute_manager().find_attribute_uint( "test") if attribute.value(1) != 6: raise ValueError("[Test] Update of edge attributes after " "polygon deletion is not correct (value of 1)") if attribute.value(2) != 7: raise ValueError("[Test] Update of edge attributes after " "polygon deletion is not correct (value of 2)") if attribute.value(3) != 8: raise ValueError("[Test] Update of edge attributes after " "polygon deletion is not correct (value of 3)") if polygonal_surface.polygon_edge(mesh.PolygonEdge(0, 0)) != 1: raise ValueError( "[Test] Edge index for PolygonEdge( 0, 0 ) is not correct") if polygonal_surface.polygon_edge(mesh.PolygonEdge(0, 3)) != 0: raise ValueError( "[Test] Edge index for PolygonEdge( 0, 3 ) is not correct")
def test_permutation(surface, builder): builder.permute_vertices([4, 2, 1, 0, 3]) if surface.polygon_vertex(mesh.PolygonVertex(0, 0)) != 3: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(0, 1)) != 2: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(0, 2)) != 1: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(1, 0)) != 2: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(1, 1)) != 4: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(1, 2)) != 1: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(2, 0)) != 4: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(2, 1)) != 0: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") if surface.polygon_vertex(mesh.PolygonVertex(2, 2)) != 1: raise ValueError("[Test] Wrong PolygonVertex after vertex permute") builder.permute_polygons([2, 0, 1]) if surface.polygon_vertex(mesh.PolygonVertex(0, 0)) != 4: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(0, 1)) != 0: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(0, 2)) != 1: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(1, 0)) != 3: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(1, 1)) != 2: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(1, 2)) != 1: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(2, 0)) != 2: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(2, 1)) != 4: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_vertex(mesh.PolygonVertex(2, 2)) != 1: raise ValueError("[Test] Wrong PolygonVertex after polygon permute") if surface.polygon_adjacent(mesh.PolygonEdge(0, 2)) != 2: raise ValueError("[Test] Wrong Adjacency after polygon permute") if surface.polygon_adjacent(mesh.PolygonEdge(2, 1)) != 0: raise ValueError("[Test] Wrong Adjacency after polygon permute") if surface.polygon_adjacent(mesh.PolygonEdge(1, 1)) != 2: raise ValueError("[Test] Wrong Adjacency after polygon permute") if surface.polygon_adjacent(mesh.PolygonEdge(1, 0)): raise ValueError("[Test] Wrong Adjacency after polygon permute") polygons_2 = surface.polygons_around_vertex(2) if len(polygons_2) != 2: raise ValueError("[Test] Wrong polygons_2 after polygon permute") if polygons_2[0].polygon_id != 2: raise ValueError("[Test] Wrong polygons_2 after polygon permute") if polygons_2[0].vertex_id != 0: raise ValueError("[Test] Wrong polygons_2 after polygon permute") if polygons_2[1].polygon_id != 1: raise ValueError("[Test] Wrong polygons_2 after polygon permute") if polygons_2[1].vertex_id != 1: raise ValueError("[Test] Wrong polygons_2 after polygon permute") polygons_4 = surface.polygons_around_vertex(4) if len(polygons_4) != 2: raise ValueError("[Test] Wrong polygons_4 after polygon permute") if polygons_4[0].polygon_id != 0: raise ValueError("[Test] Wrong polygons_4 after polygon permute") if polygons_4[0].vertex_id != 0: raise ValueError("[Test] Wrong polygons_4 after polygon permute") if polygons_4[1].polygon_id != 2: raise ValueError("[Test] Wrong polygons_4 after polygon permute") if polygons_4[1].vertex_id != 1: raise ValueError("[Test] Wrong polygons_4 after polygon permute")
def test_permutation( surface, builder ): builder.permute_vertices( [4, 2, 6, 1, 5, 0, 3] ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 0 ) ) != 5: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 1 ) ) != 3: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 2 ) ) != 1: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 1, 0 ) ) != 3: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 1, 1 ) ) != 6: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 1, 2 ) ) != 0: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 1, 3 ) ) != 1: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 0 ) ) != 3: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 1 ) ) != 4: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 2 ) ) != 2: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 3 ) ) != 6: raise ValueError( "[Test] Wrong PolygonVertex after vertex permute" ) builder.permute_polygons( [2, 0, 1] ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 0 ) ) != 3: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 1 ) ) != 4: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 2 ) ) != 2: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 0, 3 ) ) != 6: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 1, 0 ) ) != 5: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 1, 1 ) ) != 3: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 1, 2 ) ) != 1: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 0 ) ) != 3: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 1 ) ) != 6: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 2 ) ) != 0: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_vertex( mesh.PolygonVertex( 2, 3 ) ) != 1: raise ValueError( "[Test] Wrong PolygonVertex after polygon permute" ) if surface.polygon_adjacent( mesh.PolygonEdge( 0, 3 ) ) != 2: raise ValueError( "[Test] Wrong Adjacency after polygon permute" ) if surface.polygon_adjacent( mesh.PolygonEdge( 2, 0 ) ) != 0: raise ValueError( "[Test] Wrong Adjacency after polygon permute" ) if surface.polygon_adjacent( mesh.PolygonEdge( 1, 1 ) ) != 2: raise ValueError( "[Test] Wrong Adjacency after polygon permute" ) if surface.polygon_adjacent( mesh.PolygonEdge( 1, 0 ) ): raise ValueError( "[Test] Wrong Adjacency after polygon permute" ) polygons_3 = surface.polygons_around_vertex( 3 ) if len(polygons_3) != 3: raise ValueError( "[Test] Wrong polygons_3 after polygon permute" ) if polygons_3[0].polygon_id != 0: raise ValueError( "[Test] Wrong polygons_3 after polygon permute" ) if polygons_3[0].vertex_id != 0: raise ValueError( "[Test] Wrong polygons_3 after polygon permute" ) if polygons_3[1].polygon_id != 2: raise ValueError( "[Test] Wrong polygons_3 after polygon permute" ) if polygons_3[1].vertex_id != 0: raise ValueError( "[Test] Wrong polygons_3 after polygon permute" ) if polygons_3[2].polygon_id != 1: raise ValueError( "[Test] Wrong polygons_3 after polygon permute" ) if polygons_3[2].vertex_id != 1: raise ValueError( "[Test] Wrong polygons_3 after polygon permute" ) polygons_6 = surface.polygons_around_vertex( 6 ) if len(polygons_6) != 2: raise ValueError( "[Test] Wrong polygons_6 after polygon permute" ) if polygons_6[0].polygon_id != 0: raise ValueError( "[Test] Wrong polygons_6 after polygon permute" ) if polygons_6[0].vertex_id != 3: raise ValueError( "[Test] Wrong polygons_6 after polygon permute" ) if polygons_6[1].polygon_id != 2: raise ValueError( "[Test] Wrong polygons_6 after polygon permute" ) if polygons_6[1].vertex_id != 1: raise ValueError( "[Test] Wrong polygons_6 after polygon permute" )