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_COMPLEX_HH
00027 # define MLN_CORE_SITE_SET_P_COMPLEX_HH
00028 
00032 
00033 # include <mln/core/internal/site_set_base.hh>
00034 
00035 # include <mln/topo/complex.hh>
00036 
00037 # include <mln/core/site_set/complex_psite.hh>
00038 # include <mln/core/site_set/p_complex_piter.hh>
00039 # include <mln/core/site_set/p_n_faces_piter.hh>
00040 
00041 # if 0
00042 #  include <mln/core/site_set/p_complex_faces_piter.hh>
00043 # endif
00044 
00045 # include <mln/geom/complex_geometry.hh>
00046 
00047 
00048 
00049 
00050 
00051 namespace mln
00052 {
00053 
00054   
00055   template <unsigned D, typename G> class p_complex;
00056 
00057   template <unsigned D, typename G> class p_complex_fwd_piter_;
00058   template <unsigned D, typename G> class p_complex_bkd_piter_;
00059 
00060 
00061 # if 0
00062   template <unsigned N, unsigned D, typename G>
00063   class p_complex_faces_fwd_piter_;
00064   template <unsigned N, unsigned D, typename G>
00065   class p_complex_faces_bkd_piter_;
00066 # endif
00067 
00068   namespace trait
00069   {
00070     template <unsigned D, typename G>
00071     struct site_set_< p_complex<D, G> >
00072     {
00073       typedef trait::site_set::nsites::known   nsites;
00074       
00075       typedef trait::site_set::bbox::unknown   bbox;
00076       typedef trait::site_set::contents::fixed contents;
00077       typedef trait::site_set::arity::unique   arity;
00078     };
00079   } 
00080 
00081 
00082   
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103   
00104 
00112 
00113 
00114 
00115   template <unsigned D, typename G>
00116   class p_complex
00117     : public internal::site_set_base_< complex_psite<D, G>, p_complex<D, G> >
00118   {
00119     typedef p_complex<D, G> self_;
00120     typedef internal::site_set_base_< complex_psite<D, G>, self_ > super_;
00121 
00122   public:
00127     p_complex(const topo::complex<D>& cplx, const G& geom);
00128 
00132     typedef mln_site(super_) element;
00133 
00135     typedef complex_psite<D, G> psite;
00136 
00138     typedef p_complex_fwd_piter_<D, G> fwd_piter;
00139 
00141     typedef p_complex_bkd_piter_<D, G> bkd_piter;
00142 
00144     typedef fwd_piter piter;
00146 
00153     unsigned nsites() const;
00154 
00156     unsigned nfaces() const;
00158     unsigned nfaces_of_dim(unsigned n) const;
00159 
00160     
00162     bool is_valid() const;
00163 
00165     bool has(const psite& p) const;
00166 
00167     
00168     std::size_t memory_size() const;
00169 
00174     
00175 
00176     topo::complex<D>& cplx() const;
00179     topo::complex<D>& cplx();
00180 
00182     const G& geom() const;
00184 
00185   private:
00187     
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199     mutable topo::complex<D> cplx_;
00201     G geom_;
00202   };
00203 
00204 
00209   template <unsigned D, typename G>
00210   bool
00211   operator==(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs);
00212 
00221   template <unsigned D, typename G>
00222   bool
00223   operator<=(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs);
00224 
00225 
00226 
00227 # ifndef MLN_INCLUDE_ONLY
00228 
00229   template <unsigned D, typename G>
00230   inline
00231   p_complex<D, G>::p_complex(const topo::complex<D>& cplx, const G& geom)
00232     : cplx_(cplx), geom_(geom)
00233   {
00234   }
00235 
00236   template <unsigned D, typename G>
00237   inline
00238   unsigned
00239   p_complex<D, G>::nsites() const
00240   {
00241     return nfaces();
00242   }
00243 
00244   template <unsigned D, typename G>
00245   inline
00246   unsigned
00247   p_complex<D, G>::nfaces() const
00248   {
00249     return cplx_.nfaces();
00250   }
00251 
00252   template <unsigned D, typename G>
00253   inline
00254   unsigned
00255   p_complex<D, G>::nfaces_of_dim(unsigned n) const
00256   {
00257     return cplx_.nfaces_of_dim(n);
00258   }
00259 
00260   template <unsigned D, typename G>
00261   inline
00262   bool
00263   p_complex<D, G>::is_valid() const
00264   {
00265     return true;
00266   }
00267 
00268   template <unsigned D, typename G>
00269   inline
00270   bool
00271   p_complex<D, G>::has(const psite& p) const
00272   {
00273     mln_precondition(is_valid());
00274     return
00275       
00276       (p.site_set() == *this) &&
00277       
00278       (p.is_valid());
00279   }
00280 
00281   template <unsigned D, typename G>
00282   inline
00283   std::size_t
00284   p_complex<D, G>::memory_size() const
00285   {
00286     
00287     abort();
00288     return 0;
00289   }
00290 
00291   template <unsigned D, typename G>
00292   topo::complex<D>&
00293   p_complex<D, G>::cplx() const
00294   {
00295     mln_precondition(is_valid());
00296     return cplx_;
00297   }
00298 
00299   template <unsigned D, typename G>
00300   topo::complex<D>&
00301   p_complex<D, G>::cplx()
00302   {
00303     mln_precondition(is_valid());
00304     return cplx_;
00305   }
00306 
00307   template <unsigned D, typename G>
00308   const G&
00309   p_complex<D, G>::geom() const
00310   {
00311     return geom_;
00312   }
00313 
00314 
00315   
00316 
00317 
00318 
00319   template <unsigned D, typename G>
00320   bool
00321   operator==(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs)
00322   {
00323     
00324 
00325     return lhs.cplx() == rhs.cplx();
00326   }
00327 
00328   template <unsigned D, typename G>
00329   bool
00330   operator<=(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs)
00331   {
00332     
00333 
00334     return lhs == rhs;
00335   }
00336 
00337 # endif // ! MLN_INCLUDE_ONLY
00338 
00339 } 
00340 
00341 #endif // ! MLN_CORE_SITE_SET_P_COMPLEX_HH