1 // This is gel/octree/ConvexHull.h
2 #ifndef ConvexHull_h_
3 #define ConvexHull_h_
4 //:
5 // \file
6 // \author
7 //     Geoffrey Cross, Oxford RRG, 24 May 99
8 //
9 //-----------------------------------------------------------------------------
10 
11 class ConvexHull
12 {
13  public:
14   // Constructors/Destructors--------------------------------------------------
15 
16   ConvexHull( int npoints);
17 
18   // Computations--------------------------------------------------------------
19 
20   void compute();
21 
22   // Data Access---------------------------------------------------------------
23 
24   void set_point( int n, double x, double y);
get_pointx(int n)25   double get_pointx( int n) const { return P[n][0]; }
get_pointy(int n)26   double get_pointy( int n) const { return P[n][1]; }
get_npoints()27   inline int get_npoints() const { return hullsize; }
28 
29  protected:
30   // Data Members--------------------------------------------------------------
31 
32   int numberofpoints;
33   int hullsize;
34   double points[10][2], *P[10+1];
35 
36   // Helpers-------------------------------------------------------------------
37 
38   static int cmpl(const void *a, const void *b);
39   static int cmph(const void *a, const void *b);
40   int ccw(double **P, int i, int j, int k);
41   int ch2d();
42   int make_chain(double** V, int n, int (*cmp)(const void*, const void*));
43 };
44 
45 #endif // ConvexHull_h_
46