added unittest to verify good connectivity generation; should be failing tests
This commit is contained in:
parent
3fb1c97403
commit
3f927477e9
1
blender/samples/cube-no-connectivity.json
Normal file
1
blender/samples/cube-no-connectivity.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"edges": [[4, 5], [5, 1], [1, 0], [0, 4], [5, 6], [6, 2], [2, 1], [6, 7], [7, 3], [3, 2], [7, 4], [0, 3]], "vertices": [[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0], [-1.0, -1.0, 1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, -1.0, 1.0]], "faces": [[4, 5, 1, 0], [5, 6, 2, 1], [6, 7, 3, 2], [7, 4, 0, 3], [0, 1, 2, 3], [7, 6, 5, 4]]}
|
@ -207,6 +207,8 @@ class PolygonMesh(object):
|
|||||||
'vertices': self.vertices,
|
'vertices': self.vertices,
|
||||||
'edges': self.edges,
|
'edges': self.edges,
|
||||||
'faces': self.faces,
|
'faces': self.faces,
|
||||||
|
'faces_for_vert': self.faces_for_vert,
|
||||||
|
'edges_for_vert': self.edges_for_vert,
|
||||||
}
|
}
|
||||||
return json.dumps(d)
|
return json.dumps(d)
|
||||||
|
|
||||||
|
@ -11,17 +11,38 @@ class TestPM(unittest.TestCase):
|
|||||||
path, file_name = os.path.split(__file__)
|
path, file_name = os.path.split(__file__)
|
||||||
self.samples_dir = os.path.join(path, os.pardir, os.pardir,
|
self.samples_dir = os.path.join(path, os.pardir, os.pardir,
|
||||||
'blender', 'samples')
|
'blender', 'samples')
|
||||||
cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
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:
|
with open(cube_file_name) as cube_file:
|
||||||
self.cube = json.load(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):
|
def test_cube_load(self):
|
||||||
p = PolygonMesh(**self.cube)
|
p = PolygonMesh(**self.full_cube)
|
||||||
v = p.vertices[0]
|
v = p.vertices[0]
|
||||||
self.assertAlmostEqual(v.x, -1.0)
|
self.assertAlmostEqual(v.x, -1.0)
|
||||||
self.assertAlmostEqual(v.y, -1.0)
|
self.assertAlmostEqual(v.y, -1.0)
|
||||||
self.assertAlmostEqual(v.z, -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))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(verbosity=3)
|
unittest.main(verbosity=3)
|
||||||
|
Loading…
Reference in New Issue
Block a user