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 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 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 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 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); }
// exposes node to tesselate surfaces in dynamo, returns triangular surfaces // Peter will hate this :) /// <summary> /// This method exposes the tessellation algorithm that is used to display /// geometry in Dynamo's watch3d and background preview displays as a node. /// It is possible this node and all dependent code in the unfolding library /// will be replaced by faster triangle representation that does not require /// conversion to a surface. /// </summary> /// <param name="surfaces"></param> /// <param name="tolerance"> tolerance between the surface and mesh representation</param> /// <param name="maxGridLines">maximum number of surface divisons that define one direction of the mesh </param> /// <returns name = "Surfaces"> a list of trimmed planar surfaces that represent triangles</returns> public static List <Surface> _TesselateSurfaces(List <Surface> surfaces, double tolerance = -1, int maxGridLines = 512) { var pointtuples = Tesselation.Tessellate(surfaces, tolerance, maxGridLines); //convert triangles to surfaces List <Surface> trisurfaces = pointtuples.Select(x => Surface.ByPerimeterPoints(new List <Point>() { x[0], x[1], x[2] })).ToList(); return(trisurfaces); }
/// <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 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 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); }
// The following methods may be removed from Import eventually #region explorationdebug // method is for debugging the BFS output visually in dynamo, very useful public static object __BFSTestTesselation(List <Surface> surfaces, double tolerance = -1, int maxGridLines = 512) { //handle tesselation here var pointtuples = Tesselation.Tessellate(surfaces, tolerance, maxGridLines); //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); //perform BFS on the graph and get back the tree var nodereturn = ModelGraph.BFS <EdgeLikeEntity, FaceLikeEntity>(graph); var tree = nodereturn; var treegeo = ModelGraph.ProduceGeometryFromGraph <EdgeLikeEntity, FaceLikeEntity> (tree as List <GraphVertex <EdgeLikeEntity, FaceLikeEntity> >); return(treegeo); }