def example_apply_filter_parameters_percentage():
    # lines needed to run this specific example
    print('\n')
    from . import samples_common
    base_path = samples_common.samples_absolute_path()
    output_path = samples_common.test_output_path()

    # create a new MeshSet
    ms = pymeshlab.MeshSet()

    ms.load_new_mesh(base_path + "rangemaps/face000.ply")

    assert ms.number_meshes() == 1

    assert ms.current_mesh().face_number() == 166259

    # create a new object of type Percentage, with value 50%
    p = pymeshlab.Percentage(50)

    # apply the filter that will remove connected components having diameter less than 50%
    # of the diameter of the entire mesh
    ms.apply_filter('remove_isolated_pieces_wrt_diameter', mincomponentdiag=p)

    assert ms.current_mesh().face_number() == 161606

    ms.save_current_mesh(output_path + 'face000_clean_by_diameter.ply')
示例#2
0
def test_remove_isolated_pieces_diameter():
    print('\n')
    base_path = samples_common.samples_absolute_path()
    output_path = samples_common.test_output_path()
    ms = ml.MeshSet()

    ms.load_new_mesh(base_path + "rangemaps/face000.ply")

    assert ms.number_meshes() == 1

    assert ms.current_mesh().face_number() == 166259

    p = ml.Percentage(50)

    ms.apply_filter('remove_isolated_pieces_wrt_diameter', mincomponentdiag=p)

    assert ms.current_mesh().face_number() == 161606

    ms.save_current_mesh(output_path + 'face000_clean_by_diameter.ply')
示例#3
0
"""pymeshlab interoperability example:
Surface reconstruction by ball pivoting"""
import pymeshlab, vedo

pts = vedo.Mesh(vedo.dataurl + 'cow.vtk').points()  # numpy array of vertices

m = pymeshlab.Mesh(vertex_matrix=pts)

ms = pymeshlab.MeshSet()
ms.add_mesh(m)

p = pymeshlab.Percentage(2)
ms.surface_reconstruction_ball_pivoting(ballradius=p)
# ms.compute_normals_for_point_sets()

mlab_mesh = ms.current_mesh()
reco_mesh = vedo.Mesh(mlab_mesh).computeNormals().flat().backColor('t')

vedo.show(
    __doc__,
    vedo.Points(pts),
    reco_mesh,
    axes=True,
    bg2='blue9',
    title="vedo + pymeshlab",
)

################################################################################
# Full list of filters, https://pymeshlab.readthedocs.io/en/latest/filter_list.html
#
# MeshLab offers plenty of useful filters, among which: