Esempio n. 1
0
        public static Tuple <List <List <int> >, List <List <int[]> > > BrepBFS(Brep brep, string startIndex = "0")
        {
            UndirectedGraphBfs g = new UndirectedGraphBfs(brep.Faces.Count);



            for (int i = 0; i < brep.Faces.Count; i++)
            {
                g.InsertVertex(i.ToString());
            }

            int[][] ef = brep.GetEdgeFaces();

            for (int i = 0; i < ef.Length; i++)
            {
                int[] f = ef[i];
                if (f.Length == 2)
                {
                    g.InsertEdge(f[0].ToString(), f[1].ToString());
                    //Rhino.RhinoApp.WriteLine("Hi");
                }
            }



            //Output
            List <List <int> >   gNodes = g.BfsTraversal_All(startIndex);
            List <List <int[]> > gEdges = g.EdgesAll;

            return(new Tuple <List <List <int> >, List <List <int[]> > >(gNodes, gEdges));
        }
Esempio n. 2
0
        public static Tuple <List <List <int> >, List <List <int[]> > > MeshBFS(Mesh mesh, string startIndex = "0")
        {
            UndirectedGraphBfs g = new UndirectedGraphBfs(mesh.Ngons.Count);

            if (mesh.Ngons.Count > 0)
            {
                for (int i = 0; i < mesh.Ngons.Count; i++)
                {
                    g.InsertVertex(i.ToString());
                }

                List <int>[] adj = mesh.GetNGonFaceAdjacency();

                for (int i = 0; i < adj.Length; i++)
                {
                    foreach (int j in adj[i])
                    {
                        g.InsertEdge(i.ToString(), j.ToString());
                    }
                }
            }
            else
            {
                for (int i = 0; i < mesh.Faces.Count; i++)
                {
                    g.InsertVertex(i.ToString());
                }

                for (int i = 0; i < mesh.Faces.Count; i++)
                {
                    int[] adj = mesh.Faces.AdjacentFaces(i);
                    foreach (int j in adj)
                    {
                        g.InsertEdge(i.ToString(), j.ToString());
                    }
                }
            }



            //Output
            List <List <int> >   gNodes = g.BfsTraversal_All(startIndex);
            List <List <int[]> > gEdges = g.EdgesAll;

            return(new Tuple <List <List <int> >, List <List <int[]> > >(gNodes, gEdges));
        }