Exemple #1
0
        void add_all_edges(int ei, HashSet <int> edge_set)
        {
            Index2i et = fillmesh.GetEdgeT(ei);
            Index3i te = fillmesh.GetTriEdges(et.a);

            edge_set.Add(te.a); edge_set.Add(te.b); edge_set.Add(te.c);
            te = fillmesh.GetTriEdges(et.b);
            edge_set.Add(te.a); edge_set.Add(te.b); edge_set.Add(te.c);
        }
        EdgeLoop select_loop_tris_hint(MeshBoundaryLoops loops)
        {
            var hint_edges = new HashSet <int>();

            foreach (int tid in BorderHintTris)
            {
                if (Mesh.IsTriangle(tid) == false)
                {
                    continue;
                }

                Index3i et = Mesh.GetTriEdges(tid);
                for (int j = 0; j < 3; ++j)
                {
                    if (Mesh.IsBoundaryEdge(et[j]))
                    {
                        hint_edges.Add(et[j]);
                    }
                }
            }


            int N         = loops.Count;
            int best_loop = -1;
            int max_votes = 0;

            for (int li = 0; li < N; ++li)
            {
                int      votes = 0;
                EdgeLoop l     = loops[li];
                foreach (int eid in l.Edges)
                {
                    if (hint_edges.Contains(eid))
                    {
                        votes++;
                    }
                }
                if (votes > max_votes)
                {
                    best_loop = li;
                    max_votes = votes;
                }
            }

            if (best_loop == -1)
            {
                return(null);
            }

            return(loops[best_loop]);
        }