public static Rhino.Geometry.Mesh ConvertToRhinoMesh(List <g3.PolyLine3d> inputLines)
        {
            Rhino.Geometry.Mesh result = new Rhino.Geometry.Mesh();
            foreach (var l in inputLines)
            {
                var poly = ConvertToRhinoPolyline(l);
                var temp = Rhino.Geometry.Mesh.CreateFromClosedPolyline(poly);
                temp.Ngons.AddPlanarNgons(double.MaxValue / 10);
                result.Append(temp);
            }

            result.UnifyNormals();

            return(result);
        }
Example #2
0
        public static Mesh ToPolygonMesh(this Rhino.Geometry.Mesh mesh)
        {
            // clean up input mesh
            mesh.Vertices.CombineIdentical(true, true);
            mesh.Vertices.CullUnused();
            mesh.UnifyNormals();
            mesh.Weld(Math.PI);

            var positions = mesh
                            .TopologyVertices
                            .Select(tv => new Vec3d(tv.X, tv.Y, tv.Z))
                            .ToList();

            var faces =
                mesh
                .GetNgonAndFacesEnumerable()
                .Select(
                    ngon => ngon.BoundaryVertexIndexList().Select(Convert.ToInt32));

            return(Mesh.CreateFromPositions(positions, faces));
        }