How to use the pymeshfix.examples.bunny_scan function in pymeshfix

To help you get started, we’ve selected a few pymeshfix examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyvista / pymeshfix / tests / test_pyx_meshfix.py View on Github external
import pytest
import pyvista as pv

from pymeshfix import _meshfix
from pymeshfix import examples

bunny = pv.PolyData(examples.bunny_scan)


def test_load_and_save_file(tmpdir):
    meshfix = _meshfix.PyTMesh()
    meshfix.load_file(examples.bunny_scan)

    with pytest.raises(Exception):
        meshfix.load_file(examples.bunny_scan)

    v, f = meshfix.return_arrays()
    assert f.shape[0] == bunny.n_faces

    # test saving
    filename = str(tmpdir.mkdir("tmpdir").join('tmp.ply'))
    meshfix.save_file(filename)
    new_bunny = pv.PolyData(filename)
github pyvista / pymeshfix / tests / test_withvtk.py View on Github external
def test_repair_vtk():
    meshin = pv.PolyData(bunny_scan)
    meshfix = pymeshfix.MeshFix(meshin)
    meshfix.repair()

    # check arrays and output mesh
    assert np.any(meshfix.v)
    assert np.any(meshfix.f)
    meshout = meshfix.mesh
    assert meshfix.mesh.n_points

    # test for any holes
    pdata = meshout.extract_edges(non_manifold_edges=False, feature_edges=False,
                                  manifold_edges=False)
    assert pdata.n_points == 0
github pyvista / pymeshfix / tests / test_pyx_meshfix.py View on Github external
def test_fill_small_boundaries():
    meshfix = _meshfix.PyTMesh()
    meshfix.load_file(examples.bunny_scan)
    ninit_boundaries = meshfix.boundaries()

    meshfix.fill_small_boundaries(refine=False)
    assert meshfix.boundaries() < ninit_boundaries
github marcomusy / vtkplotter / examples / other / meshfix.py View on Github external
########################################### imports
from vtkplotter import Plotter, boundaries
try:
	# Credits:
	# https://github.com/MarcoAttene/MeshFix-V2.1
	# https://github.com/akaszynski/pymeshfix
	from pymeshfix._meshfix import PyTMesh, Repair
	from pymeshfix.examples import bunny_scan
except:
	print('Install pymeshfix with: pip install pymeshfix')
	exit()

########################################### PyTMesh repair
inputmesh = bunny_scan # 'pymeshfix/examples/StanfordBunny.ply'
ouputmesh = 'meshfix_repaired.ply' # try e.g. vtkconvert -to vtk repaired.ply

tm = PyTMesh()
tm.LoadFile(inputmesh)
Repair(tm, verbose=True, joincomp=True, removeSmallestComponents=True)
tm.SaveFile(ouputmesh)

########################################### vtkplotter
vp = Plotter(shape=(2,1))

act_original = vp.load(inputmesh)
bo = boundaries(act_original)

act_repaired = vp.load(ouputmesh)
br = boundaries(act_repaired)
github pyvista / pymeshfix / pymeshfix / examples / fix.py View on Github external
def with_vtk(plot=True):
    """ Tests VTK interface and mesh repair of Stanford Bunny Mesh """
    mesh = pv.PolyData(bunny_scan)
    meshfix = pymeshfix.MeshFix(mesh)
    if plot:
        print('Plotting input mesh')
        meshfix.plot()
    meshfix.repair()
    if plot:
        print('Plotting repaired mesh')
        meshfix.plot()

    return meshfix.mesh
github pyvista / pymeshfix / pymeshfix / examples / fix.py View on Github external
if __name__ == '__main__':
    """ Functional Test: vtk and native """
    t_start = time.time()
    out_file = 'repaired.ply'
    native()
    outmesh = pv.PolyData(out_file)
    os.remove(out_file)
    assert outmesh.n_points

    # test for any holes
    pdata = outmesh.extract_edges(non_manifold_edges=False, feature_edges=False,
                                  manifold_edges=False)
    assert pdata.n_points == 0

    # test vtk
    meshin = pv.PolyData(bunny_scan)
    meshfix = pymeshfix.MeshFix(meshin)
    meshfix.repair()

    # check arrays and output mesh
    assert np.any(meshfix.v)
    assert np.any(meshfix.f)
    meshout = meshfix.mesh
    assert meshfix.mesh.n_points

    # test for any holes
    pdata = meshout.extract_edges(non_manifold_edges=False, feature_edges=False,
                                  manifold_edges=False)
    print('PASS in %f seconds' % (time.time() - t_start))

pymeshfix

Repair triangular meshes using MeshFix

GPL-3.0
Latest version published 5 months ago

Package Health Score

69 / 100
Full package analysis

Similar packages