示例#1
0
        /***************************************************/

        public static RHG.GeometryBase ToRhino(this BHG.NurbsSurface surface)
        {
            if (surface == null)
            {
                return(null);
            }

            List <int> uvCount = surface.UVCount();

            RHG.NurbsSurface rhSurface = RHG.NurbsSurface.Create(3, true, surface.UDegree + 1, surface.VDegree + 1, uvCount[0], uvCount[1]);
            for (int i = 0; i < rhSurface.KnotsU.Count; i++)
            {
                rhSurface.KnotsU[i] = surface.UKnots[i];
            }
            for (int i = 0; i < rhSurface.KnotsV.Count; i++)
            {
                rhSurface.KnotsV[i] = surface.VKnots[i];
            }
            for (int i = 0; i < uvCount[0]; i++)
            {
                for (int j = 0; j < uvCount[1]; j++)
                {
                    rhSurface.Points.SetControlPoint(i, j, new RHG.ControlPoint(surface.ControlPoints[j + (uvCount[1] * i)].ToRhino(), surface.Weights[j + (uvCount[1] * i)]));
                }
            }

            if (!rhSurface.IsValid)
            {
                return(null);
            }

            if (surface.OuterTrims.Count == 0 && surface.InnerTrims.Count == 0)
            {
                return(rhSurface);
            }
            else
            {
                RHG.Brep     brep = new RHG.Brep();
                int          srf  = brep.AddSurface(rhSurface);
                RHG.BrepFace face = brep.Faces.Add(srf);

                foreach (BHG.SurfaceTrim trim in surface.OuterTrims)
                {
                    brep.AddBrepTrim(face, trim, RHG.BrepLoopType.Outer);
                }

                foreach (BHG.SurfaceTrim trim in surface.InnerTrims)
                {
                    brep.AddBrepTrim(face, trim, RHG.BrepLoopType.Inner);
                }

                return(brep.IsValid ? brep : null);
            }
        }
示例#2
0
        /***************************************************/

        public static RHG.Brep ToRhino(this List <BHG.ISurface> surfaces)
        {
            RHG.Brep brep = new RHG.Brep();

            for (int i = 0; i < surfaces.Count; i++)
            {
                RHG.GeometryBase geo = surfaces[i].IToRhino();
                if (geo is RHG.Surface)
                {
                    brep.AddSurface((RHG.Surface)geo);
                }
                else if (geo is RHG.Brep)
                {
                    brep.Append((RHG.Brep)geo);
                }
            }
            brep.JoinNakedEdges(BHG.Tolerance.Distance);

            return(brep);
        }