Files Classes Functions Hierarchy
00001 #ifndef PARTITIONEQU_H 00002 #define PARTITIONEQU_H 00003 00004 #include <typedefs.h> 00005 #include <partitionspace.h> 00006 00007 00008 00009 template< typename P, typename Q > 00010 class partitionequmult; 00011 00012 template< typename Q > 00013 class partitionequnot; 00014 00018 template< typename P, typename Q > 00019 class partitionequadd 00020 { 00021 public: 00022 00024 P left; 00026 Q right; 00027 00029 partitionequadd 00030 ( 00031 P const & _left, 00032 Q const & _right 00033 ) 00034 : left(_left), right(_right) {} 00035 00037 template< typename W > 00038 partitionequmult< partitionequadd<P,Q>, W > operator * ( W const & x ) 00039 { return partitionequmult< partitionequadd<P,Q>, W >(*this,x); } 00040 00042 template< typename W > 00043 partitionequadd< partitionequadd<P,Q>, W > operator + ( W const & x ) 00044 { return partitionequadd< partitionequadd<P,Q>, W >(*this,x); } 00045 00047 partitionequnot< partitionequadd<P,Q> > operator ! () 00048 { return partitionequnot< partitionequadd<P,Q> >(*this); } 00049 00051 template< typename W > 00052 partitionequmult< partitionequadd<P,Q>, partitionequnot<W> > operator - ( W const & x ) 00053 { return partitionequmult< partitionequadd<P,Q>, partitionequnot<W> >(*this,partitionequnot<W>(x)); } 00054 00056 template< typename T > 00057 boolc isInside( T const & x ) const 00058 { 00059 if (left.isInside(x)==true) 00060 return true; 00061 00062 return right.isInside(x); 00063 } 00064 00065 }; 00066 00067 00071 template< typename P, typename Q > 00072 class partitionequmult 00073 { 00074 public: 00075 00077 P left; 00079 Q right; 00080 00082 partitionequmult 00083 ( 00084 P const & _left, 00085 Q const & _right 00086 ) 00087 : left(_left), right(_right) {} 00088 00090 template< typename W > 00091 partitionequmult< partitionequmult<P,Q>, W > operator * ( W const & x ) 00092 { return partitionequmult< partitionequmult<P,Q>, W >(*this,x); } 00093 00095 template< typename W > 00096 partitionequadd< partitionequmult<P,Q>, W > operator + ( W const & x ) 00097 { return partitionequadd< partitionequmult<P,Q>, W >(*this,x); } 00098 00100 partitionequnot< partitionequmult<P,Q> > operator ! () 00101 { return partitionequnot< partitionequmult<P,Q> >(*this); } 00102 00104 template< typename W > 00105 partitionequmult< partitionequmult<P,Q>, partitionequnot<W> > operator - ( W const & x ) 00106 { return partitionequmult< partitionequmult<P,Q>, partitionequnot<W> >(*this,partitionequnot<W>(x)); } 00107 00109 template< typename T > 00110 boolc isInside( T const & x ) const 00111 { 00112 if (left.isInside(x)==false) 00113 return false; 00114 00115 return right.isInside(x); 00116 } 00117 00118 }; 00119 00123 template< typename Q > 00124 class partitionequnot 00125 { 00126 public: 00128 Q right; 00129 00131 partitionequnot( Q const & _right ) 00132 : right(_right) {} 00133 00135 template< typename W > 00136 partitionequadd< partitionequnot<Q>, W > operator + ( W const & x ) 00137 { return partitionequadd< partitionequnot<Q>, W >(*this,x); } 00138 00140 template< typename W > 00141 partitionequmult< partitionequnot<Q>, W > operator * ( W const & x ) 00142 { return partitionequmult< partitionequnot<Q>, W >(*this,x); } 00143 00145 partitionequnot< partitionequnot<Q> > operator ! () 00146 { return partitionequnot< partitionequnot<Q> >(*this); } 00147 00149 template< typename W > 00150 partitionequmult< partitionequnot<Q>, partitionequnot<W> > operator - ( W const & x ) 00151 { return partitionequmult< partitionequnot<Q>, partitionequnot<W> >(*this,partitionequnot<W>(x)); } 00152 00154 template< typename T > 00155 boolc isInside( T const & x ) const 00156 { return ! right.isInside(x); } 00157 00158 }; 00159 00160 00161 00162 /* 00163 \brief Provide a base type and forward equation compilation to other classes. 00164 00165 Use Peq to convert to partitiondata. 00166 00167 \par Example 00168 \verbatim 00169 d2halfspace< pt2, double > L[4]; 00170 00171 L[0].set( pt2(0.4,0.8), pt2(0.3,0.3) ); 00172 L[1].set( pt2(0.3,0.3), pt2(0.7,0.2) ); 00173 L[2].set( pt2(0.7,0.2), pt2(0.4,0.5) ); 00174 L[3].set( pt2(0.4,0.5), pt2(0.4,0.8) ); 00175 00176 PeqCapture(ps,Peq(L[0])*Peq(L[1])*(Peq(L[2])+Peq(L[3]))); 00177 \endverbatim 00178 */ 00179 template< typename T > 00180 class partitiondata 00181 { 00182 public: 00183 00185 partitionspace<T> * data; 00186 00188 boolc isInside( T const & x ) const 00189 { return data->isInside(x); } 00190 00192 template< typename W > 00193 partitionequadd< partitiondata<T>, W > operator + ( W const & x ) 00194 { return partitionequadd< partitiondata<T>, W >(*this,x); } 00195 00197 template< typename W > 00198 partitionequmult< partitiondata<T>, W > operator * ( W const & x ) 00199 { return partitionequmult< partitiondata<T>, W >(*this,x); } 00200 00202 partitionequnot< partitiondata<T> > operator ! () 00203 { return partitionequnot< partitiondata<T> >(*this); } 00204 00206 template< typename W > 00207 partitionequmult< partitiondata<T>, partitionequnot<W> > operator - ( W const & x ) 00208 { return partitionequmult< partitiondata<T>, partitionequnot<W> >(*this,partitionequnot<W>(x)); } 00209 00211 partitiondata(partitionspace<T> * _data) 00212 : data(_data) {} 00213 }; 00214 00216 template< typename T > 00217 partitiondata<T> Peq(partitionspace<T> & p) 00218 { return partitiondata<T>(&p); } 00219 00220 00224 template< typename FN, typename T > 00225 class partitionF : public partitionspace<T> 00226 { 00228 FN fn; 00229 public: 00230 00232 partitionF(FN _fn) 00233 : fn(_fn) {} 00234 00236 boolc isInside(T const & w) const 00237 { return fn.isInside(w); } 00238 }; 00239 00241 template< typename FN, typename T > 00242 void PeqCapture( partitionspace<T>* & p, FN const & fn ) 00243 { p = new partitionF<FN,T>(fn); } 00244 00245 00246 00247 00248 #endif 00249 00250
1.5.8