Updated files to support py3
This commit is contained in:
parent
2355deec9f
commit
d05b5164b2
@ -119,7 +119,7 @@ class Vertex(list):
|
|||||||
return Vertex(-self.x, -self.y, -self.z)
|
return Vertex(-self.x, -self.y, -self.z)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'V{0}'.format([self.x, self.y, self.z])
|
return 'V{0}'.format([self.x, self.y, self.z])
|
||||||
|
|
||||||
__str__ = __unicode__
|
__str__ = __unicode__
|
||||||
__repr__ = __unicode__
|
__repr__ = __unicode__
|
||||||
|
@ -59,7 +59,7 @@ def refine(mesh):
|
|||||||
|
|
||||||
# For each original Vertex P, move the original Vertex to a new location
|
# For each original Vertex P, move the original Vertex to a new location
|
||||||
# Here we mimic the F, R, and P spelling in the wiki article
|
# Here we mimic the F, R, and P spelling in the wiki article
|
||||||
for old_vid in xrange(f_vert_offset):
|
for old_vid in range(f_vert_offset):
|
||||||
# take the average F of all n face Vertices for faces touching P ...
|
# take the average F of all n face Vertices for faces touching P ...
|
||||||
F_verts = []
|
F_verts = []
|
||||||
for old_fid in mesh.faces_for_vert[old_vid]:
|
for old_fid in mesh.faces_for_vert[old_vid]:
|
||||||
@ -88,12 +88,12 @@ def refine(mesh):
|
|||||||
|
|
||||||
# For each face point, add an edge connecting the new face point to each
|
# For each face point, add an edge connecting the new face point to each
|
||||||
# new edge point
|
# new edge point
|
||||||
for fvid, evids in evid_for_fvid.iteritems():
|
for fvid, evids in evid_for_fvid.items():
|
||||||
for evid in evids:
|
for evid in evids:
|
||||||
new_edges.append([fvid, evid])
|
new_edges.append([fvid, evid])
|
||||||
|
|
||||||
# to define new faces need to know the following for each new face:
|
# to define new faces need to know the following for each new face:
|
||||||
for fvid in xrange(f_vert_offset, e_vert_offset):
|
for fvid in range(f_vert_offset, e_vert_offset):
|
||||||
# new face_vid (1 vid)
|
# new face_vid (1 vid)
|
||||||
|
|
||||||
# vid connected to fvid (iterate over, use 1 vid periteration)
|
# vid connected to fvid (iterate over, use 1 vid periteration)
|
||||||
|
@ -12,7 +12,8 @@ class TestEdge(unittest.TestCase):
|
|||||||
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')
|
||||||
self.cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
self.cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
||||||
cube_json = json.load(open(self.cube_file_name, 'r'))
|
with open(self.cube_file_name, 'r') as cube_file:
|
||||||
|
cube_json = json.load(cube_file)
|
||||||
self.cube = PolygonMesh(**cube_json)
|
self.cube = PolygonMesh(**cube_json)
|
||||||
|
|
||||||
def test_centroid(self):
|
def test_centroid(self):
|
||||||
|
@ -11,8 +11,9 @@ 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')
|
||||||
self.cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
||||||
self.cube = json.load(open(self.cube_file_name, 'r'))
|
with open(cube_file_name) as cube_file:
|
||||||
|
self.cube = json.load(cube_file)
|
||||||
|
|
||||||
def test_cube_load(self):
|
def test_cube_load(self):
|
||||||
p = PolygonMesh(**self.cube)
|
p = PolygonMesh(**self.cube)
|
||||||
|
@ -12,18 +12,20 @@ class TestCC(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, os.pardir,
|
self.samples_dir = os.path.join(path, os.pardir, os.pardir, os.pardir,
|
||||||
'blender', 'samples')
|
'blender', 'samples')
|
||||||
self.cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
cube_file_name = os.path.join(self.samples_dir, 'cube.json')
|
||||||
self.cube = json.load(open(self.cube_file_name, 'r'))
|
with open(cube_file_name, 'r') as cube_file:
|
||||||
self.cube_file_name = os.path.join(self.samples_dir,
|
self.cube = json.load(cube_file)
|
||||||
|
cube_file_name = os.path.join(self.samples_dir,
|
||||||
'cube-blender-cc-1.json')
|
'cube-blender-cc-1.json')
|
||||||
self.cube1 = json.load(open(self.cube_file_name, 'r'))
|
with open(cube_file_name, 'r') as cube_file:
|
||||||
|
self.cube1 = json.load(cube_file)
|
||||||
|
|
||||||
def test_refined_vertex_location(self):
|
def test_refined_vertex_location(self):
|
||||||
p = PolygonMesh(**self.cube)
|
p = PolygonMesh(**self.cube)
|
||||||
p2 = cc.refine(p)
|
p2 = cc.refine(p)
|
||||||
v2 = [list(i) for i in p2.vertices]
|
v2 = [list(i) for i in p2.vertices]
|
||||||
for a, b in zip(sorted(self.cube1['vertices']), sorted(v2)):
|
for a, b in zip(sorted(self.cube1['vertices']), sorted(v2)):
|
||||||
for i in xrange(len(a)):
|
for i in range(len(a)):
|
||||||
self.assertAlmostEqual(a[i], b[i])
|
self.assertAlmostEqual(a[i], b[i])
|
||||||
|
|
||||||
def test_vert_count(self):
|
def test_vert_count(self):
|
||||||
|
@ -2,10 +2,10 @@ from surf.util import cube
|
|||||||
from surf.subd import cc
|
from surf.subd import cc
|
||||||
|
|
||||||
polygon = cube()
|
polygon = cube()
|
||||||
print polygon
|
print(polygon)
|
||||||
|
|
||||||
refined_poly = cc.refine(polygon)
|
refined_poly = cc.refine(polygon)
|
||||||
print refined_poly
|
print(refined_poly)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# import pylab
|
# import pylab
|
||||||
|
Loading…
Reference in New Issue
Block a user