
2006-09-18 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> Add oln topology class for enlarged bbox. * oln/core/gen/topo_lbbox.hh: New. * oln/core/abstract/dpoint_nd.hh (set_all): New. * oln/core/gen/topo_bbox.hh (impl_has_large): New. Index: oln/core/abstract/dpoint_nd.hh =================================================================== --- oln/core/abstract/dpoint_nd.hh (revision 547) +++ oln/core/abstract/dpoint_nd.hh (working copy) @@ -82,6 +82,11 @@ return v_[i]; } + void set_all(const coord_t& c) + { + v_.set_all(c); + } + const xtd::vec<n,coord_t>& vec() const { return v_; Index: oln/core/gen/topo_lbbox.hh =================================================================== --- oln/core/gen/topo_lbbox.hh (revision 0) +++ oln/core/gen/topo_lbbox.hh (revision 0) @@ -0,0 +1,116 @@ +// Copyright (C) 2006 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef OLENA_CORE_GEN_TOPO_LBBOX_HH +# define OLENA_CORE_GEN_TOPO_LBBOX_HH + +# include <oln/core/gen/bbox.hh> +# include <oln/core/topology_entry.hh> + + + +namespace oln +{ + + + // Forward declarations. + template <typename point> class topo_lbbox_; + + + // Super type declaration. + template <typename point> + struct set_super_type< topo_lbbox_<point> > + { + typedef topo_lbbox_<point> self_t; + typedef topology_entry<self_t> ret; + }; + + + /// Virtual types associated to oln::bbox_<point>. + template <typename point> + struct vtypes< topo_lbbox_<point> > + { + typedef bbox_<point> bbox_type; + typedef point point_type; + typedef mlc::true_ is_random_accessible_type; + }; + + + /// Bounding box topology based on a point class. + template <typename point> + class topo_lbbox_ : public topology_entry< topo_lbbox_<point> > + { + typedef bbox_<point> bbox_t; + + public: + + topo_lbbox_() + { + } + + topo_lbbox_(const bbox_t& bb, unsigned border) + : bb_(bb), border_(border) + { + typedef oln_type_of(point, dpoint) dpoint_t; + dpoint_t dp; + dp.set_all(border); + lbb_ = bbox_<point>(bb_.pmin() - dp, bb_.pmax() + dp); + } + + const bbox_t& impl_bbox() const + { + return bb_; + } + + bool impl_has(const point& p) const + { + return bb_.has(p); + } + + bool impl_has_large(const point& p) const + { + return lbb_.has(p); + } + + const bbox_t& lbbox() const + { + return lbb_; + } + + protected: + + bbox_<point> bb_; + unsigned border_; + bbox_<point> lbb_; // FIXME: HERE + + }; + + +} // end of namespace oln + + +#endif // ! OLENA_CORE_GEN_TOPO_LBBOX_HH Index: oln/core/gen/topo_bbox.hh =================================================================== --- oln/core/gen/topo_bbox.hh (revision 547) +++ oln/core/gen/topo_bbox.hh (working copy) @@ -87,6 +87,11 @@ return bb_.has(p); } + bool impl_has_large(const point& p) const + { + return bb_.has(p); + } + protected: bbox_<point> bb_;