def subdivision(v, f, level=1): for _ in range(level): # subdivision v, f = igl.upsample(v, f) # normalize v /= np.linalg.norm(v, axis=1)[:, np.newaxis] return v, f
def run(self): geo = self.get_input_geometry_ref(0) if geo is None: return if geo.getNumFaces() == 0 or geo.getNumVertexes() == 0: return itera = self.get_property("Iteration") if itera == 0: return mesh = geo.getTriangulateMesh() v = mesh.points() f = mesh.face_vertex_indices() mt = self.get_property("Method") if mt == "Upsample": for i in range(itera): v, f = igl.upsample(v, f) elif mt == "Loop": for i in range(itera): v, f = igl.loop(v, f) self.geo = Mesh() self.geo.addVertices(v) self.geo.addFaces(f)
def test_upsample(self): nv, nf = igl.upsample(self.v1, self.f1) self.assertEqual(nv.dtype, self.v1.dtype) self.assertEqual(nf.dtype, self.f1.dtype) self.assertEqual(nv.shape[1], self.v1.shape[1]) self.assertEqual(nf.shape[1], self.f1.shape[1])
def test_upsample(self): nv, nf = igl.upsample(self.v1, self.f1) self.assertEqual(nv.dtype, self.v1.dtype) self.assertEqual(nf.dtype, self.f1.dtype) self.assertEqual(nv.shape[1], self.v1.shape[1]) self.assertEqual(nf.shape[1], self.f1.shape[1]) self.assertTrue(nv.flags.c_contiguous) self.assertTrue(nf.flags.c_contiguous)