proj home

Files   Classes   Functions   Hierarchy  

convexregionsD2< PT, PD > Class Template Reference

Construct regions by cutting specified regions with a 2D half spaces. More...

#include <convexregionsD2.h>

Collaboration diagram for convexregionsD2< PT, PD >:

List of all members.

Public Member Functions

 convexregionsD2 (vector< PT > &pts_)
 Pass in the global points.
boolc split (uintc k, halfspaceD2< PT, PD > const &h)
 Split the region with the half space.

Public Attributes

vector< PT > & pts
 List of points.
vector< polytopeD2linkedvi
 Linked region that are convex.

Static Public Attributes

static bool splittouchesface = false
 When split fails if the half space touches a line segment this flag is set.
static bool splittouchespoint = false
 When split fails if the half space touches a one point this flag is set.
static uint splittouchesindex = 0
 If the split touches this index is the first index position.


Detailed Description

template<typename PT, typename PD>
class convexregionsD2< PT, PD >

Construct regions by cutting specified regions with a 2D half spaces.

The region is assumed to be convex.

Definition at line 20 of file convexregionsD2.h.


Constructor & Destructor Documentation

template<typename PT , typename PD >
convexregionsD2< PT, PD >::convexregionsD2 ( vector< PT > &  pts_  )  [inline]

Pass in the global points.

Definition at line 58 of file convexregionsD2.h.

References convexregionsD2< PT, PD >::pts, and convexregionsD2< PT, PD >::vi.

00059   : pts(pts_) 
00060 {
00061   vi.push_back( polytopeD2linked() );
00062   assert(pts.size()>0);
00063 }


Member Function Documentation

template<typename PT , typename PD >
boolc convexregionsD2< PT, PD >::split ( uintc  k,
halfspaceD2< PT, PD > const &  h 
) [inline]

Split the region with the half space.

Definition at line 68 of file convexregionsD2.h.

References partitionspace< PT >::classify().

00072 {
00073   assert(k<vi.size());
00074 
00075   polytopeD2linked & x(vi[k]);
00076 
00077   uintc sz = x.pi.size();
00078   assert(sz>1);
00079 
00080   uint ci[sz];
00081 
00082   PT *beg = & x.pi[0]; 
00083   h.classify(ci,beg,beg+sz);
00084 
00085   // The two cutting positions
00086   uint cut[2];
00087 
00088   // Problem with templates so cut and paste the type.
00089   enum { undefined, below, on, above };
00090 
00091 //  cut[0] = undefined;
00092 //  cut[1] = undefined;
00093 
00094   uint index = 0;
00095   uint i2;
00096 
00097   for (uint i=0; i<sz; ++i)
00098   {
00099     if (ci[i]==on)
00100     {
00101       cut[index] = i;
00102       ++index;
00103       if (index==2)
00104         i=sz;
00105       continue;
00106     }
00107 
00108     i2 = (i+1)%sz;
00109     if (ci[i]==above)
00110     {
00111       if (ci[i2]==below)
00112       {
00113         cut[index] = i;
00114         ++index;
00115         if (index==2)
00116           i=sz;
00117         continue;
00118       } 
00119     }
00120   }
00121 
00122   // There should be two cuts.
00123   if (index==0)
00124     return false;
00125 
00126   if (index==1)
00127   {
00128     splittouchesface=false;
00129     splittouchespoint=true;
00130     splittouchesindex = cut[0];
00131     return false;
00132   }
00133 
00134   //uint a;
00135   uint status=0;
00136   if(cut[0]==on)
00137     status += 1;
00138   if(cut[1]==on)
00139     status += 2;
00140 
00141   switch (status)
00142   {
00143     // Two new points to be created.
00144     case 0:
00145       break;
00146 
00147     // First on, second to be made.
00148     case 1:
00149       break;
00150 
00151     // Second on, first to be made.
00152     case 2:
00153       break;
00154 
00155     // No new points to be created.
00156     case 3:
00157       // Handle line cutting face by rejection.
00158       if (cut[1] == (cut[0]+1)%sz)
00159       {
00160         splittouchesface = true;
00161         splittouchespoint = false;
00162         splittouchesindex = cut[0];
00163         return false;
00164       }
00165       if (cut[0] == (cut[1]+1)%sz)
00166       {
00167         splittouchesface = true;
00168         splittouchespoint = false;
00169         splittouchesindex = cut[1];
00170         return false;
00171       }
00172       break;
00173   }
00174 
00175 
00176   return true;
00177 }


Member Data Documentation

template<typename PT , typename PD >
vector< PT >& convexregionsD2< PT, PD >::pts

List of points.

Definition at line 25 of file convexregionsD2.h.

Referenced by convexregionsD2< PT, PD >::convexregionsD2().

template<typename PT , typename PD >
bool convexregionsD2< PT, PD >::splittouchesface = false [inline, static]

When split fails if the half space touches a line segment this flag is set.

Definition at line 37 of file convexregionsD2.h.

template<typename PT , typename PD >
uint convexregionsD2< PT, PD >::splittouchesindex = 0 [inline, static]

If the split touches this index is the first index position.

Definition at line 43 of file convexregionsD2.h.

template<typename PT , typename PD >
bool convexregionsD2< PT, PD >::splittouchespoint = false [inline, static]

When split fails if the half space touches a one point this flag is set.

Definition at line 40 of file convexregionsD2.h.

template<typename PT , typename PD >
vector< polytopeD2linked > convexregionsD2< PT, PD >::vi

Linked region that are convex.

Definition at line 27 of file convexregionsD2.h.

Referenced by convexregionsD2< PT, PD >::convexregionsD2().


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

Generated on Fri Mar 4 00:49:52 2011 for Chelton Evans Source by  doxygen 1.5.8