示例#1
0
        /// <summary>
        /// Method for taking a list of planar surfaces and unfolding them,
        /// </summary>
        /// <param name="surfaces"> the surfaces to be unfolded</param>
        /// <returns name = "surfaces"> the unfolded surfaces </returns>
        public static List <List <Surface> > UnfoldListOfSurfaces(List <Surface> surfaces)
        {
            surfaces.RemoveAll(item => item == null);
            var unfoldsurfaces = PlanarUnfolder.Unfold(surfaces);

            return(unfoldsurfaces.UnfoldedSurfaceSet);
        }
示例#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);
            }
示例#3
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);
            }
示例#4
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);
            }
示例#5
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();
                }
            }
示例#6
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);
            }
示例#7
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();
            }
示例#8
0
        public static Dictionary <string, object> UnfoldListOfSurfaces_AndReturnTransforms(List <Surface> surfaces)
        {
            surfaces.RemoveAll(item => item == null);
            var unfolding = PlanarUnfolder.Unfold(surfaces);

            return(new Dictionary <string, object>
            {
                { "surfaces", (unfolding.UnfoldedSurfaceSet) },
                { "unfoldingObject", (unfolding) }
            });
        }
示例#9
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);
            }
示例#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();
            }
示例#11
0
        /// <summary>
        /// Method for taking a list of surfaces,tesselating them at max tesselation level,
        /// and then unfolding them.
        /// </summary>
        /// <param name="surfaces"> the surfaces to be tesselated and unfolded</param>
        /// <returns name = "surfaces"> the unfolded surfaces </returns>
        public static List <List <Surface> > __UnfoldCurvedSurfacesByTesselation(List <Surface> surfaces)
        {
            surfaces.RemoveAll(item => item == null);
            //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);

            return(unfoldsurfaces.UnfoldedSurfaceSet);
        }
示例#12
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();
            }
示例#13
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);
            }
示例#14
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);
            }
示例#15
0
        public static Dictionary <string, object> __UnfoldCurvedSurfacesByTessellation_AndReturnTransforms(List <Surface> surfaces)
        {
            surfaces.RemoveAll(item => item == null);
            //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 unfolding = PlanarUnfolder.Unfold(trisurfaces);

            return(new Dictionary <string, object>
            {
                { "surfaces", (unfolding.UnfoldedSurfaceSet) },
                { "unfoldingObject", (unfolding) },
            });
        }
示例#16
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));
            }
示例#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);
            }