Ejemplo n.º 1
0
        /// <summary>Compares the Points in PtSetA with all the points in PtSetB, return the Point in PtSetA that is closest to each Point in PtSetB</summary>
        private static void ClosestPoint2Sets(CallFrame frame)
        {
            // Use the following technique to get the "native" .NET values of the given arguments.

            Point[] ptsA = frame.UnboxArgument<Point[]>(0);
            Point[] ptsB = frame.UnboxArgument<Point[]>(1);

            Point[] result = new Point[ptsB.Length];

            double dist = double.MaxValue;
            double tDist;
            DPoint3d cpt;
            int i = 0;

            foreach (Point ptB in ptsB)
            {
                cpt = ptB.DPoint3d;
                foreach(Point ptA in ptsA)
                {
                    tDist = ptA.DPoint3d.Distance(ref cpt);
                    if (tDist < dist)
                    {
                        dist = tDist;
                        result[i] = ptB;
                    }
                }

                i++;
            }

            CPU.SetFunctionResult(Boxer.Box(result));
        }
Ejemplo n.º 2
0
        /// <summary>Return the edges of a mesh as a DSegment3d array</summary>
        private static void MeshEdges(CallFrame frame)
        {
            // Use the following technique to get the "native" .NET values of the given arguments.

            Mesh mesh = frame.UnboxArgument<Mesh>(0);    // Get the first argument (i.e., the argument at index 0)
            CPU.SetFunctionResult(Boxer.Box(mesh.Edges()));
        }
Ejemplo n.º 3
0
        /// <summary>Gets all the vertices connected to a all the vertices on a mesh</summary>
        private static void MeshConnectedVertices(CallFrame frame)
        {
            // Use the following technique to get the "native" .NET values of the given arguments.

            Mesh mesh = frame.UnboxArgument<Mesh>(0);    // Get the first argument (i.e., the argument at index 0)

            int[] ConnectedVtxID;
            List<DPoint3d[]> result = new List<DPoint3d[]>(mesh.Vertices.Length);

            foreach (var vtx in mesh.Vertices)
            {
                result.Add(mesh.ConnectedVtx(vtx.DPoint3d, out ConnectedVtxID));
            }

            CPU.SetFunctionResult(Boxer.Box(result.ToArray()));
        }
Ejemplo n.º 4
0
        /// <summary>Gets all the vertices connected to a single vertex on a mesh</summary>
        private static void MeshConnectedVertex(CallFrame frame)
        {
            // Use the following technique to get the "native" .NET values of the given arguments.

            Mesh mesh = frame.UnboxArgument<Mesh>(0);    // Get the first argument (i.e., the argument at index 0)
            IPoint SearchPoint = frame.UnboxArgument<IPoint>(1);

            int[] ConnectedVtxID;

            DPoint3d[] cntVtx = mesh.ConnectedVtx(SearchPoint.DPoint3d, out ConnectedVtxID);

            CPU.SetFunctionResult(Boxer.Box(cntVtx));
        }
Ejemplo n.º 5
0
        /// <summary>Takes a list of numbers and rescales the values to be between the start and end values</summary>
        private static void ListRemap(CallFrame frame)
        {
            // Use the following technique to get the "native" .NET values of the given arguments.

            double[] list = frame.UnboxArgument<double[]>(0);
            double start = frame.UnboxArgument<double>(1);
            double end = frame.UnboxArgument<double>(2);

            // Here's the main body of our function.

            double[] result = new double[list.Length];

            double min = CerverFunctions.ListMin(list);
            double max = CerverFunctions.ListMax(list);
            double range = max - min;

            double temp;

            for (int i = 0; i < list.Length; i++)
            {
                temp = (((list[i] - min)/ range)*(end-start))+start;
                result[i] = temp;
            }

            CPU.SetFunctionResult(Boxer.Box(result));
        }
Ejemplo n.º 6
0
        /// <summary>Returns the smallest number in a list</summary>
        private static void ListMin(CallFrame frame)
        {
            double[] list = frame.UnboxArgument<double[]>(0);

            double min = CerverFunctions.ListMin(list);

            CPU.SetFunctionResult(Boxer.Box(min));
        }
Ejemplo n.º 7
0
        /// <summary>Get the closest point to a surface</summary>
        private static void closestPointOnSurf(CallFrame frame)
        {
            // Use the following technique to get the "native" .NET values of the given arguments.

            ISurface surface = frame.UnboxArgument<ISurface>(0);    // Get the first argument (i.e., the argument at index 0)
            IPoint point = frame.UnboxArgument<IPoint>(1);

            Point3d cp = new Point3d();
            Point2d uv = new Point2d();
            Point3d fromPt = new Point3d();
            fromPt.X = point.X; fromPt.Y = point.Y; fromPt.Z = point.Z;

            // Here's the main body of our function.

            Point result;
            surface.com_bsplineSurface.ComputeMinimumDistance(ref cp, ref uv, ref fromPt);
            result = new Point();

            CPU.SetFunctionResult(Boxer.Box(result));
        }