Files Classes Functions Hierarchy
00001 #ifndef PARTITIONSPACE_H 00002 #define PARTITIONSPACE_H 00003 00004 #include <cassert> 00005 using namespace std; 00006 00007 #include <typedefs.h> 00008 00026 template< typename PT > 00027 class partitionspace 00028 { 00029 public: 00030 00032 virtual boolc isInside(PT const & x) const = 0; 00033 00037 virtual boolc intersection 00038 ( 00039 PT & x, 00040 PT const & poutside, 00041 PT const & pinside 00042 ) const 00043 { assert(false); return false; } 00044 00046 virtual boolc isOnBoundary(PT const & w) const 00047 { assert(false); return false; } 00048 00050 virtual ~partitionspace() {} 00051 00052 enum ptclassification { undefined, below, on, above }; 00054 ptclassification classify(PT const & w) const 00055 { 00056 if (this->isOnBoundary(w)) 00057 return on; 00058 00059 if (this->isInside(w)) 00060 return above; 00061 00062 return below; 00063 } 00065 static stringc classifystring(ptclassification c) 00066 { 00067 string s; 00068 switch (c) 00069 { 00070 case undefined: s="undefined"; break; 00071 case below: s="below"; break; 00072 case on: s="on"; break; 00073 case above: s="above"; break; 00074 } 00075 00076 return s; 00077 } 00078 00080 void classify 00081 ( 00082 ptclassification* vc, 00083 PT const* beg, 00084 PT const* end 00085 ) const; 00086 00087 }; 00088 00089 //--------------------------------------------------------- 00090 // Implementation 00091 00092 template< typename PT > 00093 void partitionspace<PT>::classify 00094 ( 00095 ptclassification* vc, 00096 PT const* beg, 00097 PT const* end 00098 ) const 00099 { 00100 PT const* i(beg); 00101 for (; i!=end; ++i) 00102 { 00103 *vc = classify(*i); 00104 ++vc; 00105 } 00106 } 00107 00108 00109 #endif 00110 00111
1.5.8