Ejemplo n.º 1
0
 public HoneycombDef( int p, int q, int r )
 {
     P = p;
     Q = q;
     R = r;
     Projection = Polytope.Projection.VertexCentered;
 }
Ejemplo n.º 2
0
        public void GenerateInternal(TilingConfig config, Polytope.Projection projection = Polytope.Projection.FaceCentered)
        {
            this.TilingConfig = config;

            // Create a base tile.
            Tile tile = CreateBaseTile(config);

            // Handle edge/vertex centered projections.
            if (projection == Polytope.Projection.VertexCentered)
            {
                Mobius mobius = config.VertexCenteredMobius();
                tile.Transform(mobius);
            }
            else if (projection == Polytope.Projection.EdgeCentered)
            {
                Mobius mobius = config.EdgeMobius();
                tile.Transform(mobius);
            }

            TransformAndAdd(tile);

            List <Tile> tiles = new List <Tile>();

            tiles.Add(tile);
            Dictionary <Vector3D, bool> completed = new Dictionary <Vector3D, bool>();

            completed[tile.Boundary.Center] = true;
            ReflectRecursive(tiles, completed);

            FillOutIsometries(tile, m_tiles, config.Geometry);
            FillOutIncidences();
        }
Ejemplo n.º 3
0
        public static void Generate(EHoneycomb honeycomb, H3.Settings settings)
        {
            // XXX - Block the same as in H3.  Share code better.
            H3.Cell template = null;
            {
                int p, q, r;
                Honeycomb.PQR(honeycomb, out p, out q, out r);

                // Get data we need to generate the honeycomb.
                Polytope.Projection projection = Polytope.Projection.FaceCentered;
                double phi, chi, psi;
                H3.HoneycombData(honeycomb, out phi, out chi, out psi);

                H3.SetupCentering(honeycomb, settings, phi, chi, psi, ref projection);

                Tiling       tiling = new Tiling();
                TilingConfig config = new TilingConfig(p, q);
                tiling.GenerateInternal(config, projection);

                H3.Cell first = new H3.Cell(p, H3.GenFacets(tiling));
                first.ToSphere();                       // Work in ball model.
                first.ScaleToCircumSphere(1.0);
                first.ApplyMobius(settings.Mobius);

                template = first;
            }

            // Center
            Vector3D center = template.Center;

            // Face
            H3.Cell.Facet facet = template.Facets[0];
            Sphere        s     = H3Models.Ball.OrthogonalSphereInterior(facet.Verts[0], facet.Verts[1], facet.Verts[2]);
            Vector3D      face  = s.Center;

            face.Normalize();
            face *= DistOriginToOrthogonalSphere(s.Radius);

            // Edge
            Circle3D c;

            H3Models.Ball.OrthogonalCircleInterior(facet.Verts[0], facet.Verts[1], out c);
            Vector3D edge = c.Center;

            edge.Normalize();
            edge *= DistOriginToOrthogonalSphere(c.Radius);

            // Vertex
            Vector3D vertex = facet.Verts[0];

            Tet fundamental = new Tet(center, face, edge, vertex);

            // Recurse.
            int level = 1;
            Dictionary <Tet, int> completedTets = new Dictionary <Tet, int>(new TetEqualityComparer());

            completedTets.Add(fundamental, level);
            List <Tet> tets = new List <Tet>();

            tets.Add(fundamental);
            ReflectRecursive(level, tets, completedTets, settings);

            Shapeways mesh = new Shapeways();

            foreach (KeyValuePair <Tet, int> kvp in completedTets)
            {
                if (Utils.Odd(kvp.Value))
                {
                    continue;
                }

                Tet tet = kvp.Key;

                // XXX - really want sphere surfaces here.
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[0], tet.Verts[1], tet.Verts[2]));
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[0], tet.Verts[3], tet.Verts[1]));
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[0], tet.Verts[2], tet.Verts[3]));
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[1], tet.Verts[3], tet.Verts[2]));
            }

            mesh.Mesh.Scale(settings.Scale);
            STL.SaveMeshToSTL(mesh.Mesh, H3.m_baseDir + "fundamental" + ".stl");
        }