How to use the pymeshfix.MeshFix 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_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 / 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 / examples / cow.py View on Github external
################################################################################
cow = examples.download_cow()

# Add holes and cast to triangulated PolyData
cow['random'] = np.random.rand(cow.n_cells)
holy_cow = cow.threshold(0.9, invert=True).extract_geometry().tri_filter()
print(holy_cow)

################################################################################

# A nice camera location of the cow
cpos= [(6.56, 8.73, 22.03),
       (0.77, -0.44, 0.0),
       (-0.13, 0.93, -0.35)]

meshfix = mf.MeshFix(holy_cow)
holes = meshfix.extract_holes()

# Render the mesh and outline the holes
p = pv.Plotter()
p.add_mesh(holy_cow, color=True)
p.add_mesh(holes, color='r', line_width=8)
p.camera_position = cpos
p.enable_eye_dome_lighting() # helps depth perception
p.show()


################################################################################
# Repair the holey cow

meshfix.repair(verbose=True)
github pyvista / pymeshfix / _downloads / 700f1bf357ea69088c0a34b0aa306d26 / cow.py View on Github external
################################################################################
cow = examples.download_cow()

# Add holes and cast to triangulated PolyData
cow['random'] = np.random.rand(cow.n_cells)
holy_cow = cow.threshold(0.9, invert=True).extract_geometry().tri_filter()
print(holy_cow)

################################################################################

# A nice camera location of the cow
cpos= [(6.56, 8.73, 22.03),
       (0.77, -0.44, 0.0),
       (-0.13, 0.93, -0.35)]

meshfix = mf.MeshFix(holy_cow)
holes = meshfix.extract_holes()

# Render the mesh and outline the holes
p = pv.Plotter()
p.add_mesh(holy_cow, color=True)
p.add_mesh(holes, color='r', line_width=8)
p.camera_position = cpos
p.enable_eye_dome_lighting() # helps depth perception
p.show()


################################################################################
# Repair the holey cow

meshfix.repair(verbose=True)
github pyvista / pymeshfix / pymeshfix / examples / fix.py View on Github external
""" 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 6 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages