proj home

Files   Classes   Functions   Hierarchy  

quickhull3D< PT, D > Class Template Reference

Compute the 3D convex hull of points. More...

#include <quickhull3D.h>

Inheritance diagram for quickhull3D< PT, D >:
Collaboration diagram for quickhull3D< PT, D >:

List of all members.

Public Types

typedef halfspaceD3< PT, D > HS
typedef halfspaceContainer< HS,
PT > 
HSC

Public Member Functions

 quickhull3D (vector< PT > const &pts_)
 Compute the convex hull of the point pts.
void reset ()
 Reset the algorithm.
boolc operator! () const
 Are there any more half-space containers to process?
void operator++ ()
 Process a half-space container.

Public Attributes

vector< HSC * > cs
 Stack of half spaces to be processed.
vector< PT > const & pts
 Global points.
vector< uintboundary
 Points on the hull.


Detailed Description

template<typename PT, typename D>
class quickhull3D< PT, D >

Compute the 3D convex hull of points.

O(n^2) complexity in time (worst case).

Data structure assumption: pts[0] is not used as 0 index is used to mean that there is no point.

Definition at line 28 of file quickhull3D.h.


Member Typedef Documentation

template<typename PT, typename D>
typedef halfspaceD3<PT,D> quickhull3D< PT, D >::HS

Definition at line 32 of file quickhull3D.h.

template<typename PT, typename D>
typedef halfspaceContainer<HS,PT> quickhull3D< PT, D >::HSC

Definition at line 33 of file quickhull3D.h.


Constructor & Destructor Documentation

template<typename PT, typename D >
quickhull3D< PT, D >::quickhull3D ( vector< PT > const &  pts_  )  [inline]

Compute the convex hull of the point pts.

The first element is a dummy value.

Definition at line 234 of file quickhull3D.h.

00235   : pts(pts_)
00236 {
00237 }


Member Function Documentation

template<typename PT, typename D>
boolc quickhull3D< PT, D >::operator! (  )  const [inline]

Are there any more half-space containers to process?

Definition at line 52 of file quickhull3D.h.

00053     { return cs.empty()==false; } 

template<typename PT , typename D >
void quickhull3D< PT, D >::operator++ (  )  [inline]

Process a half-space container.

Definition at line 166 of file quickhull3D.h.

References quickhull3D< PT, D >::cs.

00167 {
00168   assert(cs.size()>0);
00169 
00170   HSC* hc = cs[cs.size()-1];
00171   cs.pop_back();
00172 
00173   partition(*hc);
00174   delete hc;
00175 }

template<typename PT , typename D >
void quickhull3D< PT, D >::reset (  )  [inline]

Reset the algorithm.

Definition at line 178 of file quickhull3D.h.

References quickhull3D< PT, D >::boundary, quickhull3D< PT, D >::cs, halfspaceContainer< HS, PT >::isInsideOrOnBoundary(), and quickhull3D< PT, D >::pts.

Referenced by quickhull3Dtest::keyboard01().

00179 {
00180   boundary.clear();
00181 
00182   uintc n(pts.size());
00183   if (n<4)
00184     return;
00185 
00186   uint x0;
00187   uint x1;
00188   uint x2;
00189 
00190   findMinMax(x0,x1,x2);
00191   boundary.push_back(x0);
00192   boundary.push_back(x1);
00193   boundary.push_back(x2);
00194 
00195   assert(x0<n);
00196   assert(x1<n);
00197   assert(x2<n);
00198 
00199   list<uint> index;
00200   for (uint i=1; i<n; ++i)
00201   {
00202     if (i==x0)
00203       continue;
00204     if (i==x1)
00205       continue;
00206     if (i==x2)
00207       continue;
00208 
00209     index.push_back(i);
00210   }
00211 
00212   if (cs.empty()==false)
00213   {
00214     for ( uint i=0; i<cs.size(); ++i)
00215       { delete cs[i]; }
00216 
00217     cs.clear();
00218   } 
00219 
00220   HSC * h1 = 
00221     new HSC( HS(&pts[0],x0,x1,x2) ,pts );
00222     //new HSC( HS(pts[x0],pts[x1],pts[x2]) ,pts );
00223   h1->isInsideOrOnBoundary(index);
00224   cs.push_back(h1);
00225 
00226   HSC * h2 = 
00227     new HSC( HS(pts[x2],pts[x1],pts[x0]), pts );
00228   h2->isInsideOrOnBoundary(index);
00229   cs.push_back(h2);
00230 }


Member Data Documentation

template<typename PT, typename D>
vector< uint > quickhull3D< PT, D >::boundary

Points on the hull.

Definition at line 42 of file quickhull3D.h.

Referenced by quickhull3D< PT, D >::reset().

template<typename PT, typename D>
vector< HSC* > quickhull3D< PT, D >::cs

Stack of half spaces to be processed.

Definition at line 36 of file quickhull3D.h.

Referenced by quickhull3D< pt3, double >::operator!(), quickhull3D< PT, D >::operator++(), and quickhull3D< PT, D >::reset().

template<typename PT, typename D>
vector<PT> const& quickhull3D< PT, D >::pts

Global points.

Definition at line 39 of file quickhull3D.h.

Referenced by quickhull3D< PT, D >::reset().


The documentation for this class was generated from the following file:

Generated on Fri Mar 4 00:50:11 2011 for Chelton Evans Source by  doxygen 1.5.8