00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifndef MLN_CORE_SITE_SET_P_FACES_HH
00027 # define MLN_CORE_SITE_SET_P_FACES_HH
00028 
00033 
00034 # include <mln/core/internal/site_set_base.hh>
00035 
00036 # include <mln/topo/complex.hh>
00037 
00038 # include <mln/core/faces_psite.hh>
00039 
00040 
00041 # if 0
00042 #  include <mln/core/site_set/p_faces_piter.hh>
00043 # endif
00044 
00045 # include <mln/core/site_set/p_complex.hh>
00046 
00047 
00048 namespace mln
00049 {
00050 
00051   
00052   template <unsigned N, unsigned D, typename P> class p_faces;
00053 
00054   template <unsigned N, unsigned D, typename P> class p_faces_fwd_piter_;
00055   template <unsigned N, unsigned D, typename P> class p_faces_bkd_piter_;
00056 
00057 
00058   namespace trait
00059   {
00060     template <unsigned N, unsigned D, typename P>
00061     struct site_set_< p_faces<N, D, P> >
00062     {
00063       typedef trait::site_set::nsites::known   nsites;
00064       
00065       typedef trait::site_set::bbox::unknown   bbox;
00066       typedef trait::site_set::contents::fixed contents;
00067       typedef trait::site_set::arity::unique   arity;
00068     };
00069   } 
00070 
00071 
00076   template <unsigned N, unsigned D, typename P>
00077   struct p_faces
00078     : public internal::site_set_base_< faces_psite<N, D, P>,
00079                                        p_faces<N, D, P> >
00080   {
00081     typedef p_faces<N, D, P> self_;
00082     typedef internal::site_set_base_< faces_psite<N, D, P>, self_ > super_;
00083 
00087     p_faces(const topo::complex<D>& cplx);
00088 
00094     p_faces(const p_complex<D, P>& pc);
00095 
00099     typedef mln_site(super_) element;
00100 
00102     typedef faces_psite<N, D, P> psite;
00103 
00104     
00106     typedef p_faces_fwd_piter_<N, D, P> fwd_piter;
00107 
00108     
00110     typedef p_faces_bkd_piter_<N, D, P> bkd_piter;
00111 
00113     typedef fwd_piter piter;
00115 
00122     unsigned nsites() const;
00123 
00125     unsigned nfaces() const;
00126 
00127     
00129     bool is_valid() const;
00130 
00131     bool has(const psite& p) const;
00132 
00133     
00134     std::size_t memory_size() const;
00135 
00140     
00141 
00142     topo::complex<D>& cplx() const;
00145     topo::complex<D>& cplx();
00147 
00148   private:
00150     
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162     mutable topo::complex<D> cplx_;
00163   };
00164 
00165 
00170   template <unsigned N, unsigned D, typename P>
00171   bool
00172   operator==(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>& rhs);
00173 
00182   template <unsigned N, unsigned D, typename P>
00183   bool
00184   operator<=(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>& rhs);
00185 
00186 
00187 
00188 # ifndef MLN_INCLUDE_ONLY
00189 
00190   template <unsigned N, unsigned D, typename P>
00191   inline
00192   p_faces<N, D, P>::p_faces(const topo::complex<D>& cplx)
00193     : cplx_(cplx)
00194   {
00195     
00196     metal::bool_< N <= D >::check();
00197   }
00198 
00199   template <unsigned N, unsigned D, typename P>
00200   inline
00201   p_faces<N, D, P>::p_faces(const p_complex<D, P>& pc)
00202     : cplx_(pc.cplx())
00203   {
00204     
00205     metal::bool_< N <= D >::check();
00206   }
00207 
00208   template <unsigned N, unsigned D, typename P>
00209   inline
00210   unsigned
00211   p_faces<N, D, P>::nsites() const
00212   {
00213     return nfaces();
00214   }
00215 
00216   template <unsigned N, unsigned D, typename P>
00217   inline
00218   unsigned
00219   p_faces<N, D, P>::nfaces() const
00220   {
00221     return cplx_.template nfaces_of_static_dim<N>();
00222   }
00223 
00224   template <unsigned N, unsigned D, typename P>
00225   inline
00226   bool
00227   p_faces<N, D, P>::is_valid() const
00228   {
00229     return true;
00230   }
00231 
00232   template <unsigned N, unsigned D, typename P>
00233   inline
00234   bool
00235   p_faces<N, D, P>::has(const psite& p) const
00236   {
00237     mln_precondition(is_valid());
00238     return
00239       
00240       (p.site_set() == *this) &&
00241       
00242       (p.is_valid());
00243   }
00244 
00245   template <unsigned N, unsigned D, typename P>
00246   inline
00247   std::size_t
00248   p_faces<N, D, P>::memory_size() const
00249   {
00250     
00251     abort();
00252     return 0;
00253   }
00254 
00255   template <unsigned N, unsigned D, typename P>
00256   topo::complex<D>&
00257   p_faces<N, D, P>::cplx() const
00258   {
00259     mln_precondition(is_valid());
00260     return cplx_;
00261   }
00262 
00263   template <unsigned N, unsigned D, typename P>
00264   topo::complex<D>&
00265   p_faces<N, D, P>::cplx()
00266   {
00267     mln_precondition(is_valid());
00268     return cplx_;
00269   }
00270 
00271 
00272   
00273 
00274 
00275 
00276   template <unsigned N, unsigned D, typename P>
00277   bool
00278   operator==(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>& rhs)
00279   {
00280     
00281 
00282     return lhs.cplx() == rhs.cplx();
00283   }
00284 
00285   template <unsigned N, unsigned D, typename P>
00286   bool
00287   operator<=(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>& rhs)
00288   {
00289     
00290 
00291     return lhs == rhs;
00292   }
00293 
00294 # endif // ! MLN_INCLUDE_ONLY
00295 
00296 } 
00297 
00298 #endif // ! MLN_CORE_SITE_SET_P_FACES_HH