Exemplo n.º 1
0
        private static H3.Cell[] GenTruss(Sphere[] simplex, Mesh mesh, Vector3D cen, bool ball)
        {
            // We don't want to include the first mirror (which reflects across cells).
            Sphere[] mirrors    = simplex.Skip(1).ToArray();
            Sphere[] allMirrors = simplex.ToArray();

            // Simplices will be the "cells" in Recurse.CalcCells.
            H3.Cell.Facet[] simplexFacets = simplex.Select(m => new H3.Cell.Facet(m)).ToArray();

            H3.Cell startingCell = new H3.Cell(simplexFacets);
            startingCell.Center = cen;

            //FCOrient( startingCell );
            //return null;

            startingCell = startingCell.Clone();                // So our mirrors don't get munged after we reflect around later.
            H3.Cell[] simplices = Recurse.CalcCells(mirrors, new H3.Cell[] { startingCell }, new Recurse.Settings()
            {
                Ball = ball
            });
            //H3.Cell[] simplices = new H3.Cell[] { startingCell };

            // Subsets
            //return simplices.Where( s => s.Depths[0] == 1 ).ToArray();
            //return simplices.ToArray();

            List <H3.Cell> final = new List <H3.Cell>();

            final.AddRange(simplices);

            // Add in other truss cells.
            Recurse.Settings settings = new Recurse.Settings();
            foreach (int[] reflections in TrussReflections())
            {
                foreach (H3.Cell c in simplices)
                {
                    H3.Cell clone = c.Clone();
                    foreach (int r in reflections)
                    {
                        clone.Reflect(allMirrors[r]);
                    }
                    if (Recurse.CellOk(clone, settings))
                    {
                        final.Add(clone);
                    }
                }
            }

            return(final.ToArray());
        }
Exemplo n.º 2
0
 private static H3.Cell[] GenCell(Sphere[] simplex, Mesh mesh, Vector3D cen, Vector3D[] auxPoints, bool ball)
 {
     //Sphere[] mirrors = simplex.Skip(1).ToArray();
     Sphere[]        mirrors       = simplex.ToArray();
     H3.Cell.Facet[] simplexFacets = simplex.Select(m => new H3.Cell.Facet(m)).ToArray();
     H3.Cell         startingCell  = new H3.Cell(simplexFacets);
     startingCell.Center    = cen;
     startingCell.Mesh      = mesh;
     startingCell.AuxPoints = auxPoints;
     startingCell           = startingCell.Clone();      // So our mirrors don't get munged after we reflect around later.
     H3.Cell[] simplices = Recurse.CalcCells(mirrors, new H3.Cell[] { startingCell }, new Recurse.Settings()
     {
         Ball = ball, Threshold = m_thresh
     });
     //return simplices.Where( s => s.Depths[0] <= layer /*&& s.Depths[0] == 3 && s.Depths[1] == 3*/ ).ToArray();
     return(simplices.ToArray());
 }
