Esempio n. 1
0
 public void GeneratorTreeCotree(TriMesh mesh, out DynamicTree <TriMesh.Vertex> primalTree, out DynamicTree <TriMesh.Face> dualTree)
 {
     TreeNode <TriMesh.Vertex>[] primalFlags = null;
     TreeNode <TriMesh.Face>[]   dualFlags   = null;
     primalTree = BuildPrimalSpanningTree(mesh, out primalFlags);
     dualTree   = BuildDualSpanningCoTree(mesh, primalFlags, out dualFlags);
 }
Esempio n. 2
0
        public List <List <TriMesh.HalfEdge> > ExtractHonologyGenerator(TriMesh mesh)
        {
            TreeNode <TriMesh.Vertex>[]     primalFlags = null;
            TreeNode <TriMesh.Face>[]       dualFlags   = null;
            DynamicTree <TriMesh.Vertex>    primalTree  = BuildPrimalSpanningTree(mesh, out primalFlags);
            DynamicTree <TriMesh.Face>      dualTree    = BuildDualSpanningCoTree(mesh, primalFlags, out dualFlags);
            List <List <TriMesh.HalfEdge> > cycles      = BuildCycle(mesh, primalFlags, dualFlags);

            ColorCycle(cycles);
            return(cycles);
        }
Esempio n. 3
0
        public List <TriMesh.Edge> BuildCoTree(DynamicTree <TriMesh.Face> cotree)
        {
            if (cotree == null)
            {
                return(null);
            }

            List <TriMesh.Edge> cotreeMarks = new List <HalfEdgeMesh.Edge>();



            Vector3D[] bycenters = new Vector3D[mesh.Faces.Count];
            cotreeMarks = new List <HalfEdgeMesh.Edge>();
            TreeNode <TriMesh.Face>          currentCoNode = cotree.Root;
            Queue <TreeNode <TriMesh.Face> > coQueue       = new Queue <TreeNode <TriMesh.Face> >();

            coQueue.Enqueue(currentCoNode);
            do
            {
                currentCoNode = coQueue.Dequeue();
                bycenters[currentCoNode.Attribute.Index] = TriMeshUtil.GetMidPoint(currentCoNode.Attribute);

                TreeNode <TriMesh.Face> currentChild = currentCoNode.LeftMostChild;
                while (currentChild != null)
                {
                    //Mark edge
                    TriMesh.Face f1 = currentCoNode.Attribute;
                    TriMesh.Face f2 = currentChild.Attribute;

                    foreach (TriMesh.HalfEdge hf in f1.Halfedges)
                    {
                        if (hf.Opposite.Face == f2)
                        {
                            cotreeMarks.Add(hf.Edge);
                            break;
                        }
                    }

                    coQueue.Enqueue(currentChild);
                    currentChild = currentChild.RightSibling;
                }
            } while (coQueue.Count > 0);

            return(cotreeMarks);
        }
Esempio n. 4
0
        public List <TriMesh.Edge> BuildTree(DynamicTree <TriMesh.Vertex> tree)
        {
            if (tree == null)
            {
                return(null);
            }

            List <TriMesh.Edge> treeMarks = new List <HalfEdgeMesh.Edge>();


            treeMarks = new List <HalfEdgeMesh.Edge>();
            TreeNode <TriMesh.Vertex>          currentNode = tree.Root;
            Queue <TreeNode <TriMesh.Vertex> > queue       = new Queue <TreeNode <TriMesh.Vertex> >();

            queue.Enqueue(currentNode);
            do
            {
                currentNode = queue.Dequeue();

                TreeNode <TriMesh.Vertex> currentChild = currentNode.LeftMostChild;
                while (currentChild != null)
                {
                    //Mark edge
                    TriMesh.Vertex v1 = currentNode.Attribute;
                    TriMesh.Vertex v2 = currentChild.Attribute;

                    foreach (TriMesh.HalfEdge hf in v1.HalfEdges)
                    {
                        if (hf.ToVertex == v2)
                        {
                            treeMarks.Add(hf.Edge);
                            break;
                        }
                    }

                    queue.Enqueue(currentChild);
                    currentChild = currentChild.RightSibling;
                }
            } while (queue.Count > 0);


            return(treeMarks);
        }
