Beispiel #1
0
def test_delete_vertex(polygonal_surface, builder):
    to_delete = [False] * polygonal_surface.nb_vertices()
    to_delete[0] = True
    builder.delete_vertices(to_delete)
    if polygonal_surface.nb_vertices() != 6:
        raise ValueError("[Test] PolygonalSurface should have 6 vertices")
    answer = geom.Point3D([2.1, 9.4, 6.7])
    if polygonal_surface.point(0) != answer:
        raise ValueError(
            "[Test] PolygonalSurface vertex coordinates are not correct")
    if polygonal_surface.nb_polygons() != 2:
        raise ValueError("[Test] PolygonalSurface should have 2 polygons")
    if polygonal_surface.polygon_adjacent(mesh.PolygonEdge(1, 3)) != 0:
        raise ValueError(
            "[Test] PolygonalSurface adjacent index is not correct")
    if polygonal_surface.nb_edges() != 7:
        raise ValueError("[Test] PolygonalSurface should have 7 edges")

    attribute = polygonal_surface.edge_attribute_manager().find_attribute_uint(
        "test")
    if attribute.value(4) != 6:
        raise ValueError("[Test] Update of edge attributes after "
                         "vertex deletion is not correct (value of 4)")
    if attribute.value(5) != 7:
        raise ValueError("[Test] Update of edge attributes after "
                         "vertex deletion is not correct (value of 5)")
    if attribute.value(6) != 8:
        raise ValueError("[Test] Update of edge attributes after "
                         "vertex deletion is not correct (value of 6)")
    if polygonal_surface.polygon_edge(mesh.PolygonEdge(1, 0)) != 4:
        raise ValueError(
            "[Test] Edge index for PolygonEdge( 1, 0 ) is not correct")
    if polygonal_surface.polygon_edge(mesh.PolygonEdge(1, 3)) != 1:
        raise ValueError(
            "[Test] Edge index for PolygonEdge( 1, 3 ) is not correct")
Beispiel #2
0
def test_previous_next_on_border(polygonal_surface):
    if polygonal_surface.previous_on_border(mesh.PolygonEdge(
            0, 0)) != mesh.PolygonEdge(0, 2):
        raise ValueError("[Test] Previous edge on border index is not correct")
    if polygonal_surface.next_on_border(mesh.PolygonEdge(
            0, 0)) != mesh.PolygonEdge(2, 0):
        raise ValueError("[Test] Next edge on border index is not correct")
Beispiel #3
0
def test_polygon_adjacencies(polygonal_surface, builder):
    builder.compute_polygon_adjacencies()
    if polygonal_surface.polygon_adjacent(mesh.PolygonEdge(0, 0)):
        raise ValueError(
            "[Test] PolygonalSurface adjacent index is not correct")
    if polygonal_surface.polygon_adjacent(mesh.PolygonEdge(0, 1)) != 1:
        raise ValueError(
            "[Test] PolygonalSurface adjacent index is not correct")
    if polygonal_surface.polygon_adjacent(mesh.PolygonEdge(1, 3)) != 0:
        raise ValueError(
            "[Test] PolygonalSurface adjacent index is not correct")
    if polygonal_surface.polygon_adjacent_edge(mesh.PolygonEdge(
            0, 1)) != mesh.PolygonEdge(1, 3):
        raise ValueError(
            "[Test] PolygonalSurface adjacent index is not correct")
    if polygonal_surface.polygon_edge(mesh.PolygonEdge(
            0, 1)) != polygonal_surface.polygon_edge(mesh.PolygonEdge(1, 3)):
        raise ValueError("[Test] PolygonalSurface edge indices is not correct")

    if polygonal_surface.polygon_adjacent(mesh.PolygonEdge(2, 0)):
        raise ValueError(
            "[Test] PolygonalSurface adjacent index is not correct")
    if polygonal_surface.polygon_adjacent(mesh.PolygonEdge(2, 3)) != 1:
        raise ValueError(
            "[Test] PolygonalSurface adjacent index is not correct")

    if len(polygonal_surface.polygons_around_vertex(1)) != 3:
        raise ValueError(
            "[Test] PolygonalSurface should have 3 polygons around this vertex"
        )