Exemplo n.º 3
0
        public static H3.Cell.Edge[] OneHoneycombOrthoscheme(HoneycombDef def, int[] active, int baseHue, Settings settings = null)
        {
            // Setup parameters.
            int numEdges = 250000;

            if (settings != null)
            {
                active   = settings.PovRay.Active;
                def      = new HoneycombDef(settings.P, settings.Q, settings.R);
                numEdges = settings.PovRay.NumEdges;
            }

            CalcThickness(active);
            if (settings != null)
            {
                H3.m_settings.AngularThickness = settings.PovRay.EdgeWidth;                     // ZZZ - should really stop using that settings class.
            }
            string baseName      = BaseName(def);
            string mirrorsString = ActiveMirrorsString(active);
            string suffix        = "-" + mirrorsString;
            string fileName      = baseName + suffix;

            if (ViewPath != null)
            {
                fileName += string.Format("_{0:D4}", ViewPath.Step);
            }

            if (File.Exists(fileName + ".pov"))
            {
                File.Delete(fileName + ".pov");
                //Console.WriteLine( string.Format( "Skipping {0}", fileName ) );
                //return;
            }

            Program.Log(string.Format("Building {0}", fileName));

            // The wiki mirrors are labeled in the reverse of ours.
            Func <int, int> mapMirror = i => 3 - i;

            active = active.Select(i => mapMirror(i)).OrderBy(i => i).ToArray();

            Simplex simplex = new Simplex();

            simplex.Facets = SimplexCalcs.Mirrors(def.P, def.Q, def.R);
            simplex.Verts  = SimplexCalcs.VertsBall(def.P, def.Q, def.R);

            Vector3D startingPoint = IterateToStartingPoint(def, active, simplex);

            if (startingPoint.DNE)
            {
                return(null);
            }
            List <H3.Cell.Edge> startingEdges = new List <H3.Cell.Edge>();

            foreach (int a in active)
            {
                Vector3D reflected = simplex.ReflectInFacet(startingPoint, a);
                startingEdges.Add(new H3.Cell.Edge(startingPoint, reflected));
                //startingEdges.Add( new H3.Cell.Edge( simplex.Verts[0], simplex.Verts[3] ) );	// Used for Borromean Rings complement image.
            }

            if (false)
            {
                Vector3D[] kv = simplex.Verts.Select(v => HyperbolicModels.PoincareToKlein(v)).ToArray();
                kv[3] = SimplexCalcs.VertexPointKlein(def.P, def.Q, def.R);
                Vector3D t       = (kv[3] - kv[0]) * 0.5;
                Sphere   gSphere = H3Models.Ball.OrthogonalSphereInterior(HyperbolicModels.KleinToPoincare(t));
                gSphere = H3Models.BallToKlein(gSphere);
                Vector3D t2 = Euclidean3D.IntersectionPlaneLine(gSphere.Normal, gSphere.Offset, kv[3] - kv[2], kv[2]);
                //t2 = kv[2] + ( kv[3] - kv[2]) * 0.5;

                t  = HyperbolicModels.KleinToPoincare(t);
                t2 = HyperbolicModels.KleinToPoincare(t2);
                startingEdges.Add(new H3.Cell.Edge(t, t2));
                startingEdges.Add(new H3.Cell.Edge(t, simplex.ReflectInFacet(t, 3)));
            }

            // If we are doing a view path, transform our geometry.
            if (ViewPath != null)
            {
                //Vector3D p = new Vector3D( 0, 0, .5 );
                Vector3D p = new Vector3D(0.08, 0.12, 0.07);
                simplex.Facets = simplex.Facets.Select(f => H3Models.Transform_PointToOrigin(f, p)).ToArray();
                simplex.Verts  = simplex.Verts.Select(v => H3Models.Transform_PointToOrigin(v, p)).ToArray();
                startingEdges  = startingEdges.Select(e => new H3.Cell.Edge(
                                                          H3Models.Transform_PointToOrigin(e.Start, p),
                                                          H3Models.Transform_PointToOrigin(e.End, p))).ToList();
            }

            SetupBaseHue(fileName, mirrorsString, baseHue);
            Recurse.m_background = baseHue == -1 ? new Vector3D() : new Vector3D(baseHue, 1, .1);

            H3.Cell.Edge[] edges = Recurse.CalcEdgesSmart2(simplex.Facets, startingEdges.ToArray(), numEdges);
            //H3.Cell.Edge[] edges = Recurse.CalcEdges( simplex.Facets, startingEdges.ToArray(),
            //	new Recurse.Settings() { ThreshType = Recurse.EdgeThreshType.Radial, Threshold = H3Models.Ball.FindLocationForDesiredRadius( settings.PovRay.EdgeWidth, 0.8/100 ) } );
            //edges = edges.Where( e => e.Depths[0] % 2 == 1 ).ToArray();	// Used for Borromean Rings complement image.

            // Shapeways truncated 436.
            if (false)
            {
                if (true)
                {
                    Mobius m = Mobius.Scale(1.0 / H3Models.UHS.ToE(Honeycomb.InRadius(def.P, def.Q, def.R)));
                    double a = -Math.PI / 2 + Math.Asin(1 / Math.Sqrt(3));
                    edges = edges.Select(e =>
                    {
                        Vector3D v1 = e.Start;
                        Vector3D v2 = e.End;
                        v1.RotateAboutAxis(new Vector3D(1, 0, 0), a);
                        v2.RotateAboutAxis(new Vector3D(1, 0, 0), a);
                        v1 = H3Models.Ball.ApplyMobius(m, v1);
                        v2 = H3Models.Ball.ApplyMobius(m, v2);
                        return(new H3.Cell.Edge(v1, v2));
                    }).ToArray();

                    double   thresh  = -.01;
                    Vector3D looking = new Vector3D(0, 0, -1);
                    edges = edges.Where(e => e.Start.Dot(looking) > thresh && e.End.Dot(looking) > thresh).ToArray();

                    Dictionary <H3.Cell.Edge, int> edgeDict = edges.ToDictionary(e => e, e => 1);
                    H3.RemoveDanglingEdgesRecursive(edgeDict);
                    edges = edgeDict.Keys.ToArray();
                }
                else
                {
                    Mobius m = Mobius.Scale(2);
                    edges = edges.Select(e =>
                    {
                        Vector3D v1 = e.Start;
                        Vector3D v2 = e.End;
                        v1          = H3Models.Ball.ApplyMobius(m, v1);
                        v2          = H3Models.Ball.ApplyMobius(m, v2);
                        return(new H3.Cell.Edge(v1, v2));
                    }).ToArray();

                    Dictionary <H3.Cell.Edge, int> edgeDict = edges.ToDictionary(e => e, e => 1);
                    H3.RemoveDanglingEdgesRecursive(edgeDict);
                    edges = edgeDict.Keys.ToArray();
                }
            }

            //H3.m_settings.Output = H3.Output.STL;
            //H3.m_settings.Scale = 50;
            H3.SaveToFile(fileName, edges, finite: true, append: true);

            bool doCells = false;

            H3.Cell[] cellsToHighlight = null;
            if (doCells)
            {
                int[] polyMirrors = new int[] { 1, 2, 3 };
                active = active.Select(i => mapMirror(i)).OrderBy(i => i).ToArray();

                H3.Cell startingCell = PolyhedronToHighlight(Geometry.Hyperbolic, polyMirrors, simplex, startingPoint);
                cellsToHighlight = Recurse.CalcCells(simplex.Facets, new H3.Cell[] { startingCell });
                H3.AppendFacets(fileName, cellsToHighlight);
            }

            return(edges);
        }
