Exemple #1
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);
            }
Exemple #2
0
            public void UnfoldAndLabelCurvedArcLoft()
            {
                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 unfoldObject = PlanarUnfolder.Unfold(trisurfaces);

                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);
            }
            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();
                    }
                }
            }
            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);
            }
            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();
                    }
                }
            }
Exemple #6
0
            public void UnfoldCurvedArcSweep()
            {
                Surface testsweep = UnfoldTestUtils.SetupArcCurveSweep();

                var surfaces = new List <Surface>()
                {
                    testsweep
                };
                //handle tesselation here
                var pointtuples = Tesselation.Tessellate(surfaces, -1, 30);
                //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);

                foreach (IDisposable item in trisurfaces)
                {
                    item.Dispose();
                }
            }
Exemple #7
0
            public void UnfoldAndLabelCurvedArcLoft()
            {
                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 unfoldObject = PlanarUnfolder.Unfold(trisurfaces);

                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);
            }
Exemple #8
0
        public static void AssertLabelsGoodStartingLocationAndOrientation <K, T>(List <PlanarUnfolder.UnfoldableFaceLabel
                                                                                       <K, T> > labels)
            where K : IUnfoldableEdge
            where T : IUnfoldablePlanarFace <K>
        {
            // get aligned geometry
            var alignedGeo = labels.Select(x => x.AlignedLabelGeometry).ToList();

            // assert that the bounding box of the label at least intersects the face it represents
            for (int i = 0; i < alignedGeo.Count; i++)
            {
                var curveList = alignedGeo[i];

                var curvePoints = curveList.Select(x => x.StartPoint);
                var labelPlane  = Plane.ByBestFitThroughPoints(curvePoints);
                var testsurf    = Surface.ByPatch(Rectangle.ByWidthLength(1, 1).
                                                  Transform(CoordinateSystem.ByPlane(labelPlane)) as Curve);

                //check that the aligned curves intersect the surface they are aligned to
                Assert.IsTrue(curveList.SelectMany(x => labels[i].UnfoldableFace.SurfaceEntities.Select(x.DoesIntersect)).Any());
                Console.WriteLine("This label was in the right spot at the start of the unfold");
                //also assert that the face normal is parallel with the normal of the boundingbox plane

                var face = labels[i].UnfoldableFace.SurfaceEntities;

                UnfoldTestUtils.AssertSurfacesAreCoplanar(testsurf, face.First());
                Console.WriteLine("This label was in the right orientation at the start of the unfold");

                testsurf.Dispose();
                labelPlane.Dispose();
            }
        }
Exemple #9
0
            public void UnfoldAndLabel2ArcLofts()
            {
                // unfold cube
                Surface testloft  = UnfoldTestUtils.SetupArcLoft();
                Surface testloft2 = UnfoldTestUtils.SetupArcLoft();
                var     surfaces  = new List <Surface>()
                {
                    testloft
                };
                var surfaces2 = new List <Surface>()
                {
                    testloft
                };
                //handle tesselation here
                var pointtuples  = Tesselation.Tessellate(surfaces, -1, 512);
                var pointtuples2 = 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();
                List <Surface> trisurfaces2 = pointtuples2.Select(x => Surface.ByPerimeterPoints(new List <Point>()
                {
                    x[0], x[1], x[2]
                })).ToList();

                var unfoldObject1 = PlanarUnfolder.Unfold(trisurfaces);
                var unfoldObject2 = PlanarUnfolder.Unfold(trisurfaces2);

                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, trisurfaces.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);
            }
Exemple #10
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();
            }
Exemple #11
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);
            }
Exemple #12
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);
            }
Exemple #13
0
        public static void CheckAllUnfoldedFacesForCorrectUnfold(List <List <Surface> > unfoldsurfaces)
        {
            foreach (var srflist in unfoldsurfaces)
            {
                UnfoldTestUtils.AssertNoSurfaceIntersections(srflist);

                UnfoldTestUtils.AssertConditionForEverySurfaceAgainstEverySurface(srflist, UnfoldTestUtils.AssertSurfacesAreCoplanar);

                UnfoldTestUtils.AssertConditionForEverySurfaceAgainstEverySurface(srflist, UnfoldTestUtils.AssertRotatedSurfacesDoNotShareSameCenter);
            }
        }
        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);
            }
        }
Exemple #15
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);
            }
 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();
     }
 }
Exemple #17
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();
            }
        }
Exemple #18
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();
                    }
                }
            }
Exemple #21
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();
            }
Exemple #22
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);
            }
Exemple #23
0
            public void FullyUnfoldConeTallFromTriSurfaces()
            {
                Solid          testCone = UnfoldTestUtils.SetupTallCone();
                List <Face>    faces    = testCone.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);
            }
Exemple #24
0
            public void UnfoldOf300TriSurface()
            {
                var surface = UnfoldTestUtils.SetupArcLoft();

                var surfaces = new List <Surface>()
                {
                    surface
                };

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

                Assert.DoesNotThrow(() => PlanarUnfolder.Unfold(trisurfaces));
            }
Exemple #25
0
            public void UnfoldEachPairOfTriangularSurfacesInAConeWideParentAsRefFace()
            {
                Solid          testCone = UnfoldTestUtils.SetupLargeCone();
                List <Face>    faces    = testCone.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);
            }
Exemple #26
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);
            }