a playground adding surface subdivision methods to scipy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB

import json
import os
import unittest
from surf.geometry import PolygonMesh
class TestPM(unittest.TestCase):
def setUp(self):
path, file_name = os.path.split(__file__)
self.samples_dir = os.path.join(path, os.pardir, os.pardir,
'blender', 'samples')
full_cube_file_name = os.path.join(self.samples_dir, 'cube.json')
with open(full_cube_file_name) as cube_file:
self.full_cube = json.load(cube_file)
cube_file_name = os.path.join(self.samples_dir, 'cube-no-connectivity.json')
with open(cube_file_name) as cube_file:
self.skeleton_cube = json.load(cube_file)
self.skel = PolygonMesh(**self.skeleton_cube)
self.cube = PolygonMesh(**self.full_cube)
def test_cube_load(self):
p = PolygonMesh(**self.full_cube)
v = p.vertices[0]
self.assertAlmostEqual(v.x, -1.0)
self.assertAlmostEqual(v.y, -1.0)
self.assertAlmostEqual(v.z, -1.0)
def test_connectivity(self):
self.skel.faces_for_vert
self.skel.edges_for_vert
self.skel.edges_for_face
self.skel.faces_for_edge
def test_faces_for_vert(self):
for pi, qi in zip(self.skel.faces_for_vert, self.cube.faces_for_vert):
self.assertEqual(sorted(pi), sorted(qi))
def test_edges_for_vert(self):
for pi, qi in zip(self.skel.edges_for_vert, self.cube.edges_for_vert):
self.assertEqual(sorted(pi), sorted(qi))
def test_edges_for_face(self):
for pi, qi in zip(self.skel.edges_for_face, self.cube.edges_for_face):
self.assertEqual(sorted(pi), sorted(qi))
def test_faces_for_edge(self):
for pi, qi in zip(self.skel.faces_for_edge, self.cube.faces_for_edge):
self.assertEqual(sorted(pi), sorted(qi))
if __name__ == '__main__':
unittest.main(verbosity=3)