Beispiel #1
0
def cleanup(wires):
    # Remove duplicated edges.
    ordered_edges = np.sort(wires.edges, axis=1)
    __, unique_edge_ids, __ = pymesh.unique_rows(ordered_edges)
    edges = wires.edges[unique_edge_ids, :]
    wires.load(wires.vertices, edges)

    # Remove topologically degenerate edges.
    is_not_topologically_degenerate = edges[:, 0] != edges[:, 1]
    if not np.all(is_not_topologically_degenerate):
        wires.filter_edges(is_not_topologically_degenerate)

    return wires
Beispiel #2
0
def cleanup(wires, logger):
    if wires.num_vertices == 0:
        return wires
    start_time = time()
    tol = 1e-6
    vertices, edges, __ = pymesh.remove_duplicated_vertices_raw(
        wires.vertices, wires.edges, tol)

    # Remove duplicated edges.
    ordered_edges = np.sort(edges, axis=1)
    __, unique_edge_ids, __ = pymesh.unique_rows(ordered_edges)
    edges = edges[unique_edge_ids, :]
    wires.load(vertices, edges)

    # Remove topologically degenerate edges.
    is_not_topologically_degenerate = edges[:, 0] != edges[:, 1]
    if not np.all(is_not_topologically_degenerate):
        wires.filter_edges(is_not_topologically_degenerate)

    finish_time = time()
    t = finish_time - start_time
    logger.info("Cleanup running time: {}".format(t))

    return wires
Beispiel #3
0
def cleanup(wires, logger):
    if wires.num_vertices == 0:
        return wires;
    start_time = time();
    tol = 1e-6;
    vertices, edges, __ = pymesh.remove_duplicated_vertices_raw(
            wires.vertices, wires.edges, tol);

    # Remove duplicated edges.
    ordered_edges = np.sort(edges, axis=1);
    __, unique_edge_ids, __ = pymesh.unique_rows(ordered_edges);
    edges = edges[unique_edge_ids, :];
    wires.load(vertices, edges);

    # Remove topologically degenerate edges.
    is_not_topologically_degenerate = edges[:,0] != edges[:,1];
    if not np.all(is_not_topologically_degenerate):
        wires.filter_edges(is_not_topologically_degenerate);

    finish_time = time();
    t = finish_time - start_time;
    logger.info("Cleanup running time: {}".format(t));

    return wires;
Beispiel #4
0
def print_extended_info(mesh, info):
    print_section_header("Extended info")

    num_cc = mesh.num_components
    num_f_cc = mesh.num_surface_components
    if mesh.num_voxels > 0:
        num_v_cc = mesh.num_volume_components
    else:
        num_v_cc = 0
    isolated_vertices = mesh.num_isolated_vertices
    duplicated_faces = mesh.num_duplicated_faces
    unique_vertices = pymesh.unique_rows(mesh.vertices)[0]
    duplicated_vertices = mesh.num_vertices - len(unique_vertices)

    degenerated_indices = pymesh.get_degenerated_faces(mesh)
    num_degenerated = len(degenerated_indices)

    if num_degenerated > 0:
        degenerated_faces = mesh.faces[degenerated_indices]
        combinatorially_degenerated_faces = \
                [f for f in degenerated_faces if len(set(f)) != len(f) ]
        num_combinatorial_degenerated_faces =\
                len(combinatorially_degenerated_faces)
    else:
        num_combinatorial_degenerated_faces = 0

    print_property("num connected components", num_cc)
    print_property("num connected surface components", num_f_cc)
    print_property("num connected volume components", num_v_cc)
    print_property("num isolated vertices", isolated_vertices, 0)
    print_property("num duplicated vertices", duplicated_vertices, 0)
    print_property("num duplicated faces", duplicated_faces, 0)
    print_property("num boundary edges", mesh.num_boundary_edges)
    print_property("num boundary loops", mesh.num_boundary_loops)
    print_property("num degenerated faces", num_degenerated, 0)
    if num_degenerated > 0:
        print_property("  combinatorially degenerated",
                       num_combinatorial_degenerated_faces, 0)
        print_property("  geometrically degenerated",
                       num_degenerated - num_combinatorial_degenerated_faces,
                       0)

    info["num_connected_components"] = num_cc
    info["num_connected_surface_components"] = num_f_cc
    info["num_connected_volume_components"] = num_v_cc
    info["num_isolated_vertices"] = isolated_vertices
    info["num_duplicated_vertices"] = duplicated_vertices
    info["num_duplicated_faces"] = duplicated_faces
    info["num_boundary_edges"] = mesh.num_boundary_edges
    info["num_boundary_loops"] = mesh.num_boundary_loops
    info["num_degenerated_faces"] = num_degenerated
    info["num_combinatorial_degenerated_faces"] =\
            num_combinatorial_degenerated_faces
    info["num_geometrical_degenerated_faces"] =\
            num_degenerated - num_combinatorial_degenerated_faces

    if mesh.dim == 2 and mesh.vertex_per_face == 3:
        tri_orientations = pymesh.get_triangle_orientations(mesh)
        num_inverted_tris = np.sum(tri_orientations < 0)
        print_property("num inverted triangles:", num_inverted_tris, 0)
        info["num_inverted_triangles"] = int(num_inverted_tris)

    if mesh.num_voxels > 0 and mesh.vertex_per_voxel == 4:
        tet_orientations = pymesh.get_tet_orientations(mesh)
        num_degenerate_tets = np.sum(tet_orientations == 0)
        num_inverted_tets = np.sum(tet_orientations < 0)
        print_property("num degenerated tets:", num_degenerate_tets, 0)
        print_property("num inverted tets:", num_inverted_tets, 0)
        info["num_degenerated_tets"] = int(num_degenerate_tets)
        info["num_inverted_tets"] = int(num_inverted_tets)

    is_closed = mesh.is_closed()
    is_edge_manifold = mesh.is_edge_manifold()
    is_vertex_manifold = mesh.is_vertex_manifold()
    is_oriented = mesh.is_oriented()
    euler = mesh.euler_characteristic
    print_property("oriented", is_oriented, True)
    print_property("closed", is_closed, True)
    print_property("edge manifold", is_edge_manifold, True)
    print_property("vertex manifold", is_vertex_manifold, True)
    print_property("euler characteristic", euler)
    info["oriented"] = is_oriented
    info["closed"] = is_closed
    info["vertex_manifold"] = is_vertex_manifold
    info["edge_manifold"] = is_edge_manifold
    info["euler_characteristic"] = euler
