Exemplo n.º 1
0
def main(filename):
    mesh = Mesh(filename)

    # Freeze vertices
    for i in range(mesh.num_vertices()):
        v = mesh.vertex(i)
        v.set_is_static(True)

    # Fill holes
    hole_fill(mesh, np.pi / 6.0)
    print('[ OK ] hole filling')

    # Remesh
    remesh_triangular(mesh, short_length=0.5, long_length=2.0)
    print('[ OK ] remeshing')

    # Fairing
    implicit_fairing(mesh)
    print('[ OK ] fairing')

    # Save
    base, ext = os.path.splitext(filename)
    outfile = base + '_fairing' + ext
    mesh.save(outfile)
    print('[ OK ] saved to %s' % (outfile))
Exemplo n.º 2
0
def main(filename):
    mesh = Mesh(filename)

    # Fill holes
    hole_fill(mesh, np.pi / 6.0)
    print('[ OK ] hole filling')

    # Add noise
    for i in range(mesh.num_vertices()):
        v = mesh.vertex(i)
        pos = v.pos() + np.random.uniform(-0.01, 0.01, size=(3))
        v.set_pos(pos)

    base, ext = os.path.splitext(filename)
    outfile = base + "_noise" + ext
    mesh.save(outfile)

    # Then, denoise
    denoise_normal_bilateral(mesh, sigma_c=0.2, sigma_s=0.1, iterations=10)
    print('[ OK ] denoising')

    # Save
    base, ext = os.path.splitext(filename)
    outfile = base + "_denoise" + ext
    mesh.save(outfile)
    print('[ OK ] saved to %s' % (outfile))
Exemplo n.º 3
0
    def test_simplify_qem(self, filename):
        filename = os.path.join(CWD, model_dir, filename)
        mesh = tm.Mesh(filename)
        tm.hole_fill(mesh)

        try:
            tm.simplify_qem(mesh, mesh.num_faces() // 10)
        except Exception:
            self.fail('Failed!')
Exemplo n.º 4
0
    def test_remesh_triangular(self, filename):
        filename = os.path.join(CWD, model_dir, filename)
        mesh = tm.Mesh(filename)
        tm.hole_fill(mesh)

        try:
            tm.remesh_triangular(mesh)
        except Exception:
            self.fail('Failed!')
Exemplo n.º 5
0
    def test_denoise_l0_smooth(self, filename):
        filename = os.path.join(CWD, model_dir, filename)
        mesh = tm.Mesh(filename)
        tm.hole_fill(mesh)

        try:
            tm.denoise_l0_smooth(mesh)
        except Exception:
            self.fail('Failed!')
Exemplo n.º 6
0
    def test_implicit_fairing(self, filename):
        filename = os.path.join(CWD, model_dir, filename)
        mesh = tm.Mesh(filename)
        tm.hole_fill(mesh)

        try:
            tm.implicit_fairing(mesh)
        except Exception:
            self.fail('Failed!')
Exemplo n.º 7
0
    def test_smooth_laplacian(self, filename):
        filename = os.path.join(CWD, model_dir, filename)
        mesh = tm.Mesh(filename)
        tm.hole_fill(mesh)

        try:
            tm.smooth_laplacian(mesh)
        except Exception:
            self.fail('Failed!')
Exemplo n.º 8
0
    def test_hole_fill(self, filename):
        filename = os.path.join(CWD, model_dir, filename)
        mesh = tm.Mesh(filename)

        try:
            tm.hole_fill(mesh)
        except Exception:
            self.fail('Failed!')

        self.assertTrue(mesh.verify())