Commit 21d16acf authored by Thierry Geraud's avatar Thierry Geraud
Browse files

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.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@866 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent a6e757e7
2007-03-13 Thierry Geraud <thierry.geraud@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.
2007-03-12 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add type of 2d images with border.
......
// Copyright (C) 2001, 2003, 2004, 2005, 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 OLN_CORE_1D_ALIASES_HH
# define OLN_CORE_1D_ALIASES_HH
namespace oln
{
/// Forward declarations.
/// \{
template <unsigned D> struct grid_;
template <typename C> class point1d_;
template <typename C> class dpoint1d_;
template <typename D> class neighb_;
template <typename D> class window_;
template <typename P> class bbox_;
template <typename P> class topo_lbbox_;
template <typename T> class fwd_piter_bbox_;
template <typename T> class bkd_piter_bbox_;
template <typename P> class fwd_qiter_win_;
template <typename P> class bkd_qiter_win_;
/// \}
/// Aliases.
/// \{
typedef grid_<1> grid1d;
typedef point1d_<int> point1d;
typedef dpoint1d_<int> dpoint1d;
typedef neighb_<dpoint1d> neighb1d;
typedef window_<dpoint1d> window1d;
typedef bbox_<point1d> bbox1d;
typedef topo_lbbox_<point1d> topo1d;
typedef fwd_piter_bbox_<point1d> fwd_piter1d;
typedef bkd_piter_bbox_<point1d> bkd_piter1d;
typedef fwd_qiter_win_<point1d> fwd_qiter1d;
typedef bkd_qiter_win_<point1d> bkd_qiter1d;
typedef point1d_<float> point1df;
typedef dpoint1d_<float> dpoint1df;
/// \}
} // end of namespace oln
#endif // ! OLN_CORE_1D_ALIASES_HH
// 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 @@ namespace oln
# 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_;
......
// Copyright (C) 2006 EPITA Research and Development Laboratory
// 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
......@@ -25,20 +25,21 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLN_CORE_2D_FWD_DECLS
# define OLN_CORE_2D_FWD_DECLS
#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
{
template <typename V, typename C> class array2d;
template <typename C> class dpoint2d_;
template <typename C> class point2d_;
template <typename T> class image2d;
// FIXME: box1d should be an actual type, not an alias...
typedef box_<point1d> box1d;
} // end of namespace oln
#endif // ! OLN_CORE_1D_BOX1D_HH
#endif // ! OLN_CORE_2D_FWD_DECLS
// 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> >
/// Virtual types.
template <>
struct vtypes< dpoint1d >
{
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;
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
// 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 OLN_CORE_1D_FWD_DECLS
# define OLN_CORE_1D_FWD_DECLS
namespace oln
{
template <typename V, typename C> class array1d;
template <typename C> class dpoint1d_;
template <typename C> class point1d_;
template <typename T> class image1d;
} // end of namespace oln
#endif // ! OLN_CORE_1D_FWD_DECLS
// Copyright (C) 2006 EPITA Research and Development Laboratory
// 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
......@@ -25,27 +25,69 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLN_CORE_FWD_DECLS
# define OLN_CORE_FWD_DECLS
#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
# include <oln/core/1d/fwd_decls.hh>
# include <oln/core/2d/fwd_decls.hh>
# include <oln/core/3d/fwd_decls.hh>
# include <oln/core/gen/fwd_decls.hh>
namespace oln
{
template <typename T> class image1d;
template <typename T> class image2d;
template <typename T> class image3d;
template <typename E> class image_entry;
template <typename E> class image_entry;
template <typename P, typename V> class mapimage;
} // end of 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;