Beispiel #5
0
def print_extended_info(mesh, info):
    print_section_header("Extended info");

    num_cc = mesh.num_components;
    num_f_cc = mesh.num_surface_components;
    if mesh.num_voxels > 0:
        num_v_cc = mesh.num_volume_components;
    else:
        num_v_cc = 0;
    isolated_vertices = mesh.num_isolated_vertices;
    duplicated_faces = mesh.num_duplicated_faces;
    unique_vertices = pymesh.unique_rows(mesh.vertices)[0];
    duplicated_vertices = mesh.num_vertices - len(unique_vertices);

    degenerated_indices = pymesh.get_degenerated_faces(mesh);
    num_degenerated = len(degenerated_indices);

    if num_degenerated > 0:
        degenerated_faces = mesh.faces[degenerated_indices];
        combinatorially_degenerated_faces = \
                [f for f in degenerated_faces if len(set(f)) != len(f) ];
        num_combinatorial_degenerated_faces =\
                len(combinatorially_degenerated_faces);
    else:
        num_combinatorial_degenerated_faces = 0;

    print_property("num connected components", num_cc);
    print_property("num connected surface components", num_f_cc);
    print_property("num connected volume components", num_v_cc);
    print_property("num isolated vertices", isolated_vertices, 0);
    print_property("num duplicated vertices", duplicated_vertices, 0);
    print_property("num duplicated faces", duplicated_faces, 0);
    print_property("num boundary edges", mesh.num_boundary_edges);
    print_property("num boundary loops", mesh.num_boundary_loops);
    print_property("num degenerated faces", num_degenerated, 0)
    if num_degenerated > 0:
        print_property("  combinatorially degenerated",
                num_combinatorial_degenerated_faces, 0);
        print_property("  geometrically degenerated",
                num_degenerated - num_combinatorial_degenerated_faces, 0);

    info["num_connected_components"] = num_cc;
    info["num_connected_surface_components"] = num_f_cc;
    info["num_connected_volume_components"] = num_v_cc;
    info["num_isolated_vertices"] = isolated_vertices;
    info["num_duplicated_vertices"] = duplicated_vertices;
    info["num_duplicated_faces"] = duplicated_faces;
    info["num_boundary_edges"] = mesh.num_boundary_edges;
    info["num_boundary_loops"] = mesh.num_boundary_loops;
    info["num_degenerated_faces"] = num_degenerated;
    info["num_combinatorial_degenerated_faces"] =\
            num_combinatorial_degenerated_faces;
    info["num_geometrical_degenerated_faces"] =\
            num_degenerated - num_combinatorial_degenerated_faces;

    if mesh.dim == 2 and mesh.vertex_per_face == 3:
        tri_orientations = pymesh.get_triangle_orientations(mesh);
        num_inverted_tris = np.sum(tri_orientations < 0);
        print_property("num inverted triangles:", num_inverted_tris, 0);
        info["num_inverted_triangles"] = int(num_inverted_tris);

    if mesh.num_voxels > 0 and mesh.vertex_per_voxel == 4:
        tet_orientations = pymesh.get_tet_orientations(mesh);
        num_degenerate_tets = np.sum(tet_orientations == 0);
        num_inverted_tets = np.sum(tet_orientations < 0);
        print_property("num degenerated tets:", num_degenerate_tets, 0);
        print_property("num inverted tets:", num_inverted_tets, 0);
        info["num_degenerated_tets"] = int(num_degenerate_tets);
        info["num_inverted_tets"] = int(num_inverted_tets);

    is_closed = mesh.is_closed();
    is_edge_manifold = mesh.is_edge_manifold();
    is_vertex_manifold = mesh.is_vertex_manifold();
    is_oriented = mesh.is_oriented();
    euler = mesh.euler_characteristic;
    print_property("oriented", is_oriented, True);
    print_property("closed", is_closed, True)
    print_property("edge manifold", is_edge_manifold, True);
    print_property("vertex manifold", is_vertex_manifold, True);
    print_property("euler characteristic", euler);
    info["oriented"] = is_oriented;
    info["closed"] = is_closed;
    info["vertex_manifold"] = is_vertex_manifold;
    info["edge_manifold"] = is_edge_manifold;
    info["euler_characteristic"] = euler;