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