Files Classes Functions Hierarchy
00001 #ifndef D4TRI_H 00002 #define D4TRI_H 00003 00004 #include <cassert> 00005 #include <iosfwd> 00006 using namespace std; 00007 00008 #include <typedefs.h> 00009 00013 class d4tri 00014 { 00015 public: 00016 00017 // Indexes to points or verticies. 00018 uint pi[4]; 00019 // Indexes to neighboring tetrahedrons. 00020 uint ni[4]; 00021 // Get the local point index. 00022 uintc piInverse( uintc gpt ) const 00023 { 00024 assert(gpt!=0); 00025 00026 if (pi[0]==gpt) return 0; 00027 if (pi[1]==gpt) return 1; 00028 if (pi[2]==gpt) return 2; 00029 if (pi[3]==gpt) return 3; 00030 00031 assert(false); 00032 return 4; // Return crap. 00033 } 00034 uintc piInverse( bool& res, uintc neib ) const; 00035 // Get the local neighbour index. 00036 uintc niInverse( uintc neib ) const 00037 { 00038 if (ni[0]==neib) return 0; 00039 if (ni[1]==neib) return 1; 00040 if (ni[2]==neib) return 2; 00041 if (ni[3]==neib) return 3; 00042 00043 assert(false); 00044 return 4; // Return crap. 00045 } 00046 uintc niInverse( bool& res, uintc neib ) const; 00047 00048 00049 00050 00051 00052 00053 // Default Constructor: all fields set to 0. 00054 d4tri(); 00055 // Construct a tetrahedron. 00056 d4tri 00057 ( 00058 uintc a, uintc b, uintc c, uintc d, 00059 uintc na=0, uintc nb=0, uintc nc=0, uintc nd=0 00060 ); 00061 // Construct this tetrahedron. 00062 void construct 00063 ( 00064 uintc a, uintc b, uintc c, uintc d, 00065 uintc na, uintc nb, uintc nc, uintc nd 00066 ); 00067 00068 // Returns anticlockwise triangle point indexes 00069 // a,b,c are indexes from {0,1,2,3} 00070 void getanticlockwiseface( uint & a, uint & b, uint & c, uintc face) const; 00071 00072 // Returns clockwise triangle point indexes 00073 // a,b,c are indexes from {0,1,2,3} 00074 void getclockwiseface( uint & a, uint & b, uint & c, uintc face) const; 00075 00076 // Query Functions 00077 00078 // Is the tetrahedron part of the surface? 00079 boolc isonboundary() const; 00080 00081 // Is the point a vertex of this tetrahedron? 00082 boolc isavertex( uintc gpt ) const; 00083 00084 // Set all pointers to 0. 00085 void setnull(); 00086 // Is this a tetrahedron? Are all the fields set to zero? 00087 boolc isnull() const; 00088 00089 // Compare their points 00090 boolc hassamepoints(d4tri const & w) const; 00091 00092 // Supportive functions that use the basic operations. 00093 00094 // Modifiy a neighboring pointer. 00095 void niReset( uintc from, uintc to ) 00096 { ni[ niInverse(from) ] = to; } 00097 00098 // Common operation of getting face from opposite point. 00099 uint & niFrompiInverse(uintc gpt) 00100 { return ni[ piInverse(gpt) ]; } 00101 00102 // Possibly remove this function. 00103 // a,b,c each have a value from { 0,1,2,3 }. 00104 // find x which has the last remaining value. 00105 // void solvex(uint & x, uintc a, uintc b, uintc c) const; 00106 00107 ostream & print(ostream& os) const; 00108 private: 00109 00110 // As a quick check to compare if two tets have the same points. 00111 uintc sumofpoints() const; 00112 }; 00113 00114 ostream & operator << (ostream& os, d4tri const & x); 00115 00116 // The Tetrahedron Data Structure 00117 // 00118 // The tetrahedrons are doubly linked with each other. 00119 // 00120 // This class indexes into point and neighbor 00121 // vectors with integers. 00122 // 00123 // Support for constructing, querying and using the 00124 // data structure is given. 00125 // 00126 // The perspective is that of the tetrahedron, 00127 // not the verticies or points, so algorithms 00128 // using this data structure can be clearer. 00129 00130 // 00131 // The points are anticlockwise with the 4th point 00132 // comming out of the page. 00133 // 00134 // pi[2] 00135 // 00136 // 00137 // pi[0] pi[1] 00138 // 00139 // 00140 // The neibors are defined opposite to the 00141 // points. The neibors are the faces and point 00142 // to other tetrahedrons. 00143 // 00144 // eg ni[0] is pointing to the tetrahedron connected 00145 // to the opposite face of point pi[0], 0 indicates no 00146 // neibor. 00147 // 00148 00149 00150 #endif 00151 00152
1.5.8