public Tab(T face, K edge, PlanarUnfolder.PlanarUnfolding <K, T> unfoldObject, double tabOffset = .3)
 {
     ID             = face.ID;
     UnfoldableFace = face;
     TabSurf        = generateTabGeo(edge, tabOffset);
     AlignedTabSurf = PlanarUnfolder.DirectlyMapGeometryToUnfoldingByID(unfoldObject, TabSurf, ID);
 }
示例#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
        /// <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);
        }
示例#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 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);
            }
示例#7
0
        public static void AssertTabsGoodFinalLocation <K, T>(List <TabGeneration.Tab <K, T> > tabs,
                                                              PlanarUnfolder.PlanarUnfolding <K, T> unfoldingObject)
            where K : IUnfoldableEdge
            where T : IUnfoldablePlanarFace <K>
        {
            var oldgeo = new List <Geometry>();

            // assert that the final geometry  intersect with the
            //the orginal surfaces(transformed through their transformation histories)
            for (int i = 0; i < tabs.Count; i++)
            {
                var tab        = tabs[i];
                var initialSrf = unfoldingObject.StartingUnfoldableFaces[tab.ID].SurfaceEntities;

                var transformedInitialSurfaceToFinal = PlanarUnfolder.DirectlyMapGeometryToUnfoldingByID
                                                       <K, T, Surface>
                                                           (unfoldingObject, initialSrf, tab.ID);

                Assert.IsTrue(transformedInitialSurfaceToFinal.Select(x => tab.TabSurf.DoesIntersect(x)).Any());
                oldgeo.AddRange(transformedInitialSurfaceToFinal);
                Console.WriteLine("This tab was in the right spot at the end of the unfold, \n" +
                                  "it intersects with the correct face");
            }

            foreach (IDisposable item in oldgeo)
            {
                item.Dispose();
            }
        }
示例#8
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);
            }
示例#9
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();
            }
示例#10
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);
            }
示例#11
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) }
            });
        }
示例#12
0
        /// <summary>
        /// method that generates labels on the unfolded faces
        /// </summary>
        /// <param name="unfoldingObject"> requires an unfolding object that represents an unfolding operation</param>
        /// <param name="labelScale"> scale for the text labels</param>
        /// <returns name = "labels"> labels composed of curve geometry </returns>
        public static List <List <Curve> > GenerateUnfoldedLabels
            (PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> unfoldingObject, double labelScale = 1.0)
        {
            var labels = unfoldingObject.StartingUnfoldableFaces.Select(x =>
                                                                        new PlanarUnfolder.UnfoldableFaceLabel <EdgeLikeEntity, FaceLikeEntity>(x, labelScale)).ToList();

            // need to make one piece of geometry from list of geo...
            var transformedGeo = labels.Select(x => PlanarUnfolder.MapGeometryToUnfoldingByID(unfoldingObject, x.AlignedLabelGeometry, x.ID)).ToList();


            return(transformedGeo);
        }
示例#13
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();
            }
示例#14
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);
        }
示例#15
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();
            }
示例#16
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);
            }
示例#17
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) },
            });
        }
示例#18
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));
            }
示例#19
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);
            }
示例#20
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);
            }
示例#21
0
        public static void AssertLabelsGoodFinalLocationAndOrientation <K, T>(List <PlanarUnfolder.UnfoldableFaceLabel
                                                                                    <K, T> > labels, List <List <Curve> >
                                                                              translatedgeo, PlanarUnfolder.PlanarUnfolding <K, T> unfoldingObject)
            where K : IUnfoldableEdge
            where T : IUnfoldablePlanarFace <K>
        {
            var oldgeo = new List <Geometry>();

            // assert that the final geometry  intersect with the
            //the orginal surfaces(transformed through their transformation histories)
            for (int i = 0; i < labels.Count; i++)
            {
                var label  = labels[i];
                var curves = translatedgeo[i];

                var transformedInitialSurfaceToFinal = PlanarUnfolder.DirectlyMapGeometryToUnfoldingByID
                                                       <K, T, Surface>
                                                           (unfoldingObject, label.UnfoldableFace.SurfaceEntities, label.ID);

                Assert.IsTrue(curves.SelectMany(x => transformedInitialSurfaceToFinal.Select(x.DoesIntersect)).Any());
                oldgeo.AddRange(transformedInitialSurfaceToFinal);
                Console.WriteLine("This label was in the right spot at the end of the unfold");
            }

            foreach (IDisposable item in oldgeo)
            {
                item.Dispose();
            }
            foreach (var list in translatedgeo)
            {
                foreach (IDisposable item in list)
                {
                    item.Dispose();
                }
            }
        }