Esempio n. 1
0
        public static void GrowByVertexArea(TriMesh mesh)
        {
            Queue <TriMesh.Vertex> queue = new Queue <HalfEdgeMesh.Vertex>();

            double[] avgArea = new double[mesh.Vertices.Count];
            foreach (var v in mesh.Vertices)
            {
                avgArea[v.Index] = TriMeshUtil.ComputeAreaOneRing(v);
                if (v.Traits.SelectedFlag != 0)
                {
                    queue.Enqueue(v);
                }
            }

            double k = 0.896;

            while (queue.Count != 0)
            {
                TriMesh.Vertex center = queue.Dequeue();
                foreach (var round in center.Vertices)
                {
                    if (round.Traits.SelectedFlag == 0)
                    {
                        if (Math.Abs(avgArea[center.Index] -
                                     avgArea[round.Index]) < k * avgArea[center.Index])
                        {
                            round.Traits.SelectedFlag = center.Traits.SelectedFlag;
                            queue.Enqueue(round);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private double k           = 0.896;                                    //0<k<1

        public void ComputeAverageArea(List <TriMesh.Vertex> selectedVertices) //计算种子点相关三角形的面积的均值
        {
            foreach (TriMesh.Vertex v in selectedVertices)
            {
                double a = 0, b = 0, c = 0;
                double sum = 0;
                sum = TriMeshUtil.ComputeAreaOneRing(v) / v.FaceCount;//计算相关三角形的面积的均值
                area.Add(sum);
            }
        }
Esempio n. 3
0
        public double ComputeSArea(TriMesh.Vertex vertex)//计算相关三角形的面积
        {
            double s = TriMeshUtil.ComputeAreaOneRing(vertex) / vertex.FaceCount;

            return(s);
        }