Exemplo n.º 4
0
        public static void OneHoneycombGoursat(int[] active, string baseName, int baseHue, Settings settings = null)
        {
            // Setup parameters.
            int numEdges = 250000;

            if (settings != null)
            {
                active   = settings.PovRay.Active;
                numEdges = settings.PovRay.NumEdges;
                baseName = string.Join("-", settings.Angles);
            }

            CalcThickness(active);
            if (settings != null)
            {
                H3.m_settings.AngularThickness = settings.PovRay.EdgeWidth;                 // ZZZ - should really stop using that settings class.
            }
            // Create the simplex.
            Simplex simplex = new Simplex();

            if (settings != null)
            {
                simplex.InitializeGoursat(settings.Angles);
            }
            else
            {
                simplex.InitializeGoursat();
            }

            // Map of labels for mirrors consistent with input scheme to Goursat function.
            // Map is from wikipedia labeling scheme to the indices our function generates.
            //
            // wiki == our index
            // 0100 == 0
            // 0001 == 1
            // 1000 == 2
            // 0010 == 3
            Func <int, int> mapMirror = i =>
            {
                switch (i)
                {
                case 0: return(2);

                case 1: return(0);

                case 2: return(3);

                case 3: return(1);
                }
                throw new System.ArgumentException();
            };

            // We need to set this up before converting the mirrors.
            string mirrorsString = ActiveMirrorsString(active);
            string suffix        = "_" + mirrorsString;

            // Convert our active mirrors into the Goursat tet indices.
            int[] polyMirrors = new int[] { 1, 2, 3 };
            active      = active.Select(i => mapMirror(i)).OrderBy(i => i).ToArray();
            polyMirrors = polyMirrors.Select(i => mapMirror(i)).OrderBy(i => i).ToArray();

            Vector3D            startingPoint = IterateToStartingPoint(null, active, simplex);
            List <H3.Cell.Edge> startingEdges = new List <H3.Cell.Edge>();

            foreach (int a in active)
            {
                Vector3D reflected = simplex.ReflectInFacet(startingPoint, a);
                startingEdges.Add(new H3.Cell.Edge(startingPoint, reflected));
            }

            bool doEdges = true;
            bool doCells = false;

            // Generate the honeycomb.
            H3.Cell.Edge[] edges = null;
            if (doEdges)
            {
                edges = Recurse.CalcEdgesSmart(simplex.Facets, startingEdges.ToArray(), numEdges);
            }

            // Highlighted cells.
            H3.Cell[] cellsToHighlight = null;
            if (doCells)
            {
                H3.Cell startingCell = PolyhedronToHighlight(Geometry.Hyperbolic, polyMirrors, simplex, startingPoint);
                cellsToHighlight = Recurse.CalcCells(simplex.Facets, new H3.Cell[] { startingCell });
                //cellsToHighlight = new H3.Cell[] { startingCell };
            }

            // plugin Wendy's nonuniform calcs here...
            //Nonuniform.Wendy( simplex, edges );

            // Trim out half the edges (the ones we won't see in our Pov-Ray view).

            /*Vector3D lookFrom = new Vector3D( 1, 1, 1 ) * 0.7;
             * Vector3D lookAt = new Vector3D();   // pov-ray lookat
             * double thresh = -.01;
             * if( doEdges )
             *      edges = edges.Where( e => e.Start.Dot( lookAt ) > thresh || e.End.Dot( lookAt ) > thresh ).ToArray();
             * //if( doCells )
             * //	cellsToHighlight = cellsToHighlight.Where( c => c.Center.Dot( lookAt ) > thresh ).ToArray();	// I don't think this works right
             */

            string fileName = baseName + suffix;

            if (File.Exists(fileName + ".pov"))
            {
                File.Delete(fileName + ".pov");
                //Console.WriteLine( string.Format( "Skipping {0}", fileName ) );
                //return;
            }

            SetupBaseHueGoursat(fileName, mirrorsString, baseHue);

            if (doEdges)
            {
                H3.SaveToFile(fileName, edges, finite: true, append: true);
            }
            if (doCells)
            {
                HashSet <H3.Cell.Edge> cellEdges = new HashSet <H3.Cell.Edge>(new H3.Cell.EdgeEqualityComparer());
                foreach (H3.Cell cell in cellsToHighlight)
                {
                    cell.AppendAllEdges(cellEdges);
                }
                edges = cellEdges.ToArray();
                H3.SaveToFile(fileName, edges, finite: true, append: true);

                H3.AppendFacets(fileName, cellsToHighlight);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// This generates a honeycomb by reflecting in 4 mirrors of the fundamental simplex.
        /// This "new" method is now old.
        /// </summary>
        public static void OneHoneycombNew(HoneycombDef imageData)
        {
            int p = imageData.P;
            int q = imageData.Q;
            int r = imageData.R;

            double thickness           = 0.05;
            double thicknessSpherical  = Spherical2D.s2eNorm(thickness);
            double thicknessHyperbolic = R3.Math.DonHatch.h2eNorm(thickness);
            double threshold           = 1;

            H3.Cell.Edge[] edges            = null;
            H3.Cell[]      cellsToHighlight = null;
            Sphere[]       simplex          = null;
            Vector3D       vertex           = new Vector3D();

            Geometry g = Util.GetGeometry(p, q, r);

            if (g == Geometry.Spherical)
            {
                thickness = thicknessSpherical /*.07 for 333*/  /* 0.05for 433*/  /*.025 for 533,335*/;
                threshold = 10000;

                simplex = SimplexCalcs.MirrorsSpherical(p, q, r);
                vertex  = SimplexCalcs.VertexSpherical(p, q, r);

                // Ugly special casing for 333, since it has a vertex project to infinity.
                if (p == 3 && q == 3 && r == 3)
                {
                    SpecialCase333();
                }
            }
            else if (g == Geometry.Euclidean)
            {
                thickness = thickness / 2;
                threshold = 1 /*20*/;

                //SimplexCalcs.CalcEScale();
                simplex = SimplexCalcs.MirrorsEuclidean();
                Vector3D[] verts = SimplexCalcs.VertsEuclidean();
                vertex = verts[2];
            }
            else
            {
                thickness = thicknessHyperbolic;
                threshold = 0.01;

                simplex = SimplexCalcs.Mirrors(p, q, r);
                Vector3D[] verts = SimplexCalcs.VertsBall(p, q, r);
                vertex = verts[2];

                //Vector3D[] simplexVerts = SimplexCalcs.VertsBall( p, q, r );
                //H3.Cell.Edge edge = new H3.Cell.Edge( simplexVerts[2], simplexVerts[3] );
                //H3.Cell.Edge edge = SimplexCalcs.HoneycombEdgeBall( p, q, r );
                //H3.Cell.Edge[] startingEdges = new H3.Cell.Edge[] { edge };

                //H3.Cell.Edge[] edges = Recurse.CalcEdgesSmart2( simplex, startingEdges );

                // Vertex Centered.
                bool vertexCentered = false;
                if (vertexCentered)
                {
                    Vector3D v = SimplexCalcs.VertexPointBall(p, q, r);
                    v = H3Models.BallToUHS(v);
                    double scale = 1.0 / v.Abs();
                    edges = edges.Select(e =>
                    {
                        Vector3D start = H3Models.UHSToBall(H3Models.BallToUHS(e.Start) * scale);
                        Vector3D end   = H3Models.UHSToBall(H3Models.BallToUHS(e.End) * scale);
                        return(new H3.Cell.Edge(start, end));
                    }).ToArray();
                }

                // Code to show endpoints of 535

                /*using( StreamWriter sw = File.CreateText( "535_points.pov" ) )
                 * {
                 *      HashSet<Vector3D> verts = new HashSet<Vector3D>();
                 *      foreach( H3.Cell.Edge e in edges )
                 *      {
                 *              verts.Add( Sterographic.SphereToPlane( e.Start ) );
                 *              verts.Add( Sterographic.SphereToPlane( e.End ) );
                 *      }
                 *
                 *      foreach( Vector3D vert in verts )
                 *              if( !Infinity.IsInfinite( vert ) )
                 *                      sw.WriteLine( PovRay.Sphere( new Sphere() { Center = vert, Radius = 0.01 } ) );
                 * }*/
            }

            // Recurse
            bool dual = false;
            {
                H3.Cell.Edge[] startingEdges = null;
                if (dual)
                {
                    startingEdges = new H3.Cell.Edge[] { SimplexCalcs.DualEdgeBall(simplex) }
                }
                ;
                else
                {
                    //startingEdges = new H3.Cell.Edge[] { SimplexCalcs.HoneycombEdgeBall( simplex, vertex ) };
                    Vector3D[] verts  = SimplexCalcs.VertsEuclidean();
                    Vector3D   v1     = verts[0] + 2 * verts[2];             // adjacent cube center
                    Vector3D   corner = verts[3];

                    startingEdges = new H3.Cell.Edge[] { new H3.Cell.Edge(v1, corner) };
                }

                edges = Recurse.CalcEdges(simplex, startingEdges, new Recurse.Settings()
                {
                    G = g, Threshold = threshold
                });

                edges = edges.Where(e =>
                {
                    int sum = e.Depths.Count(d => d == 0);
                    return(true);
                }).ToArray();

                //CullHalfOfEdges( ref edges );

                // No need to cull edges in spherical case.
                // This was just to generate some images for 350-cell paper.
                //edges = Cull120Cell( edges );

                Simplex tet = new Simplex();
                tet.Facets = simplex;

                if (dual)
                {
                    H3.Cell.Edge[] oneDualCell = edges.Where(e => e.Depths[2] == 0).ToArray();
                    simplex = simplex.Skip(1).ToArray();
                    edges   = Recurse.CalcEdges(simplex, oneDualCell, new Recurse.Settings()
                    {
                        G = g, Threshold = threshold
                    });

                    int[]   polyMirrors  = new int[] { 0, 1, 3 };
                    H3.Cell startingCell = HoneycombGen.PolyhedronToHighlight(g, polyMirrors, tet, new Vector3D());
                    cellsToHighlight = Recurse.CalcCells(simplex, new H3.Cell[] { startingCell });
                    //cellsToHighlight = new H3.Cell[] { startingCell };
                    //cellsToHighlight = cellsToHighlight.Skip( 7 ).ToArray();
                }
                else
                {
                    int[]   polyMirrors  = new int[] { 1, 2, 3 };
                    H3.Cell startingCell = HoneycombGen.PolyhedronToHighlight(g, polyMirrors, tet, vertex);
                    //cellsToHighlight = Recurse.CalcCells( simplex, new H3.Cell[] { startingCell } );
                    cellsToHighlight = new H3.Cell[] { startingCell };
                }

                // Include just one cell?
                bool includeOne = false;
                if (includeOne)
                {
                    edges = edges.Where(e => e.Depths[0] == 0).ToArray();
                    //cellsToHighlight = cellsToHighlight.Where( c => c.Depths[0] == 0 ).ToArray();
                }
            }

            // Rotate
            bool rotate = false;

            if (rotate)
            {
                CompoundOfFive24Cells(ref edges);
            }

            // Write the file
            bool pov = true;

            if (pov)
            {
                string filename = string.Format("{0}{1}{2}.pov", p, q, r);
                PovRay.WriteEdges(new PovRay.Parameters()
                {
                    AngularThickness = thickness
                }, g, edges,
                                  filename, append: false);
                //File.Delete( filename );
                //PovRay.AppendFacets( cellsToHighlight, filename );

                HashSet <Vector3D> verts = new HashSet <Vector3D>();
                foreach (H3.Cell.Edge e in edges)
                {
                    verts.Add(e.Start);
                    verts.Add(e.End);
                }

                /*foreach( Vector3D v in verts )
                 * {
                 *      Vector3D t = v;
                 *      t.Normalize();
                 *      t *= 0.9;
                 *      System.Diagnostics.Trace.WriteLine( string.Format( "light_source {{ <{0},{1},{2}> White*.2 }}", t.X, t.Y, t.Z ) );
                 * }*/


                /*
                 * // Include the standard pov stuff, so we can batch this.
                 * string fileName = imageData.FormatFilename( string.Empty );
                 * using( StreamWriter sw = File.CreateText( fileName + ".pov" ) )
                 * {
                 *      sw.WriteLine( "#include \"C:\\Users\\hrn\\Documents\\roice\\povray\\paper\\H3.pov\"" );
                 * }
                 *
                 * bool dummy = true;	// Doesn't matter for Pov-Ray, just Shapeways meshes.
                 * H3.SaveToFile( fileName, edges, dummy, append: true );
                 */
            }
            else
            {
                if (g == Geometry.Spherical)
                {
                    edges = edges.Where(e => e.Start.Valid() && e.End.Valid() && !Infinity.IsInfinite(e.Start) && !Infinity.IsInfinite(e.End)).ToArray();
                    S3.EdgesToStl(edges);
                }
                else
                {
                    throw new System.NotImplementedException();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// This is like the GenCell method, but super hacked up for the Catacombs image with Henry.
        /// </summary>
        internal static void GenCellCatacombs(Sphere[] simplex, bool ball)
        {
            // We don't want to include the first mirror (which reflects across cells).
            Sphere[] mirrors    = simplex.Skip(1).ToArray();
            Sphere[] allMirrors = simplex.ToArray();

            // Simplices will be the "cells" in Recurse.CalcCells.
            H3.Cell.Facet[] simplexFacets = simplex.Select(m => new H3.Cell.Facet(m)).ToArray();

            // Offset cell boundary ever so slightly, to avoid artifacts of adjacent cells.
            Sphere toReflectLater = simplexFacets[0].Sphere.Clone();

            //simplexFacets[0].Sphere = CoxeterImages.GeodesicOffset( simplexFacets[0].Sphere, ball ? -1e-6 : 1e-7, ball );

            H3.Cell startingCell = new H3.Cell(simplexFacets);
            startingCell = startingCell.Clone();                // So our mirrors don't get munged after we reflect around later.
            Vector3D cen = new Vector3D(0.05, 0.01, -0.05);     //	373, 438

            //Vector3D cen = new Vector3D( 0.05, 0.01, 100 );		//	637
            //cen.RotateXY( Math.PI / 2 );	// only if we also rotate simplex mirrors.  XXX - make a setting.
            startingCell.Center = cen;
            H3.Cell[] simplices = Recurse.CalcCells(mirrors, new H3.Cell[] { startingCell }, new Recurse.Settings()
            {
                Ball = ball
            });

            List <H3.Cell> simplicesFinal = new List <H3.Cell>();
            List <int[]>   reflectionSets = new List <int[]>();

            // 1 reflects in x-axis
            // 3, 1 rotates right
            // 1, 3 rotates left

            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 0, 1, 3 });
            reflectionSets.Add(new int[] { 0, 3, 1, 2, 3, 1, 0, 3, 1, 2, 0, 3 });

            // 2
            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2, 3, 1, 3, 2, 3, 1 });
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0,		3, 1, 3, 1, 0,	3, 1, 3, 1, 3, 1, 2,	3, 1, 3, 2, 3, 1 } );

            // 3
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 3, 1, 0, 3, 1, 2 } );
            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 3, 0, 3, 1, 3, 1, 0, 2 });
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 2 } );

            // 5
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 1, 2, 3, 1 } );

            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 2, 3, 1 } );
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2, 3, 1, 3, 1, 0, 1, 3 } );	// baby
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2 } );	// maybe
            //reflectionSets.Add( new int[] { 0, 3, 1, 2, 3, 1, 0, 2, 1, 3 } );
            //reflectionSets.Add( new int[] { 0, 3, 1, 2, 3, 1, 0, 3, 1, 2 } );		// not great orientation
            // reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 2 } );	// big

            bool ceiling = true;

            if (ceiling)
            {
                simplicesFinal = simplices.ToList();
            }
            else
            {
                foreach (int[] set in reflectionSets)
                {
                    List <H3.Cell> copy = simplices.Select(s => s.Clone()).ToList();
                    foreach (int r in set)
                    {
                        foreach (H3.Cell cell in copy)
                        {
                            cell.Reflect(allMirrors[r]);
                        }
                    }
                    simplicesFinal.AddRange(copy);
                }
            }

            /*
             * // A second cell.
             * //toReflectLater = simplices[45].Facets[0].Sphere.Clone();
             * //toReflectLater = simplices.First( s => s.Depth == 2 ).Facets[0].Sphere.Clone();
             * foreach( H3.Cell cell in simplices )
             *      cell.Reflect( toReflectLater );
             *
             * // A third cell.
             * toReflectLater = simplices[40].Facets[0].Sphere.Clone();
             * //toReflectLater = simplices.First( s => s.Depth == 4 ).Facets[0].Sphere.Clone();
             * foreach( H3.Cell cell in simplices )
             *      cell.Reflect( toReflectLater );
             *
             * foreach( H3.Cell cell in simplices )
             *      cell.Depths = new int[4];
             * List<H3.Cell> simplicesFinal = Recurse.CalcCells2( mirrors, simplices ).ToList();
             * simplicesFinal = simplicesFinal.Where( s => s.Depths[0] % 3 == 1 && s.Depths[1] % 2 == 0 && s.Depths[2] % 2 == 1 ).ToList();
             */

            /*
             * List<H3.Cell> simplicesFinal = new List<H3.Cell>();
             * //for( int d = 0; d < 1; d+=2 )
             * int d = 0;
             * {
             *      //Sphere toReflect = simplices.First( s => s.Depth == d ).Facets[0].Sphere.Clone();
             *      //Sphere toReflect = simplices.Where( s => s.Depth == d ).Skip(1).Take(1).First().Facets[0].Sphere.Clone();
             *      List<H3.Cell> reflectionCells = simplices.Where( s => s.Depths[1] == d && s.Depths[0] % 2 == 0 ).Skip(0).Take(1).ToList();
             *      foreach( Sphere toReflect in reflectionCells.Select( c => c.Facets[0].Sphere.Clone() ) )
             *      {
             *              List<H3.Cell> thisCell = new List<H3.Cell>();
             *              foreach( H3.Cell cell in simplices )
             *              {
             *                      H3.Cell clone = cell.Clone();
             *                      clone.Reflect( toReflect );
             *                      thisCell.Add( clone );
             *              }
             *
             *              //Sphere toReflect2 = thisCell.First( s => s.Depth1 == d + 3 && s.Depth0 % 2 == 0 ).Facets[0].Sphere.Clone();
             *              //List<H3.Cell> reflectionCellsTemp = simplices.Where( s => Math.Abs( s.Depths[1] - d ) == 2 && s.Depths[0] % 2 == 0 ).ToList();
             *              List<H3.Cell> reflectionCellsTemp = simplices.Where( s => s.Depths[1] == 2 && s.Depths[1] == s.Depths[0] + s.Depths[2] ).ToList();
             *              List<H3.Cell> reflectionCells2 = reflectionCellsTemp;//.Where( ( x, i ) => i % 3 == 0 ).ToList(); // .Skip( 5 ).Take( 5 ).ToList();
             *              foreach( Sphere toReflect2 in reflectionCells2.Select( c => c.Facets[0].Sphere.Clone() ) )
             *              //Sphere toReflect2 = toReflectLater;
             *              {
             *                      foreach( H3.Cell cell in thisCell )
             *                      {
             *                              H3.Cell clone = cell.Clone();
             *                              clone.Reflect( toReflect2 );
             *                              simplicesFinal.Add( clone );
             *                      }
             *              }
             *      }
             * }*/

            int count = 0;

            foreach (H3.Cell cell in simplicesFinal)
            {
                count++;

                //if( count % 2 == 0 )
                //	continue;

                /*if( count < 1 )
                 *      continue;
                 * if( count > 30 )
                 *      return;
                 */
                //int[] include = new int[] { 0, 1, 2, 3 };
                int[] include = new int[] { 0 };
                PovRay.AppendSimplex(cell.Facets.Select(f => f.Sphere).ToArray(), cell.Center, include, "cell.pov");
            }
        }