Commit 6a98b954 authored by Nicolas Ballas's avatar Nicolas Ballas
Browse files

add point implementation for Iterator_On_Points.

	* olena/tests/core/iter_point1d.cc, olena/tests/core/iter_point2d.cc: New.
	* olena/tests/core/iter_point3d.cc: New test file.
	* olena/tests/core/Makefile.am: Add new tests in make check.
	* olena/oln/core/internal/iterator_on_points_impl.hh: New, implementations for Iterator_On_Points.
	* olena/oln/core/internal/iterator_on_points_base.hh: Now derive from itertor_on_points_impl 


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@924 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 777b6fef
2007-03-29 Nicolas Ballas <ballas@lrde.epita.fr>
add point implementation for Iterator_On_Points.
* olena/tests/core/iter_point1d.cc, olena/tests/core/iter_point2d.cc: New.
* olena/tests/core/iter_point3d.cc: New test file.
* olena/tests/core/Makefile.am: Add new tests in make check.
* olena/oln/core/internal/iterator_on_points_impl.hh: New, implementations for Iterator_On_Points.
* olena/oln/core/internal/iterator_on_points_base.hh: Now derive from itertor_on_points_impl
2007-03-26 Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr>
Fix 'Make check morpho' / 'morpho'. draft cc_tarjan .
......
......@@ -29,6 +29,7 @@
# define OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_BASE_HH
# include <oln/core/concept/iterator_on_points.hh>
# include <oln/core/internal/iterator_on_points_impl.hh>
namespace oln
......@@ -57,15 +58,20 @@ namespace oln
typedef stc::final< oln_coord(point__) > coord;
typedef stc::final< oln_dim(point__) > dim;
typedef stc::final< oln_dpoint(point__) > dpoint;
};
// for getting point implementation
typedef stc_deferred(dim) dim__;
};
namespace internal
{
template <typename Exact>
class iterator_on_points_base_ : public Iterator_on_Points<Exact>
class iterator_on_points_base_ : public Iterator_on_Points<Exact>,
public impl::iterator_on_points_impl
<mlc_value(typename vtypes< internal::iterator_on_points_base_<Exact> >::dim__),
Exact, typename vtypes< internal::iterator_on_points_base_<Exact> >::point__>
{
protected:
iterator_on_points_base_();
......
// 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_ITERATOR_ON_POINTS_IMPL_HH
# define OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_IMPL_HH
namespace oln
{
// Forward declarations
namespace impl
{
template <unsigned n, typename Exact, typename P>
struct iterator_on_points_impl;
}
template <unsigned n, typename Exact, typename P>
struct super_trait_< impl::iterator_on_points_impl<n, Exact, P> >
{
typedef Any<P> ret;
};
template <unsigned n, typename Exact, typename P>
struct vtypes< impl::iterator_on_points_impl<n, Exact, P> >
{
};
namespace impl
{
template <unsigned n, typename Exact, typename P>
struct iterator_on_points_impl : public virtual Any<Exact>
{
};
/// point1d interface
template <typename Exact, typename P>
struct iterator_on_points_impl<1, Exact, P> : public virtual Any< Exact >
{
typename P::coord ind() const;
};
/// point2d interface
template <typename Exact, typename P>
struct iterator_on_points_impl<2, Exact, P>: public virtual Any< Exact >
{
typename P::coord row() const;
typename P::coord col() const;
};
/// point3d interface
template <typename Exact, typename P>
struct iterator_on_points_impl<3, Exact, P>: public virtual Any< Exact >
{
typename P::coord row() const;
typename P::coord col() const;
typename P::coord slice() const;
};
# ifndef OLN_INCLUDE_ONLY
// point1d
template <typename Exact, typename P>
typename P::coord
iterator_on_points_impl<1, Exact, P>::ind() const
{
return exact(this)->to_point().ind();
}
// point2d
template <typename Exact, typename P>
typename P::coord
iterator_on_points_impl<2, Exact, P>::row() const
{
return exact(this)->to_point().row();
}
template <typename Exact, typename P>
typename P::coord
iterator_on_points_impl<2, Exact, P>::col() const
{
return exact(this)->to_point().col();
}
// point3d
template <typename Exact, typename P>
typename P::coord
iterator_on_points_impl<3, Exact, P>::row() const
{
return exact(this)->to_point().row();
}
template <typename Exact, typename P>
typename P::coord
iterator_on_points_impl<3, Exact, P>::col() const
{
return exact(this)->to_point().col();
}
template <typename Exact, typename P>
typename P::coord
iterator_on_points_impl<3, Exact, P>::slice() const
{
return exact(this)->to_point().slice();
}
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
} // end of namespace oln
#endif // ! OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_IMPL_HH
......@@ -25,6 +25,9 @@ check_PROGRAMS = \
grid \
image1d \
image2d \
iter_point1d \
iter_point2d \
iter_point3d \
neighb2d \
npoints \
point2d \
......@@ -40,6 +43,9 @@ dpoint2d_SOURCES = dpoint2d.cc
grid_SOURCES = grid.cc
image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
iter_point1d_SOURCES = iter_point1d.cc
iter_point2d_SOURCES = iter_point2d.cc
iter_point3d_SOURCES = iter_point3d.cc
neighb2d_SOURCES = neighb2d.cc
npoints_SOURCES = npoints.cc
point2d_SOURCES = point2d.cc
......
// 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.
#include <cassert>
#include <oln/core/1d/image1d.hh>
#include <oln/core/internal/iterator_on_points_base.hh>
int
main()
{
oln::image1d<int> ima1(40);
oln::image1d<int>::piter p (ima1.points());
oln::point1d p1;
for (p.start(); p.is_valid(); p.next())
p1.ind() = p.ind();
assert(p1.ind() == 39);
return 0;
}
// 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.
#include <cassert>
#include <oln/core/2d/image2d.hh>
int
main()
{
oln::image2d<int> ima1(40, 30);
oln::image2d<int>::piter p (ima1.points());
oln::point2d p1;
for (p.start(); p.is_valid(); p.next())
{
p1.row() = p.row();
p1.col() = p.col();
}
assert(p1.row() == 39);
assert(p1.col() == 29);
return 0;
}
// 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.
#include <cassert>
#include <oln/core/3d/image3d.hh>
int
main()
{
oln::image3d<int> ima1(40, 30, 20);
oln::image3d<int>::piter p (ima1.points());
oln::point3d p1;
for (p.start(); p.is_valid(); p.next())
{
p1.row() = p.row();
p1.col() = p.col();
p1.slice() = p.slice();
}
assert(p1.row() == 39);
assert(p1.col() == 29);
assert(p1.slice() == 19);
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment