def test_read_off(self):
     v, f, n = igl.read_off(self.test_path + "bunny.off")
     self.assertTrue(type(v) == type(f) == type(n) == np.ndarray)
     self.assertTrue(v.shape == (3485, 3) and n.shape == (0, 0) and f.shape == (6966, 3))
     self.assertTrue(v.dtype == np.float64)
     v, f, n = igl.read_off(self.test_path + "bunny.off", read_normals=False, dtype="float32")
     self.assertTrue(v.shape == (3485, 3) and n.shape == (0, 0) and f.shape == (6966, 3))
     self.assertTrue(v.dtype == np.float32)
     self.assertTrue(v.flags.c_contiguous)
     self.assertTrue(f.flags.c_contiguous)
     self.assertTrue(n.flags.c_contiguous)
    def setUp(self):
        # Some global datastructures to use in the tests
        np.random.seed(42)
        self.test_path = os.path.join(os.path.dirname(
            os.path.realpath(__file__)), "../data/")
        self.v1, self.f1, self.n1 = igl.read_off(os.path.join(self.test_path, "bunny.off"))
        self.v2, self.f2, self.n2 = igl.read_off(os.path.join(self.test_path, "fertility.off"))

        self.v = np.random.rand(10, 3).astype(self.v1.dtype)
        self.t = np.random.rand(10, 4)
        self.f = np.random.randint(0, 10, size=(20, 3), dtype=self.f1.dtype)
        self.g = np.random.randint(0, 10, size=(20, 4), dtype="int32")
    def test_slim(self):
        v, f, _ = igl.read_off("data/camelhead.off")
        b = igl.boundary_loop(f)
        thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis]
        bc = np.concatenate([np.cos(thetas), np.sin(thetas), np.zeros_like(thetas)], axis=1)
        uv_initial_guess = igl.harmonic_weights(v, f, b, bc, 1)

        slim = igl.SLIM(v, f, uv_initial_guess[:, :2], b, bc[:, :2], igl.SLIM_ENERGY_TYPE_ARAP, 0.0)
        slim.solve(1)
        v2 = slim.vertices()
        self.assertEqual(v2.shape[0], v.shape[0])
        self.assertTrue(v2.flags.c_contiguous)
    def test_arap1(self):
        v, f, _ = igl.read_off("data/camelhead.off")
        b = igl.boundary_loop(f)
        thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis]
        bc = np.concatenate([np.cos(thetas), np.sin(thetas), np.zeros_like(thetas)], axis=1)
        uv_initial_guess = igl.harmonic_weights(v, f, b, bc, 1)

        arap1 = igl.ARAP(v, f, 2, b)
        vp1 = arap1.solve(bc[:, :2], uv_initial_guess[:, :2])
        self.assertEqual(vp1.shape[0], v.shape[0])
        self.assertTrue(vp1.flags.c_contiguous)

        arap2 = igl.ARAP(v, f, 3, b)
        vp2 = arap2.solve(bc, uv_initial_guess)
        self.assertEqual(vp2.shape[0], v.shape[0])
        self.assertTrue(vp2.flags.c_contiguous)
Пример #5
0
    def launch(self):
        display(self.renderer)
        for w in self.widgets:
            display(w)


# Tutorial 102_DrawMesh.py

import sys, os
# Add the igl library to the modules search path
sys.path.insert(0, os.getcwd() + "/../")
import igl

# Load a mesh in OFF format
v, f, _ = igl.read_off(igl.tutorial_path + "bunny.off", read_normals=False)

# Plot the mesh
viewer = igl.Viewer()
viewer.set_mesh(v, f)
viewer.launch()

#from pythreejs import *
#import numpy as np
#from IPython.display import display
#from ipywidgets import HTML, Text, Output, VBox
#from traitlets import link, dlink

#ball = Mesh(geometry=SphereGeometry(radius=1),
#            material=MeshLambertMaterial(color='red'),
#            position=[2, 1, 0])