def _computeUnindexedVertexes(self):
## Given (Nv, 3, 3) array of vertexes-indexed-by-face, convert backward to unindexed vertexes
## This is done by collapsing into a list of 'unique' vertexes (difference < 1e-14)
## I think generally this should be discouraged..
faces = self._vertexesIndexedByFaces
verts = {} ## used to remember the index of each vertex position
self._faces = np.empty(faces.shape[:2], dtype=np.uint)
self._vertexes = []
self._vertexFaces = []
self._faceNormals = None
self._vertexNormals = None
for i in xrange(faces.shape[0]):
face = faces[i]
inds = []
for j in range(face.shape[0]):
pt = face[j]
pt2 = tuple([round(x*1e14) for x in pt]) ## quantize to be sure that nearly-identical points will be merged
index = verts.get(pt2, None)
if index is None:
#self._vertexes.append(QtGui.QVector3D(*pt))
self._vertexes.append(pt)
self._vertexFaces.append([])
index = len(self._vertexes)-1
verts[pt2] = index
self._vertexFaces[index].append(i) # keep track of which vertexes belong to which faces
self._faces[i,j] = index
self._vertexes = np.array(self._vertexes, dtype=float)
#def _setUnindexedFaces(self, faces, vertexes, vertexColors=None, faceColors=None):
#self._vertexes = vertexes #[QtGui.QVector3D(*v) for v in vertexes]
#self._faces = faces.astype(np.uint)
#self._edges = None
#self._vertexFaces = None
#self._faceNormals = None
#self._vertexNormals = None
#self._vertexColors = vertexColors
#self._faceColors = faceColors
评论列表
文章目录