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