Beispiel #4
0
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")
Beispiel #5
0
def test_delete_vertex( surface, builder ):
    to_delete = [False] * surface.nb_vertices()
    to_delete[0] = True
    builder.delete_vertices( to_delete )
    if surface.nb_vertices() != 4:
        raise ValueError( "[Test] TriangulatedSurface should have 4 vertices" )
    answer = geom.Point3D( [ 2.1, 9.4, 6.7 ] )
    if surface.point( 0 ) != answer:
        raise ValueError( "[Test] TriangulatedSurface vertex coordinates are not correct" )
    if surface.nb_polygons() != 2:
        raise ValueError( "[Test] TriangulatedSurface should have 2 polygons" )
    if surface.polygon_adjacent( mesh.PolygonEdge( 1, 2 ) ) != 0:
        raise ValueError( "[Test] TriangulatedSurface adjacent index is not correct" )
    if surface.nb_edges() != 5:
        raise ValueError( "[Test] TriangulatedSurface should have 5 edges" )
Beispiel #6
0
def test_io(polygonal_surface, filename):
    mesh.save_polygonal_surface3D(polygonal_surface, filename)
    new_polygonal_surface = mesh.load_polygonal_surface3D(filename)

    if new_polygonal_surface.nb_vertices() != 7:
        raise ValueError(
            "[Test] Reloaded PolygonalSurface should have 7 vertices")
    if new_polygonal_surface.nb_edges() != 9:
        raise ValueError(
            "[Test] Reloaded PolygonalSurface should have 9 edges")
    if new_polygonal_surface.nb_polygons() != 3:
        raise ValueError(
            "[Test] Reloaded PolygonalSurface should have 3 polygons")
    if new_polygonal_surface.polygon_edge(mesh.PolygonEdge(
            1, 0)) != polygonal_surface.polygon_edge(mesh.PolygonEdge(1, 0)):
        raise ValueError(
            "[Test] Reloaded PolygonalSurface has wrong polygon edge index")
    attribute = new_polygonal_surface.edge_attribute_manager(
    ).find_attribute_uint("test")
    for e in range(new_polygonal_surface.nb_edges()):
        if attribute.value(e) != e:
            raise ValueError(
                "[Test] Reloaded PolygonalSurface has wrong attributes on its edges"
            )
Beispiel #7
0
def test_polygon_adjacencies( surface, builder ):
    builder.compute_polygon_adjacencies()
    if surface.polygon_adjacent( mesh.PolygonEdge( 0, 0 ) ):
        raise ValueError( "[Test] TriangulatedSurface adjacent index is not correct" )
    if surface.polygon_adjacent( mesh.PolygonEdge( 0, 1 ) ) != 1:
        raise ValueError( "[Test] TriangulatedSurface adjacent index is not correct" )
    if surface.polygon_adjacent( mesh.PolygonEdge( 1, 2 ) ) != 0:
        raise ValueError( "[Test] TriangulatedSurface adjacent index is not correct" )
    if surface.polygon_adjacent_edge( mesh.PolygonEdge( 0, 1 ) ) != mesh.PolygonEdge( 1, 2 ):
        raise ValueError( "[Test] TriangulatedSurface adjacent index is not correct" )

    if surface.polygon_adjacent( mesh.PolygonEdge( 2, 2 ) ) != 1:
        raise ValueError( "[Test] TriangulatedSurface adjacent index is not correct" )
    if surface.polygon_adjacent( mesh.PolygonEdge( 2, 0 ) ):
        raise ValueError( "[Test] TriangulatedSurface adjacent index 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" )