In the middle of implementing Catmull-Clark
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from .vertex import TestVertex
|
||||
from .edge import TestEdge
|
||||
from .polymesh import TestPM
|
||||
from .subd.cc import TestCC
|
||||
|
||||
|
||||
# I only use the convoluted Class.__name__ to pass pyflakes (it complains about
|
||||
@@ -10,4 +11,5 @@ __all__ = [
|
||||
TestVertex.__name__,
|
||||
TestEdge.__name__,
|
||||
TestPM.__name__,
|
||||
TestCC.__name__,
|
||||
]
|
||||
|
||||
+12
-10
@@ -1,22 +1,24 @@
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from surf.geometry import Vertex, Edge
|
||||
from surf.geometry import Vertex, PolygonMesh
|
||||
|
||||
|
||||
class TestEdge(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.origin = Vertex(0, 0, 0)
|
||||
self.v1 = Vertex(-1, -1, -1)
|
||||
self.v2 = Vertex(1, 1, 1)
|
||||
|
||||
self.v3 = Vertex(5, 4, 3)
|
||||
self.v4 = Vertex(10, -2, 13)
|
||||
self.v5 = Vertex(-4, 15.3, 100)
|
||||
path, file_name = os.path.split(__file__)
|
||||
self.samples_dir = os.path.join(path, os.pardir, os.pardir,
|
||||
'blender', 'samples')
|
||||
self.cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
||||
cube_json = json.load(open(self.cube_file_name, 'r'))
|
||||
self.cube = PolygonMesh(**cube_json)
|
||||
|
||||
def test_centroid(self):
|
||||
e = Edge(self.v1, self.v3)
|
||||
self.assertEqual(e.centroid, Vertex(2, 1.5, 1))
|
||||
e = self.cube.edges[0]
|
||||
v = self.cube.centroid(e)
|
||||
self.assertEqual(v, Vertex(-1, 0, 1))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -17,9 +17,9 @@ class TestPM(unittest.TestCase):
|
||||
def test_cube_load(self):
|
||||
p = PolygonMesh(**self.cube)
|
||||
v = p.vertices[0]
|
||||
self.assertAlmostEqual(v[0], -1.0)
|
||||
self.assertAlmostEqual(v[1], -1.0)
|
||||
self.assertAlmostEqual(v[2], -1.0)
|
||||
self.assertAlmostEqual(v.x, -1.0)
|
||||
self.assertAlmostEqual(v.y, -1.0)
|
||||
self.assertAlmostEqual(v.z, -1.0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from .cc import TestCC
|
||||
|
||||
__all__ = [
|
||||
TestCC.__name__,
|
||||
]
|
||||
@@ -0,0 +1,24 @@
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from surf.geometry import PolygonMesh
|
||||
from surf.subd import cc
|
||||
|
||||
|
||||
class TestCC(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
path, file_name = os.path.split(__file__)
|
||||
self.samples_dir = os.path.join(path, os.pardir, os.pardir, os.pardir,
|
||||
'blender', 'samples')
|
||||
self.cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
||||
self.cube = json.load(open(self.cube_file_name, 'r'))
|
||||
|
||||
def test_refine(self):
|
||||
p = PolygonMesh(**self.cube)
|
||||
p2 = cc.refine(p)
|
||||
print p2
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=3)
|
||||
Reference in New Issue
Block a user