2012-05-08 23:32:34 -07:00
|
|
|
import json
|
|
|
|
import os
|
2012-05-07 22:17:46 -07:00
|
|
|
import unittest
|
|
|
|
|
2012-05-08 23:32:34 -07:00
|
|
|
from surf.geometry import Vertex, PolygonMesh
|
2012-05-07 22:17:46 -07:00
|
|
|
|
|
|
|
|
|
|
|
class TestEdge(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
2012-05-08 23:32:34 -07:00
|
|
|
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')
|
2012-05-29 16:33:28 -07:00
|
|
|
with open(self.cube_file_name, 'r') as cube_file:
|
|
|
|
cube_json = json.load(cube_file)
|
|
|
|
self.cube = PolygonMesh(**cube_json)
|
2012-05-07 22:17:46 -07:00
|
|
|
|
|
|
|
def test_centroid(self):
|
2012-05-08 23:32:34 -07:00
|
|
|
e = self.cube.edges[0]
|
|
|
|
v = self.cube.centroid(e)
|
|
|
|
self.assertEqual(v, Vertex(-1, 0, 1))
|
2012-05-07 22:17:46 -07:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(verbosity=3)
|