Exemplo n.º 1
0
        /***************************************************/

        public static RHG.MeshFace ToRhino(this BHG.Face rFace)
        {
            if (rFace == null)
            {
                return(default(RHG.MeshFace));
            }

            if (rFace.IsQuad())
            {
                return(new RHG.MeshFace(rFace.A, rFace.B, rFace.C, rFace.D));
            }
            else
            {
                return(new RHG.MeshFace(rFace.A, rFace.B, rFace.C));
            }
        }
Exemplo n.º 2
0
        /***************************************************/
        /**** Public Methods  - Mesh                    ****/
        /***************************************************/

        public static RHG.Mesh ToRhino(this BHG.Mesh mesh)
        {
            if (mesh == null)
            {
                return(null);
            }

            List <RHG.Point3d>  rVertices = mesh.Vertices.Select(x => x.ToRhino()).ToList();
            List <BHG.Face>     faces     = mesh.Faces;
            List <RHG.MeshFace> rFaces    = new List <RHG.MeshFace>();
            int nbVertices = rVertices.Count;

            for (int i = 0; i < faces.Count; i++)
            {
                BHG.Face face = faces[i];
                if (face.IsQuad())
                {
                    if (face.A < nbVertices && face.B < nbVertices && face.C < nbVertices && face.D < nbVertices)
                    {
                        rFaces.Add(new RHG.MeshFace(face.A, face.B, face.C, face.D));
                    }
                    else
                    {
                        Reflection.Compute.RecordWarning("Mesh face [" + face.A + ", " + face.B + ", " + face.C + ", " + face.D + "] could not be created due to corresponding vertices missing");
                    }
                }
                else
                {
                    if (face.A < nbVertices && face.B < nbVertices && face.C < nbVertices)
                    {
                        rFaces.Add(new RHG.MeshFace(face.A, face.B, face.C));
                    }
                    else
                    {
                        Reflection.Compute.RecordWarning("Mesh face [" + face.A + ", " + face.B + ", " + face.C + "] could not be created due to corresponding vertices missing");
                    }
                }
            }
            RHG.Mesh rMesh = new RHG.Mesh();
            rMesh.Faces.AddFaces(rFaces);
            rMesh.Vertices.AddVertices(rVertices);
            return(rMesh);
        }