Changeset 10211 for branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers
- Timestamp:
- 12/09/13 22:42:34 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3.csproj
r10208 r10211 22 22 <ErrorReport>prompt</ErrorReport> 23 23 <WarningLevel>4</WarningLevel> 24 <AllowUnsafeBlocks>true</AllowUnsafeBlocks> 24 25 </PropertyGroup> 25 26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/QhullWrapper.cs
r10208 r10211 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 42 43 } 43 44 45 public unsafe static List<int> CalculateConvexHull(List<double[]> points) { 46 int dimension = points.First().Length; 47 int numPoints = points.Count(); 48 List<int> convexHullIndices = new List<int>(); 49 50 double[] data = new double[dimension * numPoints]; 51 for (int i = 0; i < numPoints; i++) { 52 for (int j = 0; j < dimension; j++) { 53 data[i * dimension + j] = points[i][j]; 54 } 55 } 56 57 IntPtr result = IntPtr.Zero; 58 Int32 nrOfFacets = -1; 59 Int32 retCode = 0; 60 61 result = qhull_convex_hull(dimension, numPoints, data, &retCode, &nrOfFacets); 62 if (result != IntPtr.Zero && retCode == 0) { 63 try { 64 var faces = new int[nrOfFacets * dimension]; 65 Marshal.Copy(result, faces, 0, nrOfFacets * dimension); 66 convexHullIndices.AddRange(faces.Distinct()); 67 } 68 finally { 69 qhull_free(result); 70 } 71 } 72 return convexHullIndices; 73 } 74 44 75 [System.Runtime.InteropServices.DllImportAttribute("HeuristicLab.qhull.dll", EntryPoint = "qhull_volume", CallingConvention = CallingConvention.Cdecl)] 45 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); 46 83 } 47 84 }
Note: See TracChangeset
for help on using the changeset viewer.