Commit 63a3fc78 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2006-10-12 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Add image accessors with indices.
	
	* tests/at.cc: New.
	* oln/core/automatic/image1d.hh: New.
	* oln/core/automatic/image2d.hh: New.
	* oln/core/automatic/image3d.hh: New.
	* tests/Makefile.am (check_PROGRAMS): Add 'at'.
	Move io_pnm to get consistent with SOURCES list.
	(at_SOURCES): New.
	* oln/core/typedefs.hh (oln_psite, oln_psite_): New.	
	* oln/core/automatic/image_being_mutable.hh
	(lvalue_t, psite_t): Remove; use oln_lvalue and oln_psite instead.
	(impl_op_readwrite): Update sig.
	* oln/core/abstract/image/dimension/1d.hh (at): New const method.
	(at, has_at): New methods that should be elsewhere; this is a hack.
	(image1d): Move ctor impl inside guards.
	* oln/core/abstract/image/dimension/2d.hh (at): New const method.
	(at, has_at): New methods that should be elsewhere; this is a hack.
	(image2d): Move ctor impl inside guards.
	* oln/core/abstract/image/dimension/3d.hh (at): New const method.
	(at, has_at): New methods that should be elsewhere; this is a hack.
	(image3d): Move ctor impl inside guards.
	* oln/core/abstract/point.hh (include): Add xtd/vec.hh.
	* oln/core/1d/neighb1d.hh (mk_c2): Update to mimic neighb2d.
	* oln/core/2d/image2d.hh (impl_at): New.
	* oln/core/3d/image3d.hh (impl_at): New.
	* oln/Makefile.am (nobase_oln_HEADERS): Update.
	* oln/morpher/internal/image_extension.hh (delegate): New mutable
	version.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@630 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 5f383334
