public bool IsNakedVertex(int vKey)
        {
            ITopologicVertex v = iM.GetVertexWithKey(vKey);

            if (v.V2HF != 0)
            {
                IElement e     = iM.GetElementWithKey(v.GetElementID());
                Int64    sibhe = e.GetSiblingHalfFacet(v.GetHalfFacetID());
                if (sibhe == 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        public IMesh CleanCopy()
        {
            IMesh copy = new IMesh();

            Elements.ForEach(entry =>
            {
                IElement e = (IElement)entry.CleanCopy();
                copy._elements.Add(e.Key, e);
            });
            Vertices.ForEach(entry =>
            {
                ITopologicVertex v = (ITopologicVertex)entry.CleanCopy();
                copy._vertices.Add(v.Key, v);
            });
            copy.elementKey = elementKey;
            copy._valid     = _valid;
            return(copy);
        }
        public int[] GetNakedVerticesID()
        {
            List <int> naked = new List <int>();

            foreach (int vKey in iM.VerticesKeys)
            {
                ITopologicVertex v = iM.GetVertexWithKey(vKey);
                if (v.V2HF != 0)
                {
                    IElement e     = iM.GetElementWithKey(v.GetElementID());
                    Int64    sibhe = e.GetSiblingHalfFacet(v.GetHalfFacetID());
                    if (sibhe == 0)
                    {
                        naked.Add(vKey);
                    }
                }
            }
            return(naked.ToArray());
        }
        private void BuildVertexToHalfFacet(int vKey, int elementID, int halfFacetID)
        {
            ITopologicVertex v = GetVertexWithKey(vKey);

            if (v.V2HF == 0)
            {
                v.SetV2HF(elementID, halfFacetID);
                SetVertex(vKey, v);
            }

            if (_elements[elementID].GetSiblingHalfFacet(halfFacetID) == 0)
            {
                if (v.GetElementID() != elementID || v.GetHalfFacetID() != halfFacetID)
                {
                    v.SetV2HF(elementID, halfFacetID);
                    SetVertex(vKey, v);
                }
            }
        }
Example #5
0
        public IMesh CleanCopy()
        {
            IMesh copy = new IMesh();

            Elements.ForEach(entry =>
            {
                IElement e = entry.CleanCopy();
                copy.AddElement(e);
            });
            Vertices.ForEach(entry =>
            {
                ITopologicVertex v = entry.CleanCopy();
                copy.AddVertex(v.Key, v);
            });

            copy._renderMesh = _renderMesh;
            copy.elementKey  = elementKey;
            copy._valid      = _valid;
            return(copy);
        }
Example #6
0
        public IMesh DeepCopy()
        {
            IMesh copy = new IMesh();

            Elements.ForEach(entry =>
            {
                IElement e = (IElement)entry.Clone();
                copy._elements.Add(e.Key, e);
            });
            Vertices.ForEach(entry =>
            {
                ITopologicVertex v = (ITopologicVertex)entry.Clone();
                copy._vertices.Add(v.Key, v);
            });
            copy._tempVertexToHalfFacets = _tempVertexToHalfFacets.ToDictionary(entry => entry.Key, entry => entry.Value);
            copy.dim        = dim;
            copy.message    = message;
            copy.elementKey = elementKey;
            copy._valid     = _valid;
            return(copy);
        }
Example #7
0
 public void SetVertex(int key, ITopologicVertex vertex)
 {
     _vertices[key] = vertex;
 }
        /// <summary>
        /// Computes the discrete Gaussian curvature as in the paper "Discrete Differential-Geometry Operators for Triangulated
        /// 2-Manifolds" (http://www.cs.caltech.edu/~mmeyer/Publications/diffGeomOps.pdf)
        /// </summary>
        public double ComputesGaussianCurvature(int vKey)
        {
            IVector3D meanCurvatureVector = new IVector3D();

            if (IsNakedVertex(vKey))
            {
                return(0.0);
            }

            IVector3D vect1 = new IVector3D();
            IVector3D vect2 = new IVector3D();
            IVector3D vect3 = new IVector3D();
            double    mixed = 0.0;
            double    gauss = 0.0;

            int[]            nKey = iM.Topology.GetVertexAdjacentVertices(vKey);
            ITopologicVertex v    = iM.GetVertexWithKey(vKey);
            int next_i;

            for (int i = 0; i < nKey.Length; i++)
            {
                next_i = i + 1;
                if (i == nKey.Length - 1)
                {
                    next_i = 0;
                }

                ITopologicVertex p1 = iM.GetVertexWithKey(nKey[i]);
                ITopologicVertex p2 = iM.GetVertexWithKey(nKey[next_i]);
                vect1 = IVector3D.CreateVector(v.Position, p1.Position);
                vect2 = IVector3D.CreateVector(p1.Position, p2.Position);
                vect3 = IVector3D.CreateVector(p2.Position, v.Position);
                double c12 = IVector3D.Dot(vect1, vect2);
                double c23 = IVector3D.Dot(vect2, vect3);
                double c31 = IVector3D.Dot(vect3, vect1);
                vect2 = IVector3D.Cross(vect1, vect3, false);
                double area = 0.5 * vect2.Mag();

                // This angle is obtuse
                if (c31 > 0.0)
                {
                    mixed += 0.5 * area;
                }
                else if (c12 > 0.0 || c23 > 0.0)
                {
                    mixed += 0.25 * area;
                }
                else
                {
                    if (area > 0.0 && area > -1e-9 * (c12 + c23))
                    {
                        mixed -= 0.125 * 0.5 * (c12 * IVector3D.Dot(vect3, vect3) + c23 * IVector3D.Dot(vect1, vect1)) / area;
                    }
                }
                gauss += Math.Abs(Math.Atan2(2.0 * area, -c31));
                vect3 *= c12;
                vect1 *= -c23;
                vect3 += vect1;
                meanCurvatureVector += vect3 * (0.5 / area);
            }

            meanCurvatureVector *= (0.5 / mixed);
            // Discrete gaussian curvature
            return((2.0 * Math.PI - gauss) / mixed);
        }