Esempio n. 5
0
        public DynamicTree <TriMesh.Vertex> BuildPrimalSpanningTree(TriMesh mesh, out TreeNode <TriMesh.Vertex>[] primalFlags)
        {
            DynamicTree <TriMesh.Vertex> primalSpanningTree = new DynamicTree <HalfEdgeMesh.Vertex>();

            TreeNode <TriMesh.Vertex>[] flags = new TreeNode <HalfEdgeMesh.Vertex> [mesh.Vertices.Count];
            foreach (TriMesh.Vertex v in mesh.Vertices)
            {
                if (!v.OnBoundary)
                {
                    TreeNode <TriMesh.Vertex> root = new TreeNode <HalfEdgeMesh.Vertex>(v);
                    primalSpanningTree.Root = root;
                    flags[v.Index]          = root;
                    break;
                }
            }
            //Iterate verties to get spanning tree
            Queue <TreeNode <TriMesh.Vertex> > queue = new Queue <TreeNode <TriMesh.Vertex> >();

            queue.Enqueue(primalSpanningTree.Root);
            do
            {
                TreeNode <TriMesh.Vertex> currentNode   = queue.Dequeue();
                TriMesh.Vertex            currentVertex = currentNode.Attribute;
                TriMesh.HalfEdge          he            = currentVertex.HalfEdge;
                do
                {
                    TriMesh.Vertex to = he.Opposite.FromVertex;
                    if (flags[to.Index] == null &&
                        !to.OnBoundary &&
                        to != primalSpanningTree.Root.Attribute)
                    {
                        TreeNode <TriMesh.Vertex> node = new TreeNode <HalfEdgeMesh.Vertex>(to);
                        flags[to.Index] = node;
                        currentNode.AddChild(node);
                        queue.Enqueue(node);
                    }
                    he = he.Opposite.Next;
                } while (he != currentVertex.HalfEdge);
            } while (queue.Count != 0);
            primalFlags = flags;
            return(primalSpanningTree);
        }
Esempio n. 6
0
        public DynamicTree <TriMesh.Face> BuildDualSpanningCoTree(TriMesh mesh,
                                                                  TreeNode <TriMesh.Vertex>[] primalFlags,
                                                                  out TreeNode <TriMesh.Face>[] dualFlags)
        {
            DynamicTree <TriMesh.Face> dualSpanningTree = new DynamicTree <HalfEdgeMesh.Face>();

            TreeNode <TriMesh.Face>[] flags = new TreeNode <HalfEdgeMesh.Face> [mesh.Faces.Count];
            TreeNode <TriMesh.Face>   root  = new TreeNode <HalfEdgeMesh.Face>(mesh.Faces[0]);

            dualSpanningTree.Root      = root;
            flags[mesh.Faces[0].Index] = root;
            Queue <TreeNode <TriMesh.Face> > queue = new Queue <TreeNode <TriMesh.Face> >();

            queue.Enqueue(dualSpanningTree.Root);
            do
            {
                TreeNode <TriMesh.Face> currentNode = queue.Dequeue();
                TriMesh.Face            currentFace = currentNode.Attribute;
                TriMesh.HalfEdge        he          = currentFace.HalfEdge;
                do
                {
                    TriMesh.Face toFace = he.Opposite.Face;
                    if (toFace != null &&
                        flags[toFace.Index] == null &&
                        toFace != dualSpanningTree.Root.Attribute &&
                        !InPrimalSpanningTree(he, primalFlags)
                        )
                    {
                        TreeNode <TriMesh.Face> node = new TreeNode <HalfEdgeMesh.Face>(toFace);
                        flags[toFace.Index] = node;
                        currentNode.AddChild(node);
                        queue.Enqueue(node);
                    }
                    he = he.Next;
                } while (he != currentFace.HalfEdge);
            } while (queue.Count != 0);
            dualFlags = flags;
            return(dualSpanningTree);
        }