public static IBody2 CreateSheetFromSurface(this IModeler modeler, ISurface surf, IMathPoint p0, IMathPoint p1)
        {
            var uvLow  = surf.GetClosestPointOnTs(p0.ArrayData.CastArray <double>().ToVector3());
            var uvHigh = surf.GetClosestPointOnTs(p1.ArrayData.CastArray <double>().ToVector3());

            return(modeler.CreateSheetFromSurface(surf, uvLow, uvHigh));
        }
        private static IBody2 CreateSheetFromSurface(IModeler modeler, ISurface surf, double[] uRange, double[] vRange)
        {
            var uvRange = uRange.Concat(vRange).ToArray();
            var sheet   = (IBody2)modeler.CreateSheetFromSurface(surf, uvRange);

            return(sheet);
        }
        public static IBody2 CreateSurfaceBody(this IModeler modeler, ISurface surface)
        {
            var swSurfPara = surface.Parameterization2();

            var uvrange = new double[]
            {
                swSurfPara.UMin,
                swSurfPara.UMax,
                swSurfPara.VMin,
                swSurfPara.VMax
            };

            return((IBody2)modeler.CreateSheetFromSurface(surface, uvrange));
        }
        /// <summary>
        /// Create a bounded sheet.
        /// </summary>
        /// <param name="modeler"></param>
        /// <param name="center">Center of the surface</param>
        /// <param name="vNormal">Direction of the surface</param>
        /// <param name="p0">Point to project onto surface to find UV bounds</param>
        /// <param name="p1">Point to project onto surface to find UV bounds</param>
        /// <returns></returns>
        public static IBody2 CreateSheet(this IModeler modeler, Vector3 center, Vector3 vNormal, double r)
        {
            var surf        = (Surface)modeler.CreatePlanarSurface(center.ToDoubles(), vNormal.ToDoubles());
            var mid         = surf.GetClosestPointOnTs(center);
            var midPoint    = mid.Point.ToVector3();
            var upVector    = (surf.PointAt(mid.U, mid.V + 1) - midPoint).Unit();
            var rightVector = (surf.PointAt(mid.U + 1, mid.V) - midPoint).Unit();


            var low  = midPoint - upVector * r - rightVector * r;
            var high = midPoint + upVector * r + rightVector * r;

            var uvLow  = surf.GetClosestPointOnTs(low);
            var uvHigh = surf.GetClosestPointOnTs(high);

            return(modeler.CreateSheetFromSurface(surf, uvLow, uvHigh));
        }
Example #5
0
        /// <summary>
        /// 创建球体
        /// </summary>
        /// <param name="modeler"></param>
        /// <param name="center"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public static IBody2 CreateSphereBody(this IModeler modeler, Vector3 center, double radius)
        {
            var axis    = Vector3.UnitZ;
            var refaxis = Vector3.UnitY;
            var sphere  = (ISurface)modeler.CreateSphericalSurface2(center.ToDoubles(), axis.ToDoubles(), refaxis.ToDoubles(), radius);

            var swSurfPara = sphere.Parameterization2();

            var uvrange = new double[]
            {
                swSurfPara.UMin,
                swSurfPara.UMax,
                swSurfPara.VMin,
                swSurfPara.VMax
            };


            var sphereBody = (IBody2)modeler.CreateSheetFromSurface(sphere, uvrange);

            return(sphereBody);
        }
 private static IBody2 CreateSheetFromSurface(IModeler modeler, ISurface surf, double[] uRange, double[] vRange)
 {
     var uvRange = uRange.Concat(vRange).ToArray();
     var sheet = (IBody2) modeler.CreateSheetFromSurface(surf, uvRange);
     return sheet;
 }