Apply a FilterΒΆ

This example shows how to apply a filter using the pmeshlab.MeshSet.apply_filter() function of the MeshSet class. This specific test applies the filter convex_hull, which uses as input the current mesh of the MeshSet, and it creates a new one that is the convex hull of the input mesh. The filter does not take any parameter, and automatically changes the current mesh of the MeshSet when it is executed.

This script can be executed by running the following command:

pytest --pyargs pymeshlab -k 'apply_filter'


import pymeshlab

def example_apply_filter():
    # lines needed to run this specific example
    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()

    # load mesh
    ms.load_new_mesh(base_path + "airplane.obj")

    # apply convex hull filter to the current selected mesh (last loaded)

    assert ms.number_meshes() == 2

    # save the current selected mesh
    ms.save_current_mesh(output_path + "convex_hull.obj")

    # get a reference to the current selected mesh
    m = ms.current_mesh()


    assert m.vertex_number() == 455