Started adding connectivity generation

- also added a test file in the blender folder
This commit is contained in:
Stephen M. McQuay 2012-06-07 22:24:52 -06:00
parent 15ffd82cad
commit a45c84c183
2 changed files with 12 additions and 6 deletions

View 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]]}

View File

@ -175,25 +175,30 @@ class PolygonMesh(object):
@property @property
def edges_for_face(self): def edges_for_face(self):
"""returns a list of edge indices for a given face index.""" """returns a list of edge indices for a given face index."""
# XXX
if self._edges_for_face is None: if self._edges_for_face is None:
# TODO: eventually support generating this ourselves ... self._edges_for_face = [[] for i in range(len(self.faces))]
raise NotImplementedError
return self._edges_for_face return self._edges_for_face
@property @property
def edges_for_vert(self): def edges_for_vert(self):
"""returns a list of edge indices for a given vertex index.""" """returns a list of edge indices for a given vertex index."""
if self._edges_for_vert is None: if self._edges_for_vert is None:
# TODO: eventually support generating this ourselves ... self._edges_for_vert = [[] for i in range(len(self.vertices))]
raise NotImplementedError for i, edge in enumerate(self.edges):
for vid in edge:
self._edges_for_vert[vid].append(i)
return self._edges_for_vert return self._edges_for_vert
@property @property
def faces_for_vert(self): def faces_for_vert(self):
"""returns a list of face indices for a given vert index.""" """returns a list of face indices for a given vert index."""
if self._faces_for_vert is None: if self._faces_for_vert is None:
# TODO: eventually support generating this ourselves ... self._faces_for_vert = [[] for i in range(len(self.vertices))]
raise NotImplementedError for i, face in enumerate(self.faces):
for vid in face:
self._faces_for_vert[vid].append(i)
return self._faces_for_vert return self._faces_for_vert
def __unicode__(self): def __unicode__(self):