public void GraphCanBeGeneratedFromCubeFaces()
            {
                using (Solid testcube = UnfoldTestUtils.SetupCube())
                {
                    var faces = testcube.Faces.ToList();
                    Assert.AreEqual(faces.Count, 6);
                    List <GraphVertex <EdgeLikeEntity, FaceLikeEntity> > graph;
                    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 sccs = GraphUtilities.TarjansAlgo <EdgeLikeEntity, FaceLikeEntity> .CycleDetect(graph, GraphUtilities.EdgeType.Graph);

                    UnfoldTestUtils.IsOneStronglyConnectedGraph(sccs);

                    //manual dispose of lists of Idisposeable, should implement graph type

                    foreach (IDisposable item in graph)
                    {
                        Console.WriteLine("disposing a graphnode");
                        item.Dispose();
                    }
                }
            }
Beispiel #2
0
            public void UnfoldAndLabelExtrudedLFromSurfacs()
            {
                throw new NotImplementedException();
                // unfold cube
                Solid       testcube = UnfoldTestUtils.SetupCube();
                List <Face> faces    = testcube.Faces.ToList();

                var unfoldObject = PlanarUnfolder.Unfold(faces);

                var unfoldsurfaces = unfoldObject.UnfoldedSurfaceSet;

                Console.WriteLine("generating labels");

                // generate labels
                var labels = unfoldObject.StartingUnfoldableFaces.Select(x =>
                                                                         new PlanarUnfolder.UnfoldableFaceLabel <EdgeLikeEntity, FaceLikeEntity>(x)).ToList();

                UnfoldTestUtils.AssertLabelsGoodStartingLocationAndOrientation(labels);

                // next check the positions of the translated labels

                var transformedGeo = labels.Select(x => PlanarUnfolder.MapGeometryToUnfoldingByID(unfoldObject, x.AlignedLabelGeometry, x.ID)).ToList();

                UnfoldTestUtils.AssertLabelsGoodFinalLocationAndOrientation(labels, transformedGeo, unfoldObject);
            }
            public void GraphCanBeGeneratedFromCubeSurfaces()
            {
                using (Solid testcube = UnfoldTestUtils.SetupCube())
                {
                    var faces    = testcube.Faces;
                    var surfaces = faces.Select(x => x.SurfaceGeometry()).ToList();

                    Assert.AreEqual(surfaces.Count, 6);

                    var graph = ModelTopology.GenerateTopologyFromSurfaces(surfaces);

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

                    UnfoldTestUtils.GraphHasVertForEachFace(graph, face_objs);

                    UnfoldTestUtils.GraphHasCorrectNumberOfEdges(24, graph);

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

                    UnfoldTestUtils.IsOneStronglyConnectedGraph(sccs);

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


                    foreach (IDisposable item in faces)
                    {
                        Console.WriteLine("disposing a face");
                        item.Dispose();
                    }
                }
            }
Beispiel #4
0
            public void UnfoldCubeSurfaceWithMinimalUnfold()
            {
                // unfold cube
                Solid       testcube = UnfoldTestUtils.SetupCube();
                List <Face> faces    = testcube.Faces.ToList();
                var         surfaces = faces.Select(x => x.SurfaceGeometry()).ToList();


                var unfolds = Enumerable.Range(0, 5).Select(x => PlanarUnfolder.Unfold(surfaces)).ToList();
            }
Beispiel #5
0
            public void FullyUnfoldCubeFromSurfaces()
            {
                Solid          testcube       = UnfoldTestUtils.SetupCube();
                List <Face>    faces          = testcube.Faces.ToList();
                List <Surface> surfaces       = faces.Select(x => x.SurfaceGeometry()).ToList();
                var            unfoldsurfaces = PlanarUnfolder.Unfold(surfaces).UnfoldedSurfaceSet;

                UnfoldTestUtils.CheckAllUnfoldedFacesForCorrectUnfold(unfoldsurfaces);

                Assert.AreEqual(unfoldsurfaces.Count, 1);
            }
Beispiel #6
0
            public void UnfoldEachPairOfSurfacesInACubeParentAsRefFace()
            {
                Solid          testcube = UnfoldTestUtils.SetupCube();
                List <Face>    faces    = testcube.Faces.ToList();
                List <Surface> surfaces = faces.Select(x => x.SurfaceGeometry()).ToList();
                //generate a graph of the cube
                var graph = ModelTopology.GenerateTopologyFromSurfaces(surfaces);


                UnfoldTestUtils.AssertEachFacePairUnfoldsCorrectly(graph);
            }
        public void Creating10000Cubes()
        {
            List <Solid> retainedlistofcubes = new List <Solid>();

            foreach (var i in Enumerable.Range(0, 10000))
            {
                Console.WriteLine(i);
                Solid testcube = UnfoldTestUtils.SetupCube();
                //retainedlistofcubes.Add(testcube);
            }
        }
 public void Creating10000CubesExtractFaces()
 {
     foreach (var i in Enumerable.Range(0, 10000))
     {
         Console.WriteLine(i);
         Solid testcube = UnfoldTestUtils.SetupCube();
         //testcube.Dispose();
         //List<Face> faces = testcube.Faces.ToList();
         GC.Collect();
         GC.WaitForPendingFinalizers();
     }
 }
Beispiel #9
0
            public void UnfoldEachPairOfFacesInACubeChildAsRefFace()
            {
                Solid       testcube = UnfoldTestUtils.SetupCube();
                List <Face> faces    = testcube.Faces.ToList();

                //generate a graph of the cube
                var graph = ModelTopology.GenerateTopologyFromFaces(faces);

                List <Object> faceobjs = faces.Select(x => x as Object).ToList();

                UnfoldTestUtils.AssertEachFacePairUnfoldsCorrectly(graph);
            }
