Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 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 // FIXME: Disabled (moved to the attic). 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 // FIXME: Have G default to mln::geom::complex_geom<D, P>? But we 00048 // don't know P... 00049 00050 00051 namespace mln 00052 { 00053 00054 // Forward declarations. 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 // FIXME: Disabled (moved to the attic). 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 // FIXME: Depends on G! 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 } // end of namespace mln::trait 00080 00081 00082 /* FIXME: We should decide was G represents: 00083 00084 - a unique site type for all faces of all dimensions? 00085 (Acceptable for a first implementation -- the one currently 00086 chosen.) 00087 00088 - the site type associated to 0-faces only (site types of n-faces 00089 with n > 1 will be deduced from this one)? 00090 (Better, but not really flexible.) 00091 00092 - a type list of the site types associated faces of each 00093 dimensions, e.g. 00094 00095 mln_type_list(point2d, 00096 mln_type_list(util::site_pair<point2d>, 00097 mln_type_list(site_set<point2d>, // or site_triplet<point2d> 00098 mln_empty_list))) 00099 00100 for a 2-complex? 00101 (The best solution so far, but requires more work.) */ 00102 00103 /* FIXME: Aggregate site data (location). */ 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 // FIXME: This method is probably useless now. 00162 bool is_valid() const; 00163 00165 bool has(const psite& p) const; 00166 00167 // FIXME: Dummy. 00168 std::size_t memory_size() const; 00169 00174 /* FIXME: Move back the const qualifier on this return type (see 00175 comment below on cplx_). */ 00176 topo::complex<D>& cplx() const; 00179 topo::complex<D>& cplx(); 00180 00182 const G& geom() const; 00184 00185 private: 00187 /* FIXME: Get rid of this `mutable' qualifier. This is needed for 00188 compatiblity reasons with topo::face (see p_complex_piter). 00189 00190 We should either 00191 00192 - have an additional version of topo::face holding a const (not 00193 mutable) complex; 00194 00195 - have face_handle and topo::face do not hold a reference on a 00196 complex, leading to a design of complexes similar to graphs, 00197 where vertex and edge handles (named `id's) are not tied to a 00198 specific graph. */ 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 // Check whether P's complex is compatible with this pset's complex. 00276 (p.site_set() == *this) && 00277 // Check whether P is valid. 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 // FIXME: Dummy; implement (see other site sets). 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 | Comparisons. | 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 /* FIXME: When actual location data is attached to a p_complex, 00324 check also the equlity w.r.t. to these data. */ 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 /* FIXME: When actual location data is attached to a p_complex, 00333 check also the equality w.r.t. to these data. */ 00334 return lhs == rhs; 00335 } 00336 00337 # endif // ! MLN_INCLUDE_ONLY 00338 00339 } // end of mln 00340 00341 #endif // ! MLN_CORE_SITE_SET_P_COMPLEX_HH