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(); } }
/// <summary> /// method that generates labels on the orginal model before being unfolded /// </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> > GenerateInitialLabels (PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> unfoldingObject, double labelScale = 1.0) { var labels = unfoldingObject.StartingUnfoldableFaces.Select(x => new PlanarUnfolder.UnfoldableFaceLabel <EdgeLikeEntity, FaceLikeEntity>(x, labelScale)).ToList(); return(labels.Select(x => x.AlignedLabelGeometry).ToList()); }
public void AssertMergeHasCorrectNumberOfMaps <K, T>(PlanarUnfolder.PlanarUnfolding <K, T> mergedunfold, List <PlanarUnfolder.PlanarUnfolding <K, T> > unfoldOps) where K : IUnfoldableEdge where T : IUnfoldablePlanarFace <K> { var expectedCount = unfoldOps.SelectMany(x => x.Maps).Count(); var realnum = mergedunfold.Maps.Count(); Assert.AreEqual(expectedCount, realnum); Console.WriteLine("correct number of maps in the merged unfold"); }
//methods for tab generation /// <summary> /// method for generating tabs on the unfolded surfaces, this method will generate tabs on all /// shared edges that were not folded, but only one of each pair. For example, if unfolding a cube, /// the corner edges that were split will only have tabs generated on one of the final resulting surface /// edges. This single edge in the cube becomes two edges in the unfold, and only one is tabbed. /// </summary> /// <param name="unfoldingObject"> an unfolding object that represents a single unfold operation</param> /// <param name="relativeWidth"> the tab thickness, relative to the distance between the center of the surface ///it lies on and the edge it represents, bigger surfaces will have larger tabs</param> /// <returns></returns> public static List <List <Surface> > GenerateUnfoldedTabs (PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> unfoldingObject, double relativeWidth = .3) { var output = new List <List <Surface> >(); foreach (var entry in TabGeneration.GenerateTabSurfacesFromUnfold(unfoldingObject, relativeWidth)) { output.Add(entry.Value.Select(x => x.AlignedTabSurf).ToList()); } return(output); }
public void AssertMergeHasCorrectNumberOfSurfaces <K, T>(PlanarUnfolder.PlanarUnfolding <K, T> mergedunfold, int numberOfSurfaces) where K : IUnfoldableEdge where T : IUnfoldablePlanarFace <K> { var numStartSurfs = mergedunfold.StartingUnfoldableFaces.SelectMany(x => x.SurfaceEntities).Count(); var numEndSurfs = mergedunfold.UnfoldedSurfaceSet.SelectMany(x => x).Count(); Assert.AreEqual(numStartSurfs, numEndSurfs); Assert.AreEqual(numStartSurfs, numberOfSurfaces); Console.WriteLine("correct number of surfaces in the merged unfold"); }
/// <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 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(); } } }
public static Dictionary <string, object> PackUnfoldedSurfaces( PlanarUnfolder.PlanarUnfolding <EdgeLikeEntity, FaceLikeEntity> unfolding, double width = 20, double height = 20, double gap = 3) { return(UnfoldPacking.PackUnfoldSurfaces(unfolding, width, height, gap)); }