Beispiel #10
0
            public void Unfold27CubesFromSurfaces()
            {
                // unfold cube
                Solid       testcube = UnfoldTestUtils.SetupCube();
                List <Face> faces    = testcube.Faces.ToList();
                var         surfaces = faces.Select(x => x.SurfaceGeometry()).ToList();

                List <List <Surface> > manycubes = Enumerable.Repeat(surfaces, 27).ToList();
                var unfolds = manycubes.Select(x => PlanarUnfolder.Unfold(x)).ToList();


                var unfoldsurfaces = unfolds.SelectMany(x => x.UnfoldedSurfaceSet).ToList();
            }
        public void CanWrapFacesFromCube()
        {
            using (Solid testcube = UnfoldTestUtils.SetupCube())
            {
                var faces = testcube.Faces.ToList();

                var wrappedFaces = faces.Select(x => new FaceLikeEntity(x)).ToList();
                foreach (IDisposable item in wrappedFaces)
                {
                    Console.WriteLine("disposing a wrapped 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();
                    }
                }
            }
Beispiel #13
0
            public void Unfold1000CubesFromSurfacesNOGC()
            {
                // unfold cube
                Solid       testcube = UnfoldTestUtils.SetupCube();
                List <Face> faces    = testcube.Faces.ToList();
                var         surfaces = faces.Select(x => x.SurfaceGeometry()).ToList();

                List <List <Surface> > manycubes = Enumerable.Repeat(surfaces, 1000).ToList();
                var unfolds = new List <PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> >();

                for (int index = 0; index < manycubes.Count; index++)
                {
                    unfolds.Add(PlanarUnfolder.Unfold(manycubes[index]));
                    Console.WriteLine(index);
                }

                var unfoldsurfaces = unfolds.SelectMany(x => x.UnfoldedSurfaceSet).ToList();
            }
Beispiel #14
0
            public void UnfoldAndTabCubeFromFaces()
            {
                // unfold cube
                Solid       testcube = UnfoldTestUtils.SetupCube();
                List <Face> faces    = testcube.Faces.ToList();

                var unfoldObject = PlanarUnfolder.Unfold(faces);

                Console.WriteLine("generating tabs");

                // generate tabs
                var tabDict  = TabGeneration.GenerateTabSurfacesFromUnfold <EdgeLikeEntity, FaceLikeEntity>(unfoldObject);
                var justTabs = tabDict.Keys.SelectMany(x => tabDict[x]).ToList();

                Console.WriteLine("tabs generated");
                // next check the positions of the translated tab,

                UnfoldTestUtils.AssertTabsGoodFinalLocation <EdgeLikeEntity, FaceLikeEntity>(justTabs, unfoldObject);
            }
Beispiel #15
0
            public void FullyUnfoldCubeFromTriSurfaces()
            {
                Solid          testcube = UnfoldTestUtils.SetupCube();
                List <Face>    faces    = testcube.Faces.ToList();
                List <Surface> surfaces = faces.Select(x => x.SurfaceGeometry()).ToList();

                //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 unfoldsurfaces = PlanarUnfolder.Unfold(trisurfaces).UnfoldedSurfaceSet;

                UnfoldTestUtils.CheckAllUnfoldedFacesForCorrectUnfold(unfoldsurfaces);
            }
Beispiel #16
0
            public void UnfoldEachPairOfTriangularSurfacesInACubeParentAsRefFace()
            {
                Solid          testcube = UnfoldTestUtils.SetupCube();
                List <Face>    faces    = testcube.Faces.ToList();
                List <Surface> surfaces = faces.Select(x => x.SurfaceGeometry()).ToList();

                //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();

                //generate a graph of the cube
                var graph = ModelTopology.GenerateTopologyFromSurfaces(trisurfaces);


                UnfoldTestUtils.AssertEachFacePairUnfoldsCorrectly(graph);
            }
Beispiel #17
0
            public void UnfoldAndLabel2CubesFromFaces()
            {
                // unfold cube
                Solid       testcube = UnfoldTestUtils.SetupCube();
                List <Face> faces    = testcube.Faces.ToList();

                var unfoldObject1 = PlanarUnfolder.Unfold(faces);
                var unfoldObject2 = PlanarUnfolder.Unfold(faces);

                var unfoldsurfaces = unfoldObject1.UnfoldedSurfaceSet.Concat(unfoldObject2.UnfoldedSurfaceSet).ToList();

                Console.WriteLine("merging unfolds");
                var unfoldObject = PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> .
                                   MergeUnfoldings(new List <PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> >(){ unfoldObject1, unfoldObject2 });


                AssertMergeHasCorrectNumberOfSurfaces(unfoldObject, faces.Count * 2);
                AssertMergeHasCorrectNumberOfMaps(unfoldObject, new List <PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> >()
                {
                    unfoldObject1, unfoldObject2
                });

                Console.WriteLine("generating labels");

                // generate labels
                var labels = unfoldObject.StartingUnfoldableFaces.Select(x =>
                                                                         new PlanarUnfolder.UnfoldableFaceLabel <EdgeLikeEntity, FaceLikeEntity>(x)).ToList();

                UnfoldTestUtils.AssertLabelsGoodStartingLocationAndOrientation(labels);

                // next check the positions of the translated labels,

                var transformedGeo = labels.Select(x => PlanarUnfolder.MapGeometryToUnfoldingByID
                                                       (unfoldObject, x.AlignedLabelGeometry, x.ID)).ToList();

                UnfoldTestUtils.AssertLabelsGoodFinalLocationAndOrientation(labels, transformedGeo, unfoldObject);
            }