Example #1
0
    public static MVPRetCode query_mvptree(ref MVPFile m, ref DP query, int knearest,
                                           float radius, float thresh, ref DP[] results, ref int count)
    {
        IntPtr[]   points = new IntPtr[results.Length];
        MVPRetCode ret    = ph_query_mvptree(ref m, ref query, knearest, radius, thresh, points,
                                             ref count);
        int i = 0;

        foreach (IntPtr ptr in points)
        {
            DP dp = (DP)Marshal.PtrToStructure(ptr, typeof(DP));
            results[i++] = dp;
            free(ptr);
        }
        return(ret);
    }
Example #2
0
    public static MVPRetCode save_mvptree(ref MVPFile m, DP[] points)
    {
        IntPtr[] datapoints = new IntPtr[points.Length];
        int      size       = Marshal.SizeOf(typeof(DP));
        int      i          = 0;

        foreach (DP dp in points)
        {
            IntPtr ptr = Marshal.AllocHGlobal(size);
            Marshal.StructureToPtr(dp, ptr, false);
            datapoints[i++] = ptr;
        }
        MVPRetCode ret = ph_save_mvptree(ref m, datapoints, datapoints.Length);

        for (i = 0; i < datapoints.Length; ++i)
        {
            Marshal.FreeHGlobal(datapoints[i]);
        }

        return(ret);
    }