2006-10-12 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add image accessors with indices.
* tests/at.cc: New.
* oln/core/automatic/image1d.hh: New.
* oln/core/automatic/image2d.hh: New.
* oln/core/automatic/image3d.hh: New.
* tests/Makefile.am (check_PROGRAMS): Add 'at'.
Move io_pnm to get consistent with SOURCES list.
(at_SOURCES): New.
* oln/core/typedefs.hh (oln_psite, oln_psite_): New.
* oln/core/automatic/image_being_mutable.hh
(lvalue_t, psite_t): Remove; use oln_lvalue and oln_psite instead.
(impl_op_readwrite): Update sig.
* oln/core/abstract/image/dimension/1d.hh (at): New const method.
(at, has_at): New methods that should be elsewhere; this is a hack.
(image1d): Move ctor impl inside guards.
* oln/core/abstract/image/dimension/2d.hh (at): New const method.
(at, has_at): New methods that should be elsewhere; this is a hack.
(image2d): Move ctor impl inside guards.
* oln/core/abstract/image/dimension/3d.hh (at): New const method.
(at, has_at): New methods that should be elsewhere; this is a hack.
(image3d): Move ctor impl inside guards.
* oln/core/abstract/point.hh (include): Add xtd/vec.hh.
* oln/core/1d/neighb1d.hh (mk_c2): Update to mimic neighb2d.
* oln/core/2d/image2d.hh (impl_at): New.
* oln/core/3d/image3d.hh (impl_at): New.
* oln/Makefile.am (nobase_oln_HEADERS): Update.
* oln/morpher/internal/image_extension.hh (delegate): New mutable
version.
2006-10-12 Roland Levillain <roland@lrde.epita.fr>
Fix sanity tests.
......@@ -132,6 +164,25 @@
* oln/core/gen/topo_lbbox.hh (oln::topo_lbbox_<point>): Ensure
parameter point is an oln::abstract::point.
2006-10-11 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
* tests/at.cc: New.
* oln/core/automatic/image1d.hh: New.
* oln/core/automatic/image2d.hh: New.
* oln/core/automatic/image3d.hh: New.
* tests/Makefile.am
* oln/core/typedefs.hh
* oln/core/automatic/image_being_mutable.hh
* oln/core/abstract/image/dimension/1d.hh
* oln/core/abstract/image/dimension/2d.hh
* oln/core/abstract/image/dimension/3d.hh
* oln/core/abstract/point.hh
* oln/core/1d/neighb1d.hh
* oln/core/2d/image2d.hh
* oln/core/3d/image3d.hh
* oln/Makefile.am
* oln/morpher/internal/image_extension.hh
2006-10-11 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add new facilities to access to components such as row, col, etc.
......
......@@ -91,6 +91,9 @@ nobase_oln_HEADERS = \
core/abstract/window.hh \
\
core/automatic/image.hh \
core/automatic/image1d.hh \
core/automatic/image2d.hh \
core/automatic/image3d.hh \
core/automatic/image_being_mutable.hh \
core/automatic/image_being_random_accessible.hh \
core/automatic/image_having_neighborhood.hh \
......
......@@ -46,13 +46,9 @@ namespace oln
neighb1d mk_c2()
{
static bool flower = true;
static neighb1d the_;
if (flower)
{
the_.add(dpoint1d(1));
flower = false;
}
neighb1d the_;
the_
.add(dpoint1d(1));
return the_;
}
......@@ -67,7 +63,7 @@ namespace oln
# ifndef OLN_INCLUDE_ONLY
const neighb1d c2 = internal::mk_c2();
const neighb1d c2 = internal::mk_c2();
# endif
......
......@@ -93,7 +93,10 @@ namespace oln
const topo2d& impl_topo() const;
T impl_op_read(const point2d& p) const;
T impl_at(int row, int col) const;
T& impl_op_readwrite(const point2d& p);
T& impl_at(int row, int col);
T* adr_at(int row, int col);
const T* adr_at(int row, int col) const;
......@@ -128,12 +131,14 @@ namespace oln
{
}
template <typename T>
const topo2d& image2d<T>::impl_topo() const
{
return topo_;
}
template <typename T>
T image2d<T>::impl_op_read(const point2d& p) const
{
......@@ -142,6 +147,14 @@ namespace oln
return data_->operator()(p.row(), p.col());
}
template <typename T>
T image2d<T>::impl_at(int row, int col) const
{
precondition(data_->has(row, col));
return data_->operator()(row, col);
}
template <typename T>
T& image2d<T>::impl_op_readwrite(const point2d& p)
{
......@@ -150,6 +163,14 @@ namespace oln
return data_->operator()(p.row(), p.col());
}
template <typename T>
T& image2d<T>::impl_at(int row, int col)
{
precondition(data_->has(row, col));
return data_->operator()(row, col);
}
template <typename T>
T* image2d<T>::adr_at(int row, int col)
{
......
......@@ -94,7 +94,10 @@ namespace oln
const topo3d& impl_topo() const;
T impl_op_read(const point3d& p) const;
T impl_at(int slice, int row, int col) const;
T& impl_op_readwrite(const point3d& p);
T& impl_at(int slice, int row, int col);
T* adr_at(int slice, int row, int col);
const T* adr_at(int slice, int row, int col) const;
......@@ -106,7 +109,6 @@ namespace oln
};
# ifndef OLN_INCLUDE_ONLY
template <typename T>
......@@ -137,13 +139,16 @@ namespace oln
}
template <typename T>
const topo3d& image3d<T>::impl_topo() const
const topo3d&
image3d<T>::impl_topo() const
{
return topo_;
}
template <typename T>
T image3d<T>::impl_op_read(const point3d& p) const
T
image3d<T>::impl_op_read(const point3d& p) const
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
......@@ -151,13 +156,32 @@ namespace oln
}
template <typename T>
T& image3d<T>::impl_op_readwrite(const point3d& p)
T
image3d<T>::impl_at(int slice, int row, int col) const
{
precondition(data_->has(slice, row, col));
return data_->operator()(slice, row, col);
}
template <typename T>
T&
image3d<T>::impl_op_readwrite(const point3d& p)
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
return data_->operator()(p.slice(), p.row(), p.col());
}
template <typename T>
T&
image3d<T>::impl_at(int slice, int row, int col)
{
precondition(data_->has(slice, row, col));
return data_->operator()(slice, row, col);
}
template <typename T>
T* image3d<T>::adr_at(int slice, int row, int col)
{
......
......@@ -29,6 +29,7 @@
# define OLN_CORE_ABSTRACT_IMAGE_DIMENSION_1D_HH
# include <oln/core/abstract/image.hh>
# include <oln/core/automatic/image1d.hh>
namespace oln
......@@ -43,11 +44,50 @@ namespace oln
public virtual image<E>,
public automatic::get_impl<image1d, E>
{
public:
oln_rvalue(E) at(const oln_coord(E)& index) const;
// FIXME: Hack (should be elsewhere)!
oln_lvalue(E)& at(const oln_coord(E)& index);
bool has_at(const oln_coord(E)& index) const;
protected:
/// Constructor (protected, empty).
image1d() {}
image1d();
};
# ifndef OLN_INCLUDE_ONLY
template <typename E>
image1d<E>::image1d()
{
}
template <typename E>
oln_rvalue(E)
image1d<E>::at(const oln_coord(E)& index) const
{
return this->exact().impl_at(index);
}
template <typename E>
oln_lvalue(E)&
image1d<E>::at(const oln_coord(E)& index)
{
return this->exact().impl_at(index);
}
template <typename E>
bool
image1d<E>::has_at(const oln_coord(E)& index) const
{
return this->exact().impl_has_at(index);
}
# endif
} // end of namespace oln::abstract
} // end of namespace oln
......
......@@ -29,6 +29,7 @@
# define OLN_CORE_ABSTRACT_IMAGE_DIMENSION_2D_HH
# include <oln/core/abstract/image.hh>
# include <oln/core/automatic/image2d.hh>
namespace oln
......@@ -43,6 +44,14 @@ namespace oln
public virtual image<E>,
public automatic::get_impl<image2d, E>
{
public:
oln_rvalue(E) at(const oln_coord(E)& row, const oln_coord(E)& col) const;
// FIXME: Hack (should be elsewhere)!
oln_lvalue(E)& at(const oln_coord(E)& row, const oln_coord(E)& col);
bool has_at(const oln_coord(E)& row, const oln_coord(E)& col) const;
protected:
/// Constructor (protected, empty).
image2d();
......@@ -56,6 +65,27 @@ namespace oln
{
}
template <typename E>
oln_rvalue(E)
image2d<E>::at(const oln_coord(E)& row, const oln_coord(E)& col) const
{
return this->exact().impl_at(row, col);
}
template <typename E>
oln_lvalue(E)&
image2d<E>::at(const oln_coord(E)& row, const oln_coord(E)& col)
{
return this->exact().impl_at(row, col);
}
template <typename E>
bool
image2d<E>::has_at(const oln_coord(E)& row, const oln_coord(E)& col) const
{
return this->exact().impl_has_at(row, col);
}
# endif
} // end of namespace oln::abstract
......
......@@ -29,6 +29,7 @@
# define OLN_CORE_ABSTRACT_IMAGE_DIMENSION_3D_HH
# include <oln/core/abstract/image.hh>
# include <oln/core/automatic/image3d.hh>
namespace oln
......@@ -43,10 +44,61 @@ namespace oln
public virtual image<E>,
public automatic::get_impl<image3d, E>
{
public:
oln_rvalue(E) at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col) const;
// FIXME: Hack (should be elsewhere)!
oln_lvalue(E)& at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col);
bool has_at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col) const;
protected:
/// Constructor (protected, empty).
image3d() {}
image3d();
};
# ifndef OLN_INCLUDE_ONLY
template <typename E>
image3d<E>::image3d()
{
}
template <typename E>
oln_rvalue(E)
image3d<E>::at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col) const
{
return this->exact().impl_at(slice, row, col);
}
template <typename E>
oln_lvalue(E)&
image3d<E>::at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col)
{
return this->exact().impl_at(slice, row, col);
}
template <typename E>
bool
image3d<E>::has_at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col) const
{
return this->exact().impl_has_at(slice, row, col);
}
# endif
} // end of namespace oln::abstract
......
......@@ -29,6 +29,8 @@
#ifndef OLN_CORE_ABSTRACT_POINT_HH
# define OLN_CORE_ABSTRACT_POINT_HH
# include <xtd/vec.hh>
# include <oln/core/typedefs.hh>
# include <oln/core/traits_id.hh>
# include <oln/core/abstract/dpoint.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_AUTOMATIC_IMAGE1D_HH
# define OLN_CORE_AUTOMATIC_IMAGE1D_HH
# include <oln/core/automatic/impl.hh>
# include <oln/morpher/tags.hh>
# include <oln/core/1d/point1d.hh>
namespace oln
{
// Forward declaration.
namespace abstract
{
template <typename E> class image1d;
} // end of namespace oln::abstract
namespace automatic
{
/// Default implementation corresponding to the interface
/// oln::abstract::image1d.
template <typename E, typename tag>
class set_impl<abstract::image1d, tag, E> :
public virtual stc::any__simple<E>
{
public:
oln_rvalue(E) impl_at(const oln_coord(E)& index) const;
// FIXME: Hack.
oln_lvalue(E)& impl_at(const oln_coord(E)& index);
bool impl_has_at(const oln_coord(E)& index) const;
};
/// Implementation corresponding to the interface
/// oln::abstract::image1d for an identity morpher.
template <typename E>
class set_impl<abstract::image1d, morpher::tag::identity, E> :
public virtual stc::any__simple<E>
{
public:
oln_rvalue(E) impl_at(const oln_coord(E)& index) const;
// FIXME: Hack.
oln_lvalue(E)& impl_at(const oln_coord(E)& index);
bool impl_has_at(const oln_coord(E)& index) const;
};
# ifndef OLN_INCLUDE_ONLY
// Default is: 1. convert (index) -> p then 2. call operator()(p).
template <typename E, typename tag>
oln_rvalue(E)
set_impl<abstract::image1d, tag, E>
::impl_at(const oln_coord(E)& index) const
{
point1d tmp(index);
return this->exact().operator()(tmp);
}
template <typename E, typename tag>
oln_lvalue(E)&
set_impl<abstract::image1d, tag, E>
::impl_at(const oln_coord(E)& index)
{
point1d tmp(index);
return this->exact().operator()(tmp);
}
template <typename E, typename tag>
bool
set_impl<abstract::image1d, tag, E>
::impl_has_at(const oln_coord(E)& index) const
{
point1d tmp(index);
return this->exact().has(tmp);
}
// For morphers: delegate.
template <typename E>
oln_rvalue(E)
set_impl<abstract::image1d, morpher::tag::identity, E>
::impl_at(const oln_coord(E)& index) const
{
return this->exact().delegate().at(index);
}
template <typename E>
oln_lvalue(E)&
set_impl<abstract::image1d, morpher::tag::identity, E>
::impl_at(const oln_coord(E)& index)
{
return this->exact().delegate().at(index);
}
template <typename E>
bool
set_impl<abstract::image1d, morpher::tag::identity, E>
::impl_has_at(const oln_coord(E)& index) const
{
return this->exact().delegate().has_at(index);
}
# endif
} // end of namespace oln::automatic
} // end of namespace oln
#endif // ! OLN_CORE_AUTOMATIC_IMAGE1D_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_AUTOMATIC_IMAGE2D_HH
# define OLN_CORE_AUTOMATIC_IMAGE2D_HH
# include <oln/core/automatic/impl.hh>
# include <oln/morpher/tags.hh>
# include <oln/core/2d/point2d.hh>
namespace oln
{
// Forward declaration.
namespace abstract
{
template <typename E> class image2d;
} // end of namespace oln::abstract
namespace automatic
{
/// Default implementation corresponding to the interface
/// oln::abstract::image2d.