proj home

Files   Classes   Functions   Hierarchy  

simplexD2linked.h

Go to the documentation of this file.
00001 #ifndef SIMPLEXD2LINKED_H
00002 #define SIMPLEXD2LINKED_H
00003 
00004 #include <cassert>
00005 #include <iosfwd>
00006 using namespace std;
00007 
00008 #include <typedefs.h>
00009 
00010 
00011 /*
00012 \brief A doubely linked triangle data structure.
00013 
00014 This data structure has a mathematical perspective and
00015  is designed to support operations on the simplex 
00016  (triangle in 2D).
00017 
00018 Operations with Inverse appended are the reverse of the original
00019  operators.  So pi[piInverse(10)] should yield 10
00020 
00021 Winding or order of points was implied on the data structure
00022  although for most operations the operators are invariant to
00023  the order.  
00024 
00025 There are two coordinate systems - the local ones accessing
00026  the arrays pi and ni and the global coordinate system which indexes
00027  points and triangles with integers.
00028 */
00029 class simplexD2linked
00030 {
00031 public:
00032 
00034   uint pi[3];
00037   uint ni[3];
00038 
00041   uintc nifrom( uintc gpt ) const
00042     { return ni[piInverse(gpt)]; }
00043 
00045   uintc piInverse( uintc gpt ) const
00046   {
00047     assert(gpt!=0);
00048 
00049     if (pi[0]==gpt) return 0;
00050     if (pi[1]==gpt) return 1;
00051     if (pi[2]==gpt) return 2;
00052 
00053     assert(false);
00054     return 3; // Return crap.
00055   }
00057   boolc piInverseHas( uintc gpt ) const
00058   {
00059     if (pi[0]==gpt) return true;
00060     if (pi[1]==gpt) return true;
00061     if (pi[2]==gpt) return true;
00062 
00063     return false;
00064   }
00065 
00067   uintc piInverse( bool& res, uintc gpt ) const
00068   {
00069     res=true;
00070     if (pi[0]==gpt) return 0;
00071     if (pi[1]==gpt) return 1;
00072     if (pi[2]==gpt) return 2;
00073 
00074     res=false;
00075     return 3; // Return crap.
00076   }
00077 
00079   uintc niInverse( uintc neib ) const
00080   {  
00081     if (ni[0]==neib) return 0;
00082     if (ni[1]==neib) return 1;
00083     if (ni[2]==neib) return 2;
00084 
00085     assert(false);
00086     return 3; // Return crap.
00087   }  
00089   boolc niInverseHas( uintc neib ) const
00090   {  
00091     if (ni[0]==neib) return true;
00092     if (ni[1]==neib) return true;
00093     if (ni[2]==neib) return true;
00094 
00095     return false; 
00096   }  
00098   uintc niInverse( bool& res, uintc neib ) const
00099   {
00100     res=true;
00101     if (ni[0]==neib) return 0;
00102     if (ni[1]==neib) return 1;
00103     if (ni[2]==neib) return 2;
00104 
00105     res=false;
00106     return 3; // Return crap.
00107   }  
00108 
00109 
00110 
00112   simplexD2linked();
00114   simplexD2linked
00115   (
00116     uintc a, uintc b, uintc c,
00117     uintc na=0, uintc nb=0, uintc nc=0
00118   );
00120   void construct 
00121   (
00122     uintc a, uintc b, uintc c,
00123     uintc na, uintc nb, uintc nc
00124   );
00125 
00130   void getanticlockwiseface( uint & a, uint & b, uintc face) const;
00131 
00134   void getclockwiseface( uint & a, uint & b, uintc face) const;
00135 
00136   // Query Functions
00137 
00139   boolc isonboundary() const;
00140   
00141   // Is the point a vertex of this triangle?
00142   //boolc isavertex( uintc gpt ) const;
00143 
00145   void setnull();
00147   boolc isnull() const;
00148 
00149 
00150   // Supportive functions that use the basic operations.
00151 
00153   void changelink( uintc from, uintc to )
00154     { ni[ niInverse(from) ] = to; }
00155 
00156   // Common operation of getting face from opposite point.
00157   //uint * niFrompiInverse(uintc gpt);
00158     //{ return & ni[ piInverse(gpt) ]; }
00159 
00163   boolc operator == (simplexD2linked const & w) const;
00164 
00166   operator string() const;
00168   void serializeInverse(stringc & s);
00170   ostream & print(ostream& os) const;
00172   istream & serializeInverse(istream & is);
00173 };
00174 
00175 ostream & operator << (ostream& os, simplexD2linked const & x);
00176 
00177 istream & operator >> (istream & is, simplexD2linked & x);
00178 
00179 
00180 
00181 
00182 
00183 #endif
00184 
00185 

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