https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add 1D classes and remove some dead code.
* oln/core/internal/utils.hh (triplet): New.
* oln/core/1d/image1d_b.hh,
* oln/core/1d/grid1d.hh,
* oln/core/1d/box1d.hh,
* oln/core/internal/dpoint1d.hh,
* oln/core/internal/point1d.hh: New.
* tests/core/grid.cc,
* oln/core/1d/neighb1d.hh,
* oln/core/1d/dpoint1d.hh,
* oln/core/1d/array1d.hh,
* oln/core/1d/image1d.hh,
* oln/core/1d/window1d.hh,
* oln/core/1d/point1d.hh: Update.
* oln/core/aliases.hh,
* oln/core/fwd_decls.hh,
* oln/core/1d/aliases.hh,
* oln/core/1d/topo1d.hh,
* oln/core/1d/fwd_decls.hh,
* oln/core/2d/aliases.hh,
* oln/core/2d/topo2d.hh,
* oln/core/2d/fwd_decls.hh,
* oln/core/3d/aliases.hh,
* oln/core/3d/topo3d.hh,
* oln/core/3d/fwd_decls.hh,
* oln/core/gen/fwd_decls.hh: Remove.
* oln/core/2d/box2d.hh,
* oln/core/2d/neighb2d.hh,
* oln/core/2d/window2d.hh (include): Remove aliases.
* oln/core/internal/point2d.hh (grid_): Remove fwd decl.
oln/core/1d/array1d.hh | 149 ++++++++++++++++++++---------
oln/core/1d/box1d.hh | 45 +++++++++
oln/core/1d/dpoint1d.hh | 91 +++++-------------
oln/core/1d/grid1d.hh | 93 ++++++++++++++++++
oln/core/1d/image1d.hh | 154 ++++++++++++++++++------------
oln/core/1d/image1d_b.hh | 210 ++++++++++++++++++++++++++++++++++++++++++
oln/core/1d/neighb1d.hh | 10 +-
oln/core/1d/point1d.hh | 107 +++++----------------
oln/core/1d/window1d.hh | 18 ++-
oln/core/2d/box2d.hh | 2
oln/core/2d/neighb2d.hh | 2
oln/core/2d/window2d.hh | 2
oln/core/internal/dpoint1d.hh | 108 +++++++++++++++++++++
oln/core/internal/point1d.hh | 108 +++++++++++++++++++++
oln/core/internal/point2d.hh | 1
oln/core/internal/utils.hh | 48 ++++++++-
tests/core/grid.cc | 4
17 files changed, 880 insertions(+), 272 deletions(-)
Index: tests/core/grid.cc
--- tests/core/grid.cc (revision 865)
+++ tests/core/grid.cc (working copy)
@@ -30,8 +30,8 @@
#include <cassert>
#include <oln/core/2d/grid2d.hh>
// FIXME: Disabled.
-// #include <oln/core/1d/aliases.hh>
-// #include <oln/core/3d/aliases.hh>
+// #include <oln/core/1d/grid1d.hh>
+// #include <oln/core/3d/grid3d.hh>
int
Index: oln/core/1d/neighb1d.hh
--- oln/core/1d/neighb1d.hh (revision 865)
+++ oln/core/1d/neighb1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -36,6 +36,7 @@
namespace oln
{
+ // FIXME: neighb2d should be an actual type, not an alias...
typedef neighb_<dpoint1d> neighb1d;
@@ -49,10 +50,9 @@
neighb1d mk_c2()
{
- neighb1d the_;
- the_
- .add(dpoint1d(1));
- return the_;
+ neighb1d tmp;
+ tmp.take(dpoint1d(1));
+ return tmp;
}
# endif
Index: oln/core/1d/dpoint1d.hh
--- oln/core/1d/dpoint1d.hh (revision 865)
+++ oln/core/1d/dpoint1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,103 +29,66 @@
#ifndef OLN_CORE_1D_DPOINT1D_HH
# define OLN_CORE_1D_DPOINT1D_HH
-# include <mlc/int.hh>
-# include <oln/core/1d/point1d.hh>
-# include <oln/core/internal/dpoint_nd.hh>
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/internal/dpoint1d.hh>
namespace oln
{
- typedef dpoint1d_<int> dpoint1d;
-
- /// Fwd decls.
- template <unsigned D> struct grid_;
- typedef grid_<1> grid1d;
- template <typename C> struct point1d_;
- typedef point1d_<int> point1d;
+ struct point1d;
+ struct dpoint1d;
/// Super type.
- template<typename C>
- struct set_super_type< dpoint1d_<C> >
+ template<>
+ struct super_trait_< dpoint1d >
{
- typedef internal::dpoint_nd< dpoint1d_<C> > ret;
+ typedef internal::dpoint1d_< dpoint1d > ret;
};
- /// Virtual types associated to oln::dpoint1d_<C>.
- template <typename C>
- struct vtypes< dpoint1d_<C> >
- {
- typedef grid1d grid_type;
- typedef point1d point_type;
- typedef C coord_type;
- typedef mlc::uint_<1> dim_type;
-
- typedef mlc::uint_<0> index_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< dpoint1d >
+ {
+ typedef grid1d grid;
+ typedef int coord;
+ typedef point1d point;
};
- /// General 1D dpoint class.
- template <typename C>
- class dpoint1d_
- : public internal::dpoint_nd< dpoint1d_<C> >
+ /// Usual 1D dpoint class.
+ class dpoint1d : public internal::dpoint1d_< dpoint1d >
{
- typedef dpoint1d_<C> self_t;
- typedef internal::dpoint_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- dpoint1d_();
-
- /// Ctor.
- dpoint1d_(const xtd::vec<1,C>& v);
-
- /// Ctor.
- dpoint1d_(C index);
-
- C index() const;
- C& index();
+ /// Ctors.
+ dpoint1d();
+ dpoint1d(int ind);
};
# ifndef OLN_INCLUDE_ONLY
- template <typename C>
- dpoint1d_<C>::dpoint1d_()
+ dpoint1d::dpoint1d()
{
}
- /// Ctor.
- template <typename C>
- dpoint1d_<C>::dpoint1d_(const xtd::vec<1,C>& v)
- : super_t(v)
+ dpoint1d::dpoint1d(int ind)
{
+ this->ind() = ind;
}
- /// Ctor.
- template <typename C>
- dpoint1d_<C>::dpoint1d_(C index)
- : super_t(xtd::mk_vec(index))
- {
- }
-
- template <typename C>
- C dpoint1d_<C>::index() const { return v_[0]; }
-
- template <typename C>
- C& dpoint1d_<C>::index() { return v_[0]; }
-
# endif
} // end of namespace oln
+// dpoint1d goes with point1d so:
+# include <oln/core/1d/point1d.hh>
+
+
#endif // ! OLN_CORE_1D_DPOINT1D_HH
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 865)
+++ oln/core/1d/array1d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2003, 2004, 2006 EPITA Research and Development
-// Laboratory
+// Copyright (C) 2001, 2003, 2004, 2006, 2007 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
@@ -29,40 +29,51 @@
#ifndef OLN_CORE_1D_ARRAY1D_HH
# define OLN_CORE_1D_ARRAY1D_HH
-# include <cstdlib>
+# include <cstddef>
# include <mlc/contract.hh>
-# include <oln/core/abstract/array.hh>
namespace oln
{
/// General 1D array class.
- template <typename value_t, typename coord_t = int>
- class array1d : public abstract::array
+
+ template <typename T, typename C = int>
+ class array1d_
{
public:
/// Ctor.
- array1d(coord_t min, coord_t max);
+ array1d_(C imin, C imax);
+
/// Ctor.
- array1d(coord_t len);
+ array1d_(C len);
/// Dtor.
- ~array1d();
+ ~array1d_();
+
+ const T& operator()(C i) const;
+ T& operator()(C i);
+
+ const T& operator[](std::size_t ind) const;
+ T& operator[](std::size_t ind);
- value_t operator()(coord_t i) const;
- value_t& operator()(coord_t i);
+ bool has(C i) const;
- bool has(coord_t i) const;
+ std::size_t memsize() const;
+ std::size_t ncells() const;
- size_t memsize() const;
+ C imin() const;
+ C imax() const;
+
+ const T* buffer() const;
+ T* buffer();
protected:
- coord_t min_, max_;
- coord_t len_;
- value_t* buffer_;
+ C imin_, imax_;
+ C len_;
+ T* buffer_;
private:
@@ -74,65 +85,113 @@
# ifndef OLN_INCLUDE_ONLY
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::array1d(coord_t min, coord_t max) :
- min_(min), max_(max)
+ template <typename T, typename C>
+ array1d_<T, C>::array1d_(C imin, C imax) :
+ imin_(imin),
+ imax_(imax)
{
- precondition(max >= min);
- len_ = max - min + 1;
+ precondition(imax >= imin);
+ len_ = imax - imin + 1;
allocate_();
}
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::array1d(coord_t len) :
- min_(0), len_(len)
+ template <typename T, typename C>
+ array1d_<T, C>::array1d_(C len) :
+ imin_(0),
+ len_(len)
{
precondition(len > 0);
- max_ = min_ + len_;
+ imax_ = imin_ + len_;
allocate_();
}
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::~array1d()
+ template <typename T, typename C>
+ array1d_<T, C>::~array1d_()
{
deallocate_();
}
- template <typename value_t, typename coord_t>
- value_t array1d<value_t, coord_t>::operator()(coord_t i) const
+ template <typename T, typename C>
+ const T& array1d_<T, C>::operator()(C i) const
{
precondition(has(i));
- return buffer_[i - min_];
+ return buffer_[i];
}
- template <typename value_t, typename coord_t>
- value_t& array1d<value_t, coord_t>::operator()(coord_t i)
+ template <typename T, typename C>
+ T& array1d_<T, C>::operator()(C i)
{
precondition(has(i));
- return buffer_[i - min_];
+ return buffer_[i];
+ }
+
+ template <typename T, typename C>
+ const T& array1d_<T, C>::operator[](std::size_t ind) const
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < len_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ T& array1d_<T, C>::operator[](std::size_t ind)
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < len_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ bool array1d_<T, C>::has(C i) const
+ {
+ return i >= imin_ and i <= imax_;
+ }
+
+
+ template <typename T, typename C>
+ C array1d_<T, C>::imin() const
+ {
+ return imin_;
+ }
+
+ template <typename T, typename C>
+ C array1d_<T, C>::imax() const
+ {
+ return imax_;
+ }
+
+ template <typename T, typename C>
+ const T* array1d_<T, C>::buffer() const
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ T* array1d_<T, C>::buffer()
+ {
+ return buffer_;
}
- template <typename value_t, typename coord_t>
- bool array1d<value_t, coord_t>::has(coord_t i) const
+ template <typename T, typename C>
+ std::size_t array1d_<T, C>::ncells() const
{
- return
- i >= min_ and i <= max_;
+ return len_;
}
- template <typename value_t, typename coord_t>
- size_t array1d<value_t, coord_t>::memsize() const
+ template <typename T, typename C>
+ std::size_t array1d_<T, C>::memsize() const
{
- return size_t(len_) * sizeof(value_t);
+ return len_ * sizeof(T);
}
- template <typename value_t, typename coord_t>
- void array1d<value_t, coord_t>::allocate_()
+ template <typename T, typename C>
+ void array1d_<T, C>::allocate_()
{
- buffer_ = new value_t[size_t(len_)];
+ buffer_ = new T[len_];
}
- template <typename value_t, typename coord_t>
- void array1d<value_t, coord_t>::deallocate_()
+ template <typename T, typename C>
+ void array1d_<T, C>::deallocate_()
{
precondition(buffer_ != 0);
delete[] buffer_;
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 865)
+++ oln/core/1d/image1d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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
@@ -29,73 +29,73 @@
#ifndef OLN_CORE_1D_IMAGE1D_HH
# define OLN_CORE_1D_IMAGE1D_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/image_base.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/point1d.hh>
-# include <oln/core/1d/topo1d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
+# include <oln/core/1d/box1d.hh>
namespace oln
{
- // Forward declaration.
+ // Fwd decl.
template <typename T> class image1d;
- /// Virtual types associated to oln::image1d<T>.
+ /// Virtual types.
template <typename T>
struct vtypes< image1d<T> >
{
- typedef topo1d topo_type;
+ typedef point1d point;
- typedef point1d point_type;
+ typedef int coord;
+ typedef unsigned index;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box1d pset;
+ typedef array1d_<value, coord> data;
};
- /// Super type declaration.
+ /// Super type.
template <typename T>
- struct set_super_type< image1d<T> >
+ struct super_trait_< image1d<T> >
{
- typedef image1d<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image1d<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 1D image class.
+
template <typename T>
- class image1d : public image_entry< image1d<T> >
+ class image1d : public internal::plain_primitive_image_< image1d<T> >
{
- typedef image1d<T> self_t;
- typedef array1d<T> array_t;
-
+ typedef image1d<T> current;
+ typedef internal::plain_primitive_image_<current> super;
public:
+ stc_using(data);
- /// Ctor using sizes.
- image1d(unsigned nindices, unsigned border = 2);
+ image1d();
+ image1d(const box1d& b);
+ image1d(unsigned n);
- /// Ctor using an existing topology.
- image1d(const topo1d& topo);
+ bool impl_owns_(const point1d& p) const;
- const topo1d& impl_topo() const;
+ bool impl_has(const point1d& p) const;
- T impl_op_read(const point1d& p) const;
- T& impl_op_readwrite(const point1d& p);
+ const T& impl_read(const point1d& p) const;
+ const T& impl_index_read(unsigned i) const;
- T* adr_at(int index);
- const T* adr_at(int index) const;
+ T& impl_read_write(const point1d& p);
+ T& impl_index_read_write(unsigned i);
- private:
+ std::size_t impl_npoints() const;
- topo1d topo_;
- internal::tracked_ptr<array_t> data_;
+ box1d impl_bbox() const;
+ box1d impl_points() const;
};
@@ -103,57 +103,87 @@
# ifndef OLN_INCLUDE_ONLY
template <typename T>
- image1d<T>::image1d(unsigned nindices, unsigned border)
- : topo_(bbox1d(point1d(0), point1d(nindices - 1)), border),
- data_(new array_t(0 - border,
- nindices - 1 + border))
+ image1d<T>::image1d()
+ {
+ }
+
+ template <typename T>
+ image1d<T>::image1d(const box1d& b)
+ {
+ this->data_ = new data(b.pmin().ind(), b.pmax().ind());
+ }
+
+ template <typename T>
+ image1d<T>::image1d(unsigned n)
+ {
+ precondition(n != 0);
+ this->data_ = new data(0, n - 1);
+ }
+
+ template <typename T>
+ bool image1d<T>::impl_owns_(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.ind());
+ }
+
+ template <typename T>
+ bool image1d<T>::impl_has(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.ind());
+ }
+
+ template <typename T>
+ const T& image1d<T>::impl_read(const point1d& p) const
{
+ assert(this->has_data());
+ return this->data_->operator()(p.ind());
}
template <typename T>
- image1d<T>::image1d(const topo1d& topo)
- : topo_(topo),
- data_(new array_t(topo.bbox().pmin().index(),
- topo.bbox().pmax().index()))
+ const T& image1d<T>::impl_index_read(unsigned i) const
{
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->operator[](i);
}
template <typename T>
- const topo1d& image1d<T>::impl_topo() const
+ T& image1d<T>::impl_read_write(const point1d& p)
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->operator()(p.ind());
}
template <typename T>
- T image1d<T>::impl_op_read(const point1d& p) const
+ T& image1d<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.index());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->operator[](i);
}
template <typename T>
- T& image1d<T>::impl_op_readwrite(const point1d& p)
+ std::size_t image1d<T>::impl_npoints() const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.index());
+ // faster than the default code given by primitive_image_
+ assert(this->has_data());
+ return this->data_->ncells();
}
template <typename T>
- T* image1d<T>::adr_at(int index)
+ box1d image1d<T>::impl_bbox() const
{
- precondition(data_ != 0);
- precondition(data_->has(index));
- return &(data_->operator()(index));
+ assert(this->has_data());
+ box1d b(this->data_->imin(), this->data_->imax());
+ return b;
}
template <typename T>
- const T* image1d<T>::adr_at(int index) const
+ box1d image1d<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(index));
- return &(data_->operator()(index));
+ return this->bbox();
}
# endif
Index: oln/core/1d/image1d_b.hh
--- oln/core/1d/image1d_b.hh (revision 0)
+++ oln/core/1d/image1d_b.hh (revision 0)
@@ -0,0 +1,210 @@
+// Copyright (C) 2007 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 OLN_CORE_1D_IMAGE1D_B_HH
+# define OLN_CORE_1D_IMAGE1D_B_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
+# include <oln/core/1d/array1d.hh>
+# include <oln/core/1d/box1d.hh>
+
+
+namespace oln
+{
+
+
+ // FIXME: Conversely to image2d_b, we use here the triplet class
+ // instead of the array_b_ class.
+
+
+ // Fwd decl.
+ template <typename T> class image1d_b;
+
+
+ /// Virtual types.
+ template <typename T>
+ struct vtypes< image1d_b<T> >
+ {
+ typedef point1d point;
+
+ typedef int coord;
+ typedef unsigned index;
+
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box1d pset;
+ typedef internal::triplet< array1d_<T, int>,
+ unsigned,
+ box_<point1d> > data;
+ };
+
+
+ /// Super type.
+ template <typename T>
+ struct super_trait_< image1d_b<T> >
+ {
+ typedef image1d_b<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
+ };
+
+
+ /// General 1D image class.
+
+ template <typename T>
+ class image1d_b : public internal::plain_primitive_image_< image1d_b<T> >
+ {
+ typedef image1d_b<T> current;
+ typedef internal::plain_primitive_image_<current> super;
+ typedef array1d_<T, int> array_t;
+ public:
+ stc_using(data);
+
+ image1d_b();
+ image1d_b(const box1d& b, unsigned border = 2);
+ image1d_b(unsigned n, unsigned border = 2);
+
+ bool impl_owns_(const point1d& p) const;
+
+ bool impl_has(const point1d& p) const;
+
+ const T& impl_read(const point1d& p) const;
+ const T& impl_index_read(unsigned i) const;
+
+ T& impl_read_write(const point1d& p);
+ T& impl_index_read_write(unsigned i);
+
+ std::size_t impl_npoints() const;
+
+ box1d impl_bbox() const;
+ box1d impl_points() const;
+
+ unsigned border() const;
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ image1d_b<T>::image1d_b()
+ {
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(const box1d& b, unsigned border)
+ {
+ this->data_ = new data(array_t(b.pmin().ind() - border,
+ b.pmax().ind() + border),
+ border,
+ b);
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(unsigned n, unsigned border)
+ {
+ precondition(n != 0);
+ this->data_ = new data(array_t(- border,
+ n - 1 + border),
+ border,
+ box1d(0, n - 1));
+ }
+
+ template <typename T>
+ bool image1d_b<T>::impl_owns_(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p.ind());
+ }
+
+ template <typename T>
+ bool image1d_b<T>::impl_has(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value3.has(p);
+ }
+
+ template <typename T>
+ const T& image1d_b<T>::impl_read(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1(p.ind());
+ }
+
+ template <typename T>
+ const T& image1d_b<T>::impl_index_read(unsigned i) const
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->value1[i];
+ }
+
+ template <typename T>
+ T& image1d_b<T>::impl_read_write(const point1d& p)
+ {
+ assert(this->has_data());
+ return this->data_->value1(p.ind());
+ }
+
+ template <typename T>
+ T& image1d_b<T>::impl_index_read_write(unsigned i)
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->value1[i];
+ }
+
+ template <typename T>
+ box1d image1d_b<T>::impl_bbox() const
+ {
+ assert(this->has_data());
+ return this->data_->value3;
+ }
+
+ template <typename T>
+ box1d image1d_b<T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->value3;
+ }
+
+ template <typename T>
+ unsigned image1d_b<T>::border() const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+# endif
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_IMAGE1D_B_HH
Index: oln/core/1d/grid1d.hh
--- oln/core/1d/grid1d.hh (revision 0)
+++ oln/core/1d/grid1d.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 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 OLN_CORE_1D_GRID1D_HH
+# define OLN_CORE_1D_GRID1D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/concept/grid.hh>
+
+
+# define OLN_ENV_1D
+
+
+
+namespace oln
+{
+
+
+ /// \{
+ /// Fwd decls.
+
+ template <typename Exact> struct Grid_1D;
+ struct grid1d;
+
+ /// \}
+
+
+ /// \{
+ /// Grid_1D.
+
+ template <typename Exact>
+ struct vtypes< Grid_1D<Exact> >
+ {
+ typedef mlc::uint_<1> dim;
+ };
+
+ template <typename Exact>
+ struct Grid_1D : public Grid<Exact>
+ {
+ protected:
+ Grid_1D() {}
+ };
+
+ /// \}
+
+
+ /// \{
+ /// Super type.
+
+ template<>
+ struct super_trait_< grid1d >
+ {
+ typedef Grid_1D< grid1d > ret;
+ };
+
+ /// \}
+
+
+
+ /// One-dimensional grid struct.
+
+ struct grid1d : public Grid_1D< grid1d >
+ {};
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_GRID1D_HH
Index: oln/core/1d/window1d.hh
--- oln/core/1d/window1d.hh (revision 865)
+++ oln/core/1d/window1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 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
@@ -28,10 +28,18 @@
#ifndef OLN_CORE_1D_WINDOW1D_HH
# define OLN_CORE_1D_WINDOW1D_HH
-// Headers required for the complete definition of oln::window1d
-// (i.e., oln::window_<dpoint1d>).
-# include <oln/core/1d/aliases.hh>
-# include <oln/core/1d/dpoint1d.hh>
# include <oln/core/gen/window.hh>
+# include <oln/core/1d/dpoint1d.hh>
+
+
+namespace oln
+{
+
+ // FIXME: window1d should be an actual type, not an alias...
+ typedef window_<dpoint1d> window1d;
+
+
+} // end of namespace oln
+
#endif // ! OLN_CORE_1D_WINDOW1D_HH
Index: oln/core/1d/box1d.hh
--- oln/core/1d/box1d.hh (revision 0)
+++ oln/core/1d/box1d.hh (revision 0)
@@ -0,0 +1,45 @@
+// Copyright (C) 2007 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 OLN_CORE_1D_BOX1D_HH
+# define OLN_CORE_1D_BOX1D_HH
+
+# include <oln/core/gen/box.hh>
+# include <oln/core/1d/point1d.hh>
+
+
+namespace oln
+{
+
+ // FIXME: box1d should be an actual type, not an alias...
+ typedef box_<point1d> box1d;
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_BOX1D_HH
+
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 865)
+++ oln/core/1d/point1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,119 +29,66 @@
#ifndef OLN_CORE_1D_POINT1D_HH
# define OLN_CORE_1D_POINT1D_HH
-# include <mlc/int.hh>
-# include <oln/core/internal/point_nd.hh>
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/internal/point1d.hh>
namespace oln
{
- /// Fwd decls.
- template <unsigned D> struct grid_;
- template <typename C> struct dpoint1d_;
- template <typename C> struct point1d_;
-
-
- typedef grid_<1> grid1d;
- typedef dpoint1d_<int> dpoint1d;
- typedef point1d_<int> point1d;
-
-
-
- /* FIXME: Is this the right place for these functions (on types)?
- In particular, the function on dpoint1d should be near the
- definition of dpoint1d, not point1d's. */
- /// Specializations of functions point and dpoint :
- /// \f$(n, coord) \rightarrow type\f$ for \f$n = 1\f$.
- /// \{
- template <typename C> struct point_ <1, C> { typedef point1d_<C>
ret; };
- template <typename C> struct dpoint_ <1, C> { typedef dpoint1d_<C>
ret; };
- /// \}
+ struct point1d;
+ struct dpoint1d;
/// Super type.
- template<typename C>
- struct set_super_type< point1d_<C> >
+ template<>
+ struct super_trait_< point1d >
{
- typedef internal::point_nd< point1d_<C> > ret;
+ typedef internal::point1d_< point1d > ret;
};
- /// Virtual types associated to oln::point1d_<C>.
- template <typename C>
- struct vtypes< point1d_<C> >
- {
- typedef grid1d grid_type;
- typedef dpoint1d dpoint_type;
- typedef C coord_type;
- typedef mlc::uint_<1> dim_type;
-
- typedef mlc::uint_<0> index_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< point1d >
+ {
+ typedef grid1d grid;
+ typedef int coord;
+ typedef dpoint1d dpoint;
};
- /// General 1D point class.
- template <typename C>
- class point1d_ : public internal::point_nd< point1d_<C> >
+ /// Usual 1D point class.
+ class point1d : public internal::point1d_< point1d >
{
- typedef point1d_<C> self_t;
- typedef internal::point_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- point1d_();
-
- /// Ctor.
- point1d_(C index);
-
- /// Ctor.
- point1d_(const xtd::vec<1,C>& v);
-
- /// Dtor.
- ~point1d_()
- {
- }
-
- C index() const;
- C& index();
+ /// Ctors.
+ point1d();
+ point1d(int ind);
};
# ifndef OLN_INCLUDE_ONLY
-
- template <typename C>
- point1d_<C>::point1d_()
- {
- }
-
- template <typename C>
- point1d_<C>::point1d_(C index)
- : super_t (xtd::mk_vec(index))
+ point1d::point1d()
{
}
- template <typename C>
- point1d_<C>::point1d_(const xtd::vec<1,C>& v)
- : super_t(v)
+ point1d::point1d(int ind)
{
+ this->ind() = ind;
}
- template <typename C>
- C point1d_<C>::index() const { return v_[0]; }
-
- template <typename C>
- C& point1d_<C>::index() { return v_[0]; }
-
# endif
} // end of namespace oln
+// point1d goes with dpoint1d so:
+# include <oln/core/1d/dpoint1d.hh>
+
+
#endif // ! OLN_CORE_1D_POINT1D_HH
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 865)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -31,13 +31,13 @@
# include <oln/core/gen/neighb.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: neighb2d should be an actual type, not an alias...
+ typedef neighb_<dpoint2d> neighb2d;
namespace internal
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 865)
+++ oln/core/2d/window2d.hh (working copy)
@@ -30,13 +30,13 @@
# include <oln/core/gen/window.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: window2d should be an actual type, not an alias...
+ typedef window_<dpoint2d> window2d;
window2d mk_square(unsigned odd_len);
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 865)
+++ oln/core/2d/box2d.hh (working copy)
@@ -30,13 +30,13 @@
# include <oln/core/gen/box.hh>
# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: box2d should be an actual type, not an alias...
+ typedef box_<point2d> box2d;
} // end of namespace oln
Index: oln/core/internal/dpoint1d.hh
--- oln/core/internal/dpoint1d.hh (revision 0)
+++ oln/core/internal/dpoint1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 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 OLN_CORE_INTERNAL_DPOINT1D_HH
+# define OLN_CORE_INTERNAL_DPOINT1D_HH
+
+# include <oln/core/internal/dpoint_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct dpoint1d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::dpoint1d_<Exact> >
+ {
+ typedef internal::dpoint_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::dpoint1d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class dpoint1d_ : public dpoint_base_<Exact>
+ {
+ typedef dpoint_base_<Exact> super;
+
+ public:
+ stc_using(coord);
+
+ coord ind() const;
+ coord& ind();
+
+ protected:
+ dpoint1d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ dpoint1d_<Exact>::dpoint1d_()
+ {
+ }
+
+ template <typename Exact>
+ typename dpoint1d_<Exact>::coord
+ dpoint1d_<Exact>::ind() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename dpoint1d_<Exact>::coord &
+ dpoint1d_<Exact>::ind()
+ {
+ return this->v_[0];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_DPOINT1D_HH
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 865)
+++ oln/core/internal/utils.hh (working copy)
@@ -42,8 +42,8 @@
{
singleton()
{}
- singleton(T val)
- : value(val)
+ singleton(T value)
+ : value(value)
{}
T value;
};
@@ -56,15 +56,53 @@
{
pair()
{}
- pair(T1 val1, T2 val2)
- : value1(val1),
- value2(val2)
+ pair(T1 value1, T2 value2)
+ : value1(value1),
+ value2(value2)
{}
T1 value1;
T2 value2;
};
+ /// Simple triplet class.
+
+ template <typename T1, typename T2, typename T3>
+ struct triplet
+ {
+ triplet()
+ {}
+ triplet(T1 value1, T2 value2, T3 value3)
+ : value1(value1),
+ value2(value2),
+ value3(value3)
+ {}
+ T1 value1;
+ T2 value2;
+ T3 value3;
+ };
+
+
+ /// Simple quartet class.
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ struct quartet
+ {
+ quartet()
+ {}
+ quartet(T1 value1, T2 value2, T3 value3, T4 value4)
+ : value1(value1),
+ value2(value2),
+ value3(value3),
+ value4(value4)
+ {}
+ T1 value1;
+ T2 value2;
+ T3 value3;
+ T4 value4;
+ };
+
+
} // end of namespace oln::internal
} // end of namespace oln
Index: oln/core/internal/point1d.hh
--- oln/core/internal/point1d.hh (revision 0)
+++ oln/core/internal/point1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 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 OLN_CORE_INTERNAL_POINT1D_HH
+# define OLN_CORE_INTERNAL_POINT1D_HH
+
+# include <oln/core/internal/point_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct point1d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::point1d_<Exact> >
+ {
+ typedef internal::point_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point1d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class point1d_ : public point_base_<Exact>
+ {
+ typedef point_base_<Exact> super;
+
+ public:
+ stc_using(coord);
+
+ coord ind() const;
+ coord& ind();
+
+ protected:
+ point1d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ point1d_<Exact>::point1d_()
+ {
+ }
+
+ template <typename Exact>
+ typename point1d_<Exact>::coord
+ point1d_<Exact>::ind() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename point1d_<Exact>::coord &
+ point1d_<Exact>::ind()
+ {
+ return this->v_[0];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_POINT1D_HH
Index: oln/core/internal/point2d.hh
--- oln/core/internal/point2d.hh (revision 865)
+++ oln/core/internal/point2d.hh (working copy)
@@ -37,7 +37,6 @@
/// Fwd decls.
- template <unsigned D> struct grid_;
namespace internal { template <typename Exact> struct point2d_; }