Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/11/13 23:36:52 (10 years ago)
Author:
ascheibe
Message:

#1886

  • improved qhull wrapper
  • cleaned up unit tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/QhullWrapper.cs

    r10211 r10222  
    2727namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
    2828  public static class QhullWrapper {
     29    [System.Runtime.InteropServices.DllImportAttribute("HeuristicLab.qhull.dll", EntryPoint = "qhull_volume", CallingConvention = CallingConvention.Cdecl)]
     30    public static extern double qhull_volume(int dim, int numpoints, [In]double[] data);
     31
     32    [System.Runtime.InteropServices.DllImportAttribute("HeuristicLab.qhull.dll", EntryPoint = "qhull_convex_hull", CallingConvention = CallingConvention.Cdecl)]
     33    public unsafe static extern IntPtr qhull_convex_hull(int dim, int numpoints, [In]double[] data, [Out] Int32* retCode, [Out] Int32* nrOfFacets);
     34
     35    [System.Runtime.InteropServices.DllImportAttribute("HeuristicLab.qhull.dll", EntryPoint = "qhull_free", CallingConvention = CallingConvention.Cdecl)]
     36    public static extern void qhull_free(IntPtr data);
     37
    2938    public static double CalculateVolume(List<double[]> points) {
    3039      double result = 0.0;
     
    4352    }
    4453
    45     public unsafe static List<int> CalculateConvexHull(List<double[]> points) {
     54    public unsafe static List<int> CalculateConvexHullIndices(List<double[]> points) {
    4655      int dimension = points.First().Length;
    4756      int numPoints = points.Count();
     
    7382    }
    7483
    75     [System.Runtime.InteropServices.DllImportAttribute("HeuristicLab.qhull.dll", EntryPoint = "qhull_volume", CallingConvention = CallingConvention.Cdecl)]
    76     public static extern double qhull_volume(int dim, int numpoints, [In]double[] data);
    77 
    78     [System.Runtime.InteropServices.DllImportAttribute("HeuristicLab.qhull.dll", EntryPoint = "qhull_convex_hull", CallingConvention = CallingConvention.Cdecl)]
    79     public unsafe static extern IntPtr qhull_convex_hull(int dim, int numpoints, [In]double[] data, [Out] Int32* retCode, [Out] Int32* nrOfFacets);
    80 
    81     [System.Runtime.InteropServices.DllImportAttribute("HeuristicLab.qhull.dll", EntryPoint = "qhull_free", CallingConvention = CallingConvention.Cdecl)]
    82     public static extern void qhull_free(IntPtr data);
     84    public static List<double[]> Calculate(List<double[]> points) {
     85      var ret = new List<double[]>();
     86      List<int> indices = CalculateConvexHullIndices(points);
     87      foreach (var d in indices) {
     88        ret.Add(points[d]);
     89      }
     90      return ret;
     91    }
    8392  }
    8493}
Note: See TracChangeset for help on using the changeset viewer.