Esempio n. 1
0
        public IMesh Triangulated()
        {
            // test whether the mesh contains triangles only
            if (!ContainsQuads)
            {
                return(this);
            }

            var nmesh = new Rhino.Geometry.Mesh();

            nmesh.CopyFrom(mesh);
            for (int face_ind = 0; face_ind < nmesh.Faces.Count; ++face_ind)
            {
                var face = nmesh.Faces[face_ind];
                if (face.IsQuad)
                {
                    var l_ac = nmesh.Vertices[face.A].DistanceTo(nmesh.Vertices[face.C]);
                    var l_bd = nmesh.Vertices[face.B].DistanceTo(nmesh.Vertices[face.D]);
                    Rhino.Geometry.MeshFace face1, face2;
                    if (l_ac < l_bd)
                    {
                        face1 = new Rhino.Geometry.MeshFace(face.A, face.B, face.C);
                        face2 = new Rhino.Geometry.MeshFace(face.A, face.C, face.D);
                    }
                    else
                    {
                        face1 = new Rhino.Geometry.MeshFace(face.A, face.B, face.D);
                        face2 = new Rhino.Geometry.MeshFace(face.B, face.C, face.D);
                    }
                    nmesh.Faces.SetFace(face_ind, face1);
                    nmesh.Faces.AddFace(face2);
                }
            }
            return(new RhinoMesh(nmesh));
        }
Esempio n. 2
0
        public IMesh Copy()
        {
            // Create copy of rhino mesh.
            var nmesh = new Rhino.Geometry.Mesh();

            nmesh.CopyFrom(mesh);
            return(new RhinoMesh(nmesh));
        }