Пример #1
0
    static public void Main()
    {
        //create points with the swig doubleArray proxy
        //http://www.swig.org/Doc3.0/SWIGDocumentation.html#Library_carrays
        doubleArray p = new doubleArray(12); //column major

        p.setitem(0, 0.0); p.setitem(3, 0.5); p.setitem(6, 0.5); p.setitem(9, 0.0);
        p.setitem(1, 0.0); p.setitem(4, 0.0); p.setitem(7, 1.0); p.setitem(10, 1.0);
        p.setitem(2, 0.0); p.setitem(5, 1.0); p.setitem(8, 0.0); p.setitem(11, 1.0);
        System.Console.WriteLine("Input points:");
        printArray(p, 4);
        SWIGTYPE_p_ShapeOpSolver s = shapeopCSharp.shapeop_create();

        shapeopCSharp.shapeop_setPoints(s, p.cast(), 4);
        double weight = 1.0;
        //add a plane constraint to all the vertices.
        intArray ids = new intArray(4);

        ids.setitem(0, 0); ids.setitem(1, 1); ids.setitem(2, 2); ids.setitem(3, 3);
        shapeopCSharp.shapeop_addPlaneConstraint(s, ids.cast(), 4, weight);
        //add a closeness constraint to the 1st vertex.
        shapeopCSharp.shapeop_addClosenessConstraint(s, 0, weight);
        //add a closeness constraint to the 4th vertex.
        shapeopCSharp.shapeop_addClosenessConstraint(s, 3, weight);
        shapeopCSharp.shapeop_init(s);
        shapeopCSharp.shapeop_solve(s, 10);
        shapeopCSharp.shapeop_getPoints(s, p.cast(), 4);
        shapeopCSharp.shapeop_delete(s);
        System.Console.WriteLine("Output points:");
        printArray(p, 4);
    }
Пример #2
0
    public static doubleArray frompointer(SWIGTYPE_p_double t)
    {
        global::System.IntPtr cPtr = IsarMaincsPINVOKE.doubleArray_frompointer(SWIGTYPE_p_double.getCPtr(t));
        doubleArray           ret  = (cPtr == global::System.IntPtr.Zero) ? null : new doubleArray(cPtr, false);

        return(ret);
    }
Пример #3
0
    // Test Driver
    public static void Main(string[] args)
    {
        // Call initialize function to set up any necessary state
        System.Console.WriteLine("Calling initialize");
        timestwocs.timestwo_initialize();

        // 2-by-3 input
        int m     = 2;
        int n     = 3;
        int numel = m * n;

        using (doubleArray input = new doubleArray(numel))        // Input data
            using (doubleArray result = new doubleArray(numel)) { // Result data
                // Data
                for (int i = 0; i < numel; i++)
                {
                    input.setitem(i, i);
                }
                System.Console.WriteLine("Initial data");
                timestwoMain.printArray(input, numel);

                // Call entry-point
                timestwocs.timestwo(input.cast(), result.cast());

                // Gather returned data
                timestwoMain.printArray(result, numel);

                // Call terminate function to perform any necessary clean up
                System.Console.WriteLine("Calling terminate");
                timestwocs.timestwo_terminate();
            }
    }
Пример #4
0
        public static doubleArray frompointer(SWIGTYPE_p_double t)
        {
            global::System.IntPtr cPtr = ompl_basePINVOKE.doubleArray_frompointer(SWIGTYPE_p_double.getCPtr(t));
            doubleArray           ret  = (cPtr == global::System.IntPtr.Zero) ? null : new doubleArray(cPtr, false);

            if (ompl_basePINVOKE.SWIGPendingException.Pending)
            {
                throw ompl_basePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Пример #5
0
 static public void printArray(doubleArray a, int n)
 {
     for (int c = 0; c < 3; c++)
     {
         for (int r = 0; r < n; r++)
         {
             Console.Write(a.getitem(r * 3 + c) + " ");
         }
         Console.WriteLine();
     }
 }
Пример #6
0
 public static void printArray(doubleArray d, int n)
 {
     if (n == 0)
     {
         System.Console.WriteLine("Empty array");
         return;
     }
     for (int i = 0; i < n - 1; i++)
     {
         System.Console.WriteLine(d.getitem(i) + ", ");
     }
     System.Console.WriteLine(d.getitem(n - 1));
 }
Пример #7
0
    // Test Driver
    public static void Main(string[] args)
    {
        // Call initialize function to set up any necessary state
        System.Console.WriteLine("Calling initialize");
        timestwocs.timestwo_initialize();

        // 2-by-3 input
        int m = 2;
        int n = 3;

        using (intArray dims = new intArray(2))                                                   // Size vector
            using (doubleArray data = new doubleArray(6))                                         // Data
                using (emxArray_real_T x = timestwocs.emxCreateWrapper_real_T(data.cast(), m, n)) // Input
                    using (emxArray_real_T y = timestwocs.emxCreate_real_T(0, 0)) {               // Output
                        // 2-by-3 input
                        dims.setitem(0, m);
                        dims.setitem(1, n);

                        // Data
                        int numel = m * n;
                        for (int i = 0; i < numel; i++)
                        {
                            data.setitem(i, i);
                        }
                        System.Console.WriteLine("Initial data");
                        timestwoMain.printArray(data, numel);
                        // Call entry-point
                        timestwocs.timestwo(x, y);

                        // Gather returned data
                        doubleArray output      = doubleArray.frompointer(y.data);
                        int         outputND    = y.numDimensions;
                        intArray    outputSize  = intArray.frompointer(y.size);
                        int         outputNumel = 1;
                        for (int dim = 0; dim < outputND; dim++)
                        {
                            outputNumel *= outputSize.getitem(dim);
                        }
                        timestwoMain.printArray(output, outputNumel);

                        // Call terminate function to perform any necessary clean up
                        System.Console.WriteLine("Calling terminate");
                        timestwocs.timestwo_terminate();

                        // No need to clean up emxArray variables as destructors are
                        // automatically called and have the call to emxDestroy_real_T
                        // injected in them
                    }
    }
Пример #8
0
        private void InternalCallback(uint number, uint inputCount, uint outputCount, global::System.IntPtr inputs, global::System.IntPtr outputs)
        {
            double[] callbackInput  = new double[inputCount];
            double[] callbackOutput = new double[outputCount];

            Callback(number, inputCount, outputCount, callbackInput, callbackOutput);

            using (doubleArray inputArray = new doubleArray(inputs, false))
                using (doubleArray outputArray = new doubleArray(outputs, false))
                {
                    for (int i = 0; i < inputCount; i++)
                    {
                        inputArray.setitem(i, callbackInput[i]);
                    }
                    for (int i = 0; i < outputCount; i++)
                    {
                        outputArray.setitem(i, callbackOutput[i]);
                    }
                }
        }
Пример #9
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(doubleArray obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }