예제 #1
0
        public PrincipalCurvature ComputePrincipalCurvature(TriMesh.Vertex v)
        {
            Vector3D sum = Vector3D.Zero;
            Vector3D mid = v.Traits.Position;

            foreach (var hf in v.HalfEdges)
            {
                Vector3D buttom = hf.ToVertex.Traits.Position;
                Vector3D left   = hf.Opposite.Next.ToVertex.Traits.Position;
                Vector3D right  = hf.Next.ToVertex.Traits.Position;
                double   cota   = (mid - left).Dot(buttom - left) / (mid - left).Cross(buttom - left).Length();
                double   cotb   = (mid - right).Dot(buttom - right) / (mid - right).Cross(buttom - right).Length();
                sum += (cota + cotb) * (this.Normal[v.Index] - this.Normal[hf.ToVertex.Index]);
            }
            double   mixedArea = TriMeshUtil.ComputeAreaMixed(v);
            Vector3D laplace   = sum / mixedArea / 2d;
            double   square    = -laplace.Dot(this.Normal[v.Index]);
            double   k         = this.K[v.Index].Length();
            double   delta     = -k * k + 2d * square;

            if (delta < 0d)
            {
                delta = 0d;
            }
            PrincipalCurvature pc = new PrincipalCurvature();

            pc.max = (k + Math.Pow(delta, 0.5)) / 2d;
            pc.min = (k - Math.Pow(delta, 0.5)) / 2d;
            return(pc);
        }
예제 #2
0
        public SparseMatrix BuildLaplaceCotArea(TriMesh mesh)
        {
            double[]     areas = TriMeshUtil.ComputeAreaMixed(mesh);
            SparseMatrix cot   = BuildLaplaceCot(mesh);
            int          n     = mesh.Vertices.Count;

            for (int i = 0; i < n; i++)
            {
                foreach (SparseMatrix.Element e in cot.Rows[i])
                {
                    e.value = e.value * (1 / areas[i]);
                }
            }
            return(cot);
        }
예제 #3
0
        public CurvaturePG07(TriMesh mesh)
        {
            this.mesh = mesh;

            this.K             = new Vector3D[this.mesh.Vertices.Count];
            this.Mean          = new double[this.mesh.Vertices.Count];
            this.Normal        = new Vector3D[this.mesh.Vertices.Count];
            this.PrincipalCurv = new PrincipalCurvature[this.mesh.Vertices.Count];

            foreach (var v in this.mesh.Vertices)
            {
                double mixedArea = TriMeshUtil.ComputeAreaMixed(v);
                this.K[v.Index]      = ComputeK(v, mixedArea);
                this.Mean[v.Index]   = ComputeMeanCurvature(this.K[v.Index]);
                this.Normal[v.Index] = ComputeNormal(this.K[v.Index]);
            }

            foreach (var v in this.mesh.Vertices)
            {
                this.PrincipalCurv[v.Index] = this.ComputePrincipalCurvature(v);
            }
        }