From 71f99ba58d67d61d7fa0787a28c537d3a1c91d2e Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Tue, 15 May 2012 22:57:44 -0600 Subject: [PATCH] added meaningful subd vert test --- surf/subd/cc.py | 7 ++----- surf/test/subd/cc.py | 10 +++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/surf/subd/cc.py b/surf/subd/cc.py index 63fd01b..078c17c 100644 --- a/surf/subd/cc.py +++ b/surf/subd/cc.py @@ -52,18 +52,15 @@ def refine(mesh): new_vertices.append(centroid(tmp_verts)) # For each face point, add an edge for every edge of the old face, - # connecting the face point to each edge point for the face. + # connecting the new face point to each new edge point for trunc_vid in xrange(len(new_vertices[f_vert_offset:e_vert_offset])): overall_vid = f_vert_offset + trunc_vid for edge_vid in edge_vids_for_face[trunc_vid]: new_edges.append([edge_vid, overall_vid]) - # v_vert_offset = len(new_vertices) - - # For each original point P + # For each original point P, move the original point to a new location for new_vid in xrange(f_vert_offset): # take the average F of all n face points for faces touching P ... - new_face_ids = face_ids_for_v[new_vid] F_verts = [] for fid in new_face_ids: diff --git a/surf/test/subd/cc.py b/surf/test/subd/cc.py index 76b08c9..cf28dc9 100644 --- a/surf/test/subd/cc.py +++ b/surf/test/subd/cc.py @@ -14,12 +14,16 @@ class TestCC(unittest.TestCase): 'blender', 'samples') self.cube_file_name = os.path.join(self.samples_dir, 'cube.json') self.cube = json.load(open(self.cube_file_name, 'r')) + self.cube_file_name = os.path.join(self.samples_dir, 'cube-blender-cc-1.json') + self.cube1 = json.load(open(self.cube_file_name, 'r')) - def test_refine(self): + def test_refined_vertex_location(self): p = PolygonMesh(**self.cube) p2 = cc.refine(p) - # TODO: this test is meaningless ... - p2 + v2 = [list(i) for i in p2.vertices] + for a, b in zip(sorted(self.cube1['vertices']), sorted(v2)): + for i in xrange(len(a)): + self.assertAlmostEqual(a[i], b[i]) if __name__ == '__main__': unittest.main(verbosity=3)