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

        public static BoundingBox Calculate4(NurbCurve curve)
        {
            List <Point> pts = curve.ControlPoints;

            return(new BoundingBox(
                       pts.Aggregate((a, b) => new Point(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z))),
                       pts.Aggregate((a, b) => new Point(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Max(a.Z, b.Z)))
                       ));
        }
Exemplo n.º 2
0
        /***************************************************/

        public static BoundingBox Calculate3(NurbCurve curve)
        {
            List <Point> pts = curve.ControlPoints;

            return(new BoundingBox(
                       new Point(pts.Min(pt => pt.X), pts.Min(pt => pt.Y), pts.Min(pt => pt.Z)),
                       new Point(pts.Max(pt => pt.X), pts.Max(pt => pt.Y), pts.Max(pt => pt.Z))
                       ));
        }
Exemplo n.º 3
0
        /***************************************************/
        /****  Speed Test Alternatives (all worse)      ****/
        /***************************************************/

        public static BoundingBox Calculate2(NurbCurve curve)
        {
            Point min = curve.ControlPoints[0];
            Point max = curve.ControlPoints[0];

            for (int i = curve.ControlPoints.Count - 1; i > 0; i--)
            {
                Point pt = curve.ControlPoints[i];
                min.X = Math.Min(min.X, pt.X);
                min.Y = Math.Min(min.Y, pt.Y);
                min.Z = Math.Min(min.Z, pt.Z);
                max.X = Math.Max(max.X, pt.X);
                max.Y = Math.Max(max.Y, pt.Y);
                max.Z = Math.Max(max.Z, pt.Z);
            }

            return(new BoundingBox(min, max));
        }
Exemplo n.º 4
0
        /***************************************************/

        static void ChangeCurveLength(int nbPts)
        {
            Random rnd = new Random();

            List <Point> points = new List <Point>();

            for (int i = 0; i < nbPts; i++)
            {
                points.Add(new Point(rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble()));
            }

            newControlPoints = points;
            newNurbsCurve    = new NurbCurve(points);
            newNurbsCurveB   = new NurbCurveB(points);

            oldControlPoints = points.Select(pt => new BHG.Point(pt.X, pt.Y, pt.Z)).ToList();
            oldNurbsWeights  = newNurbsCurve.Weights.ToArray();
            oldNurbsKnots    = newNurbsCurve.Knots.ToArray();
            oldNurbsCurve    = new BHG.NurbCurve(oldControlPoints, 3, oldNurbsKnots, oldNurbsWeights);
        }
Exemplo n.º 5
0
        /***************************************************/

        public static BoundingBox Calculate(NurbCurve curve)
        {
            Point  pt   = curve.ControlPoints[0];
            double minX = pt.X;
            double minY = pt.Y;
            double minZ = pt.Z;
            double maxX = minX;
            double maxY = minY;
            double maxZ = minZ;

            for (int i = curve.ControlPoints.Count - 1; i > 0; i--)
            {
                pt = curve.ControlPoints[i];
                if (pt.X < minX)
                {
                    minX = pt.X;
                }
                if (pt.Y < minY)
                {
                    minY = pt.Y;
                }
                if (pt.Z < minZ)
                {
                    minZ = pt.Z;
                }
                if (pt.X > maxX)
                {
                    maxX = pt.X;
                }
                if (pt.Y > maxY)
                {
                    maxY = pt.Y;
                }
                if (pt.Z > maxZ)
                {
                    maxZ = pt.Z;
                }
            }

            return(new BoundingBox(new Point(minX, minY, minZ), new Point(maxX, maxY, maxZ)));
        }