Example #1
0
        public static double ComputeOneRingArea(NonManifoldMesh mesh, int vertex)
        {
            int    n    = mesh.FaceCount;
            double area = 0;

            foreach (int k in mesh.AdjVF[vertex])
            {
                area += mesh.ComputeFaceArea(k);
            }
            return(area);
        }
Example #2
0
        public static double ComputeAverageArea(NonManifoldMesh mesh)
        {
            int    n    = mesh.FaceCount;
            double area = 0;

            for (int i = 0; i < n; i++)
            {
                area += mesh.ComputeFaceArea(i);
            }
            return(area / n);
        }
Example #3
0
 public static double ComputeOneRingArea(NonManifoldMesh mesh,int vertex)
 {
     int n = mesh.FaceCount;
     double area = 0;
     foreach (int k in mesh.AdjVF[vertex])
         area += mesh.ComputeFaceArea(k);
     return area;
 }
Example #4
0
 public static double ComputeAverageArea(NonManifoldMesh mesh)
 {
     int n = mesh.FaceCount;
     double area = 0;
     for (int i = 0; i < n; i++)
     {
         area += mesh.ComputeFaceArea(i);
     }
     return area / n;
 }
Example #5
0
        public static double[] ComputeVoronoiArea(ref NonManifoldMesh mesh)
        {
            int n = mesh.VertexCount;
            double[] voronoiArea = new double[n];
            for (int i = 0; i < n; i++)
            {
                voronoiArea[i] = 0;
            }
            for (int i = 0, j = 0; i < mesh.FaceCount; i++, j += 3)
            {

                int c1 = mesh.FaceIndex[j];
                int c2 = mesh.FaceIndex[j + 1];
                int c3 = mesh.FaceIndex[j + 2];
                Vector3D v1 = new Vector3D(mesh.VertexPos, c1 * 3);
                Vector3D v2 = new Vector3D(mesh.VertexPos, c2 * 3);
                Vector3D v3 = new Vector3D(mesh.VertexPos, c3 * 3);

                double dis1=(v3-v2).Length()*(v3-v2).Length();
                double dis2=(v3-v1).Length()*(v3-v1).Length();
                double dis3=(v1-v2).Length()*(v1-v2).Length();


                double cot1 = (v2 - v1).Dot(v3 - v1) / (v2 - v1).Cross(v3 - v1).Length();
                double cot2 = (v3 - v2).Dot(v1 - v2) / (v3 - v2).Cross(v1 - v2).Length();
                double cot3 = (v1 - v3).Dot(v2 - v3) / (v1 - v3).Cross(v2 - v3).Length();

                bool obtuse = false;
                if (cot1 > 0 && cot2 > 0 && cot3 > 0)
                {
                    obtuse = true;
                }

                if (!obtuse)
                {
                    voronoiArea[c1] += (dis2 * cot2 + dis3 * cot3) / 8;
                    voronoiArea[c2] += (dis1 * cot1 + dis3 * cot3) / 8;
                    voronoiArea[c3] += (dis1 * cot1 + dis2 * cot2) / 8;
                }
                else
                {
                    double faceArea = mesh.ComputeFaceArea(i);
                    if (cot1 < 0)
                    {
                        voronoiArea[c1] += faceArea / 2;
                    }
                    else
                    {
                        voronoiArea[c1] += faceArea / 4;
                    }

                    if (cot2 < 0)
                    {
                        voronoiArea[c2] += faceArea / 2;
                    }
                    else
                    {
                        voronoiArea[c2] += faceArea / 4;
                    }

                    if (cot3 < 0)
                    {
                        voronoiArea[c3] += faceArea / 2;
                    }
                    else
                    {
                        voronoiArea[c3] += faceArea / 4;
                    }
                }
            }
            return voronoiArea ;
        }
Example #6
0
        public static double[] ComputeVoronoiArea(ref NonManifoldMesh mesh)
        {
            int n = mesh.VertexCount;

            double[] voronoiArea = new double[n];
            for (int i = 0; i < n; i++)
            {
                voronoiArea[i] = 0;
            }
            for (int i = 0, j = 0; i < mesh.FaceCount; i++, j += 3)
            {
                int      c1 = mesh.FaceIndex[j];
                int      c2 = mesh.FaceIndex[j + 1];
                int      c3 = mesh.FaceIndex[j + 2];
                Vector3D v1 = new Vector3D(mesh.VertexPos, c1 * 3);
                Vector3D v2 = new Vector3D(mesh.VertexPos, c2 * 3);
                Vector3D v3 = new Vector3D(mesh.VertexPos, c3 * 3);

                double dis1 = (v3 - v2).Length() * (v3 - v2).Length();
                double dis2 = (v3 - v1).Length() * (v3 - v1).Length();
                double dis3 = (v1 - v2).Length() * (v1 - v2).Length();


                double cot1 = (v2 - v1).Dot(v3 - v1) / (v2 - v1).Cross(v3 - v1).Length();
                double cot2 = (v3 - v2).Dot(v1 - v2) / (v3 - v2).Cross(v1 - v2).Length();
                double cot3 = (v1 - v3).Dot(v2 - v3) / (v1 - v3).Cross(v2 - v3).Length();

                bool obtuse = false;
                if (cot1 > 0 && cot2 > 0 && cot3 > 0)
                {
                    obtuse = true;
                }

                if (!obtuse)
                {
                    voronoiArea[c1] += (dis2 * cot2 + dis3 * cot3) / 8;
                    voronoiArea[c2] += (dis1 * cot1 + dis3 * cot3) / 8;
                    voronoiArea[c3] += (dis1 * cot1 + dis2 * cot2) / 8;
                }
                else
                {
                    double faceArea = mesh.ComputeFaceArea(i);
                    if (cot1 < 0)
                    {
                        voronoiArea[c1] += faceArea / 2;
                    }
                    else
                    {
                        voronoiArea[c1] += faceArea / 4;
                    }

                    if (cot2 < 0)
                    {
                        voronoiArea[c2] += faceArea / 2;
                    }
                    else
                    {
                        voronoiArea[c2] += faceArea / 4;
                    }

                    if (cot3 < 0)
                    {
                        voronoiArea[c3] += faceArea / 2;
                    }
                    else
                    {
                        voronoiArea[c3] += faceArea / 4;
                    }
                }
            }
            return(voronoiArea);
        }