def create_initial_parameterizations(self):
        self.begin_operation('(Step 2 of 7) Forming initial chart parameterizations...')
        new_uv_indices = numpy.zeros(shape=(len(self.all_vert_indices), 3), dtype=numpy.int32)
        new_uvs = []
        new_uvs_offset = 0
        
        for (face, facedata) in self.facegraph.nodes_iter(data=True):
            border_edges = facedata['edges']
            chart_tris = self.all_vert_indices[facedata['tris']]
    
            unique_verts = set(chain.from_iterable(chart_tris))
            border_verts = set(chain.from_iterable(border_edges))
            interior_verts = list(unique_verts.difference(border_verts))
                    
            bordergraph = nx.from_edgelist(border_edges)
            bigcycle = list(super_cycle(bordergraph))
            boundary_path = []
            for i in range(len(bigcycle)-1):
                boundary_path.append((bigcycle[i], bigcycle[i+1]))
            boundary_path.append((bigcycle[len(bigcycle)-1], bigcycle[0]))
            assert(len(boundary_path) == len(border_edges))
    
            total_dist = 0
            for (v1, v2) in boundary_path:
                total_dist += v3dist(self.all_vertices[v1], self.all_vertices[v2])
            
            vert2uv = {}
            curangle = 0
            for edge in boundary_path:
                angle = v3dist(self.all_vertices[edge[0]], self.all_vertices[edge[1]]) / total_dist
                curangle += angle * 2 * math.pi
                x, y = (math.sin(curangle) + 1) / 2.0, (math.cos(curangle) + 1.0) / 2.0
                vert2uv[edge[0]] = (x,y)
            
            if len(interior_verts) > 0:
            
                vert2idx = {}
                for i, v in enumerate(interior_verts):
                    vert2idx[v] = i
                
                A = numpy.zeros(shape=(len(interior_verts), len(interior_verts)), dtype=numpy.float32)
                Bu = numpy.zeros(len(interior_verts), dtype=numpy.float32)
                Bv = numpy.zeros(len(interior_verts), dtype=numpy.float32)
                sumu = numpy.zeros(len(interior_verts), dtype=numpy.float32)
                
                for edge in self.vertexgraph.subgraph(unique_verts).edges_iter():
                    v1, v2 = edge
                    if v1 in border_verts and v2 in border_verts:
                        continue
                    
                    edgelen = v3dist(self.all_vertices[v1], self.all_vertices[v2])
                    if v1 in border_verts:
                        Bu[vert2idx[v2]] += edgelen * vert2uv[v1][0]
                        Bv[vert2idx[v2]] += edgelen * vert2uv[v1][1]
                        sumu[vert2idx[v2]] += edgelen
                    elif v2 in border_verts:
                        Bu[vert2idx[v1]] += edgelen * vert2uv[v2][0]
                        Bv[vert2idx[v1]] += edgelen * vert2uv[v2][1]
                        sumu[vert2idx[v1]] += edgelen
                    else:
                        A[vert2idx[v1]][vert2idx[v2]] = -1 * edgelen
                        A[vert2idx[v2]][vert2idx[v1]] = -1 * edgelen
                        sumu[vert2idx[v1]] += edgelen
                        sumu[vert2idx[v2]] += edgelen
                
                Bu.shape = (len(Bu), 1)
                Bv.shape = (len(Bv), 1)
                sumu.shape = (len(sumu), 1)
                
                A /= sumu
                Bu /= sumu
                Bv /= sumu
                try: numpy.fill_diagonal(A, 1)
                except __HOLE__:
                    for i in xrange(len(A)):
                        A[i][i] = 1
                
                interior_us = numpy.linalg.solve(A, Bu)
                interior_vs = numpy.linalg.solve(A, Bv)
                for (i, (u, v)) in enumerate(zip(interior_us, interior_vs)):
                    vert2uv[interior_verts[i]] = (u[0], v[0])
                    
            new_uvs.append(vert2uv.values())
            newvert2idx = dict(zip(vert2uv.keys(), range(new_uvs_offset, new_uvs_offset + len(vert2uv))))
            for tri in facedata['tris']:
                for i, v in enumerate(self.all_vert_indices[tri]):
                    new_uv_indices[tri][i] = newvert2idx[v]
            new_uvs_offset += len(vert2uv)
            self.facegraph.node[face]['vert2uvidx'] = newvert2idx
            
        self.new_uvs = numpy.concatenate(new_uvs)
        self.new_uv_indices = new_uv_indices
        
        self.end_operation()
dataset/ETHPy150Open pycollada/meshtool/meshtool/filters/simplify_filters/sander_simplify.py/SanderSimplify.create_initial_parameterizations