public void GenBFSTreeFromArcLoft()
            {
                Surface testsweep = UnfoldTestUtils.SetupArcLoft();

                var surfaces = new List <Surface>()
                {
                    testsweep
                };
                //handle tesselation here
                var pointtuples = Tesselation.Tessellate(surfaces, -1, 512);
                //convert triangles to surfaces
                List <Surface> trisurfaces = pointtuples.Select(x => Surface.ByPerimeterPoints(new List <Point>()
                {
                    x[0], x[1], x[2]
                })).ToList();


                var graph = ModelTopology.GenerateTopologyFromSurfaces(trisurfaces);

                List <Object> face_objs = trisurfaces.Select(x => x as Object).ToList();

                UnfoldTestUtils.GraphHasVertForEachFace(graph, face_objs);

                var    nodereturn = ModelGraph.BFS <EdgeLikeEntity, FaceLikeEntity>(graph);
                object tree       = nodereturn;

                var casttree = tree as List <GraphVertex <EdgeLikeEntity, FaceLikeEntity> >;

                UnfoldTestUtils.GraphHasVertForEachFace(casttree, face_objs);
                UnfoldTestUtils.AssertAllFinishingTimesSet(graph);

                var sccs = GraphUtilities.TarjansAlgo <EdgeLikeEntity, FaceLikeEntity> .CycleDetect(casttree, GraphUtilities.EdgeType.Tree);

                UnfoldTestUtils.IsAcylic <EdgeLikeEntity, FaceLikeEntity>(sccs, casttree);
            }
Esempio n. 2
0
        public static object __BFSTestNoGeometryGeneration(List <Surface> surfaces)
        {
            var graph = ModelTopology.GenerateTopologyFromSurfaces(surfaces);

            //perform BFS on the graph and get back the tree
            var nodereturn = ModelGraph.BFS <EdgeLikeEntity, FaceLikeEntity>(graph);

            return(nodereturn);
        }
Esempio n. 3
0
        public static void AssertEachFacePairUnfoldsCorrectly(List <GraphVertex <EdgeLikeEntity, FaceLikeEntity> > graph)
        {
            //perform BFS on the graph and get back the tree
            var    nodereturn = ModelGraph.BFS <EdgeLikeEntity, FaceLikeEntity>(graph);
            object tree       = nodereturn;

            var casttree = tree as List <GraphVertex <EdgeLikeEntity, FaceLikeEntity> >;
            //perform Tarjans algo and make sure that the tree is acylic before unfold
            var sccs = GraphUtilities.TarjansAlgo <EdgeLikeEntity, FaceLikeEntity> .CycleDetect(casttree, GraphUtilities.EdgeType.Tree);

            UnfoldTestUtils.IsAcylic <EdgeLikeEntity, FaceLikeEntity>(sccs, casttree);

            // iterate through each vertex in the tree
            // make sure that the parent/child is not null (depends which direction we're traversing)
            // if not null, grab the next node and the tree edge
            // pass these to check normal consistencey and align.
            // be careful about the order of passed faces

            foreach (var parent in casttree)
            {
                if (parent.GraphEdges.Count > 0)
                {
                    foreach (var edge in parent.GraphEdges)
                    {
                        var child = edge.Head;

                        double nc          = AlignPlanarFaces.CheckNormalConsistency(child.Face, parent.Face, edge.GeometryEdge);
                        var    rotatedFace = AlignPlanarFaces.MakeGeometryCoPlanarAroundEdge(nc, child.Face, parent.Face, edge.GeometryEdge);

                        UnfoldTestUtils.AssertSurfacesAreCoplanar(rotatedFace.First(), parent.Face.SurfaceEntities.First());

                        UnfoldTestUtils.AssertRotatedSurfacesDoNotShareSameCenter(rotatedFace.First(), parent.Face.SurfaceEntities.First());

                        foreach (IDisposable item in rotatedFace)
                        {
                            item.Dispose();
                        }
                    }
                }
            }
            foreach (IDisposable item in graph)
            {
                Console.WriteLine("disposing a graphnode");
                item.Dispose();
            }

            foreach (IDisposable item in casttree)
            {
                Console.WriteLine("disposing a face");
                item.Dispose();
            }
        }
            public void GenBFSTreeFromCubeFaces()
            {
                using (Solid testcube = UnfoldTestUtils.SetupCube())
                {
                    List <Face> faces = testcube.Faces.ToList();

                    var           graph     = ModelTopology.GenerateTopologyFromFaces(faces);
                    List <Object> face_objs = faces.Select(x => x as Object).ToList();

                    UnfoldTestUtils.GraphHasVertForEachFace(graph, face_objs);

                    UnfoldTestUtils.GraphHasCorrectNumberOfEdges(24, graph);

                    var    nodereturn = ModelGraph.BFS <EdgeLikeEntity, FaceLikeEntity>(graph);
                    object tree       = nodereturn;
                    var    casttree   = tree as List <GraphVertex <EdgeLikeEntity, FaceLikeEntity> >;

                    UnfoldTestUtils.GraphHasVertForEachFace(casttree, face_objs);
                    UnfoldTestUtils.GraphHasCorrectNumberOfTreeEdges(5, casttree);
                    UnfoldTestUtils.AssertAllFinishingTimesSet(graph);

                    var sccs = GraphUtilities.TarjansAlgo <EdgeLikeEntity, FaceLikeEntity> .CycleDetect(casttree, GraphUtilities.EdgeType.Tree);

                    UnfoldTestUtils.IsAcylic <EdgeLikeEntity, FaceLikeEntity>(sccs, casttree);

                    foreach (IDisposable item in graph)
                    {
                        Console.WriteLine("disposing a graphnode");
                        item.Dispose();
                    }


                    foreach (IDisposable item in faces)
                    {
                        Console.WriteLine("disposing a face");
                        item.Dispose();
                    }

                    foreach (IDisposable item in casttree)
                    {
                        Console.WriteLine("disposing a face");
                        item.Dispose();
                    }
                }
            }
Esempio n. 5
0
        // The following methods may be removed from Import eventually
        #region explorationdebug
        // method is for debugging the BFS output visually in dynamo, very useful
        public static object __BFSTestTesselation(List <Surface> surfaces, double tolerance = -1, int maxGridLines = 512)
        {
            //handle tesselation here
            var pointtuples = Tesselation.Tessellate(surfaces, tolerance, maxGridLines);
            //convert triangles to surfaces
            List <Surface> trisurfaces = pointtuples.Select(x => Surface.ByPerimeterPoints(new List <Point>()
            {
                x[0], x[1], x[2]
            })).ToList();

            var graph = ModelTopology.GenerateTopologyFromSurfaces(trisurfaces);

            //perform BFS on the graph and get back the tree
            var nodereturn = ModelGraph.BFS <EdgeLikeEntity, FaceLikeEntity>(graph);
            var tree       = nodereturn;

            var treegeo = ModelGraph.ProduceGeometryFromGraph <EdgeLikeEntity, FaceLikeEntity>
                              (tree as List <GraphVertex <EdgeLikeEntity, FaceLikeEntity> >);


            return(treegeo);
        }