コード例 #1
0
ファイル: draw-vbo-ext.cpp プロジェクト: EikaNN/FIB-G
void cluster(const Object& obj, vector<vector<int> >& VF, vector<vector<Cluster> >& clusters)
{
    clusters.clear();
    clusters.resize(VF.size());
    // group vertices in V:{F} into clusters, according to per-face normals
    for (unsigned int i=0; i<VF.size(); ++i) // for each vertex 
    {
        vector<int>& faces = VF[i]; 
        // assign first face to cluster 0
        Cluster cluster; 
        int f = faces[0];
        cluster.faces.push_back(f); 
        cluster.normal = obj.faces()[f].normal();
        clusters[i].push_back(cluster);
        // for each remaining face in V:{F}, try to add to an existing cluster or create new cluster
        for (unsigned int j=1; j<faces.size(); ++j)
        {
            f = faces[j];
            int index = findCluster(obj, f, clusters[i]); 
            if (index>=0) // add to an existing cluster
            {
                clusters[i][index].faces.push_back(f); 
                clusters[i][index].normal +=  obj.faces()[f].normal();           
            }
            else    // add to new cluster
            {
                Cluster cluster; 
                cluster.faces.push_back(f); 
                cluster.normal = obj.faces()[f].normal();
                clusters[i].push_back(cluster);
            }
        }
    }
}
コード例 #2
0
ファイル: compound.c プロジェクト: emdenrg/graphviz
static graph_t *getCluster(graph_t * g, char *cluster_name)
#endif
{
    Agraph_t* sg;

    if (!cluster_name || (*cluster_name == '\0'))
	return NULL;
#ifdef WITH_CGRAPH
    sg = findCluster (map, cluster_name);
#else
    sg = agfindsubg(g, cluster_name);
#endif
    if (sg == NULL) {
	agerr(AGWARN, "cluster named %s not found\n", cluster_name);
    }
    return sg;
}