Пример #1
0
        /// <summary>
        /// Remove all bowtie vertices in mesh. Makes one pass unless
        ///   bRepeatUntilClean = true, in which case repeats until no more bowties found
        /// Returns true if any vertices were removed
        /// </summary>
        public bool RemoveAllBowtieVertices(bool bRepeatUntilClean)
        {
            int nRemoved = 0;

            while (true)
            {
                List <int> bowties = new List <int>();
                foreach (int vID in Mesh.VertexIndices())
                {
                    if (Mesh.IsBowtieVertex(vID))
                    {
                        bowties.Add(vID);
                    }
                }
                if (bowties.Count == 0)
                {
                    break;
                }

                foreach (int vID in bowties)
                {
                    MeshResult result = Mesh.RemoveVertex(vID, true, false);
                    Debug.Assert(result == MeshResult.Ok);
                    nRemoved++;
                }
                if (bRepeatUntilClean == false)
                {
                    break;
                }
            }
            return(nRemoved > 0);
        }
Пример #2
0
        public static IEnumerable <int> BowtieVertices(DMesh3 mesh)
        {
            int N = mesh.MaxVertexID;

            for (int i = 0; i < N; ++i)
            {
                if (mesh.IsVertex(i))
                {
                    if (mesh.IsBowtieVertex(i))
                    {
                        yield return(i);
                    }
                }
            }
        }
        public static GenusResult Genus(DMesh3 mesh)
        {
            GenusResult result = new GenusResult()
            {
                Valid = false, Genus = -1
            };

            if (!mesh.CachedIsClosed)
            {
                result.HasBoundary = true;
                return(result);
            }

            MeshConnectedComponents compT = new MeshConnectedComponents(mesh);

            compT.FindConnectedT();
            if (compT.Count > 1)
            {
                result.MultipleConnectedComponents = true;
                return(result);
            }
            int isolated_verts = 0;

            foreach (int vid in mesh.VertexIndices())
            {
                if (mesh.IsBowtieVertex(vid))
                {
                    result.HasBowtieVertices = true;
                    return(result);
                }
                if (mesh.GetVtxTriangleCount(vid) == 0)
                {
                    isolated_verts++;
                }
            }

            int V = mesh.VertexCount - isolated_verts;
            int F = mesh.TriangleCount;
            int E = mesh.EdgeCount;

            result.Genus = (2 - (V + F - E)) / 2;
            result.Valid = true;
            return(result);
        }