示例#1
0
        public static void EdgesToStl(H3.Cell.Edge[] edges)
        {
            Shapeways mesh = new Shapeways();

            int divisions = 25;

            foreach (H3.Cell.Edge edge in edges)
            {
                Segment seg = Segment.Line(
                    Sterographic.R3toS3(edge.Start),
                    Sterographic.R3toS3(edge.End));
                Vector3D[] points = seg.Subdivide(divisions);

                ProjectAndAddS3Points(mesh, points);
            }

            for (int i = 0; i < mesh.Mesh.Triangles.Count; i++)
            {
                mesh.Mesh.Triangles[i] = new Mesh.Triangle(
                    SphericalModels.StereoToEqualVolume(mesh.Mesh.Triangles[i].a),
                    SphericalModels.StereoToEqualVolume(mesh.Mesh.Triangles[i].b),
                    SphericalModels.StereoToEqualVolume(mesh.Mesh.Triangles[i].c));
            }

            STL.SaveMeshToSTL(mesh.Mesh, @"output.stl");
        }
示例#2
0
        private static void ShapewaysPolytopes()
        {
            VEF loader = new VEF();

            loader.Load(@"C:\Users\roice\Documents\projects\vZome\VefProjector\data\24cell-cellFirst.vef");

            int divisions = 25;

            Shapeways mesh = new Shapeways();

            //int count = 0;
            foreach (GraphEdge edge in loader.Edges)
            {
                Segment seg = Segment.Line(
                    loader.Vertices[edge.V1].ConvertToReal(),
                    loader.Vertices[edge.V2].ConvertToReal());
                Vector3D[] points = seg.Subdivide(divisions);

                bool shrink = true;
                ProjectAndAddS3Points(mesh, points, shrink);

                //if( count++ > 10 )
                //	break;
            }

            STL.SaveMeshToSTL(mesh.Mesh, @"D:\p4\R3\sample\out1.stl");
        }
示例#3
0
        public static Vector3D[] GeodesicPoints(Vector3D v1, Vector3D v2)
        {
            int     div = 4;
            Segment seg = Segment.Line(v1, v2);

            Vector3D[] result = seg.Subdivide(div);
            return(result);
        }
示例#4
0
        /// <summary>
        /// Inputs and Outputs are in R3 (stereographically projected).
        /// </summary>
        public static Vector3D[] GeodesicPoints(Vector3D v1, Vector3D v2)
        {
            Vector3D start = Sterographic.R3toS3(v1);
            Vector3D end   = Sterographic.R3toS3(v2);

            AvoidNorthPole(ref start, end);
            AvoidNorthPole(ref end, start);

            int div = 42;
            //int div = 56;		// 343
            //int div = 50;		// 333
            Segment seg = Segment.Line(start, end);

            Vector3D[] result = seg.Subdivide(div);
            for (int i = 0; i < result.Length; i++)
            {
                result[i].Normalize();
                result[i] = Sterographic.S3toR3(result[i]);
            }

            return(result);
        }
示例#5
0
        private static void AddEuclideanEdge(Shapeways mesh, HashSet <H3.Cell.Edge> completed, Vector3D start, Vector3D end)
        {
            H3.Cell.Edge edge = new H3.Cell.Edge(start, end);
            if (completed.Contains(edge))
            {
                return;
            }

            Shapeways tempMesh = new Shapeways();
            Segment   seg      = Segment.Line(start, end);

            int div = 20 - (int)(start.Abs() * 4);

            if (div < 1)
            {
                div = 1;
            }

            tempMesh.AddCurve(seg.Subdivide(div), .05);
            Transform(tempMesh.Mesh);

            mesh.Mesh.Triangles.AddRange(tempMesh.Mesh.Triangles);
            completed.Add(edge);
        }
示例#6
0
        private static void MeshEdges(Mesh mesh, Tile tile, HashSet <Vector3D> completed, Polygon boundary)
        {
            for (int i = 0; i < tile.Boundary.Segments.Count; i++)
            {
                Segment boundarySeg = tile.Boundary.Segments[i];
                Segment d1          = tile.Drawn.Segments[i];
                if (completed.Contains(boundarySeg.Midpoint))
                {
                    continue;
                }

                // Find the incident segment.
                Segment seg2 = null, d2 = null;
                foreach (Tile incident in tile.EdgeIncidences)
                {
                    for (int j = 0; j < incident.Boundary.Segments.Count; j++)
                    {
                        if (boundarySeg.Midpoint == incident.Boundary.Segments[j].Midpoint)
                        {
                            seg2 = incident.Boundary.Segments[j];
                            d2   = incident.Drawn.Segments[j];
                            break;
                        }
                    }

                    if (seg2 != null)
                    {
                        break;
                    }
                }

                // Found our incident edge?
                bool foundIncident = seg2 != null;
                if (!foundIncident)
                {
                    seg2 = d2 = boundarySeg;
                }

                // Do the endpoints mismatch?
                if (boundarySeg.P1 != seg2.P1)
                {
                    Segment clone = d2.Clone();
                    clone.Reverse();
                    d2 = clone;
                }

                // Add the two vertices (careful of orientation).
                if (foundIncident)
                {
                    CheckAndAdd(mesh, new Mesh.Triangle(boundarySeg.P1, d1.P1, d2.P1), boundary);
                    CheckAndAdd(mesh, new Mesh.Triangle(boundarySeg.P2, d2.P2, d1.P2), boundary);
                }

                int        num   = 1 + (int)(d1.Length * m_divisions);
                Vector3D[] list1 = d1.Subdivide(num);
                Vector3D[] list2 = d2.Subdivide(num);
                for (int j = 0; j < num; j++)
                {
                    CheckAndAdd(mesh, new Mesh.Triangle(list1[j], list1[j + 1], list2[j + 1]), boundary);
                    CheckAndAdd(mesh, new Mesh.Triangle(list2[j], list1[j], list2[j + 1]), boundary);
                }

                completed.Add(boundarySeg.Midpoint);
            }
        }