Commit dd2ae6da authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2006-09-07 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Add image2d and fix topo-related classes.
	
	* olena/tests/npoints.cc: New.
	* olena/tests/Makefile.am: Update.
	* olena/oln/core/image_entry.hh: New.
	* olena/oln/core/2d/image2d.hh: New.
	* olena/oln/basics2d.hh: Force instantiation and include
	oln/core/2d/image2d.hh.
	* olena/oln/core/typedefs.hh: Include mlc/assert.hh and
	mlc/to_string.hh.
	(piter_type): Uncomment.
	(rvalue_type): New.
	(psite_type): New.
	(concrete_type): Uncomment.
	(size_type): Add comment.
	(topo_type): New.
	* olena/oln/core/abstract/topo.hh (bbox): Remove this method which
	is redundant with the one of topo_with_bbox.
	* olena/oln/core/abstract/topo_with_bbox.hh (bbox): Fix typo.
	* olena/oln/core/abstract/entry.hh (next_entry_node): New
	specialization to handle the specific and rare case of having no
	sub-hierarchy.
	* olena/oln/core/abstract/topo_ra.hh: Fix cut n paste errors.
	* olena/oln/core/abstract/pset.hh (piter): New vtype decl.
	* olena/oln/core/gen/fwd_piter.hh (fwd_piter_): Add commented
	forthcoming ctors.
	* olena/oln/core/gen/bbox_topo.hh: Cosmetics.
	* olena/oln/core/pset_entry.hh (piter_type): New.
	* olena/oln/core/abstract/image.hh: Update.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@527 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 4c3a9698
2006-09-07 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add image2d and fix topo-related classes.
* olena/tests/npoints.cc: New.
* olena/tests/Makefile.am: Update.
* olena/oln/core/image_entry.hh: New.
* olena/oln/core/2d/image2d.hh: New.
* olena/oln/basics2d.hh: Force instantiation and include
oln/core/2d/image2d.hh.
* olena/oln/core/typedefs.hh: Include mlc/assert.hh and
mlc/to_string.hh.
(piter_type): Uncomment.
(rvalue_type): New.
(psite_type): New.
(concrete_type): Uncomment.
(size_type): Add comment.
(topo_type): New.
* olena/oln/core/abstract/topo.hh (bbox): Remove this method which
is redundant with the one of topo_with_bbox.
* olena/oln/core/abstract/topo_with_bbox.hh (bbox): Fix typo.
* olena/oln/core/abstract/entry.hh (next_entry_node): New
specialization to handle the specific and rare case of having no
sub-hierarchy.
* olena/oln/core/abstract/topo_ra.hh: Fix cut n paste errors.
* olena/oln/core/abstract/pset.hh (piter): New vtype decl.
* olena/oln/core/gen/fwd_piter.hh (fwd_piter_): Add commented
forthcoming ctors.
* olena/oln/core/gen/bbox_topo.hh: Cosmetics.
* olena/oln/core/pset_entry.hh (piter_type): New.
* olena/oln/core/abstract/image.hh: Update.
2006-09-07 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Start the topology hierarchy.
......@@ -10,14 +42,17 @@
* oln/core/gen/bbox_topo.hh: New.
* oln/core/2d/aliases.hh (topo2d): New.
Add a new sub-hierarchy to abstract::pset.
* oln/core/abstract/pset_cnx.hh: New.
* oln/core/typedefs.hh (cnx_type): New.
* oln/core/abstract/pset_hierarchies.hh (pset_cnx_hierarchy): New.
* oln/core/abstract/bbox.hh (cnx_type): New.
* oln/core/abstract/pset_bboxed.hh (is_valid): Move this method into...
* oln/core/abstract/pset.hh (pset): ...this class.
* oln/core/pset_entry.hh
* oln/basics2d.hh
(dim): New vtype.
* oln/core/pset_entry.hh (single_vtype): Add vtype dim.
* oln/basics2d.hh: Include oln/core/gen/bbox_topo.hh.
2006-09-06 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
......
......@@ -32,13 +32,25 @@
# include <oln/core/2d/aliases.hh>
# include <oln/core/2d/point2d.hh>
namespace oln { template class point2d_<int>; }
# include <oln/core/2d/dpoint2d.hh>
namespace oln { template class dpoint2d_<int>; }
# include <oln/core/gen/bbox.hh>
namespace oln { template class bbox_<point2d>; }
# include <oln/core/gen/fwd_piter.hh>
namespace oln { template class fwd_piter_<point2d>; }
# include <oln/core/gen/bkd_piter.hh>
namespace oln { template class bkd_piter_<point2d>; }
# include <oln/core/gen/bbox_topo.hh>
namespace oln { template class bbox_topo_<point2d>; }
# include <oln/core/2d/image2d.hh>
#endif // ! OLENA_BASICS2D_HH
// Copyright (C) 2001, 2002, 2003, 2004, 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_2D_IMAGE2D_HH
# define OLENA_CORE_2D_IMAGE2D_HH
# include <oln/core/image_entry.hh>
namespace oln
{
// Forward declaration.
template <typename T> class image2d;
/// Virtual types associated to oln::image2d<T>.
template <typename T>
struct vtypes< image2d<T> >
{
typedef topo2d topo_type;
typedef grid2d grid_type;
typedef point2d point_type;
typedef fwd_piter2d fwd_piter_type;
typedef bkd_piter2d bkd_piter_type;
typedef T value_type;
typedef image2d<T> real_type;
};
/// Super type declaration.
template <typename T>
struct set_super_type< image2d<T> >
{
typedef image2d<T> self_t;
typedef image_entry<self_t> ret;
};
/// General 2D image class.
template <typename T>
class image2d : public image_entry< image2d<T> >
{
typedef image2d<T> self_t;
public:
/// Ctor.
image2d(unsigned nrows, unsigned ncols)
: topo_( bbox2d( point2d(0,0), point2d(nrows-1, ncols-1) ) )
{
}
const topo2d& impl_topo() const
{
return topo_;
}
T impl_op_read(const point2d& p) const
{
static T val_;
return ++val_;
}
bool impl_has(const point2d& p) const
{
return true;
}
private:
topo2d topo_;
};
} // end of namespace oln
#endif // ! OLENA_CORE_2D_IMAGE2D_HH
......@@ -57,6 +57,15 @@ namespace oln
// here: no other hierarchy
};
template < template <class> class abstraction,
typename E >
struct next_entry_node < abstraction, E, 1, mlc::false_ >
: public abstraction<E>
{
};
template < template <class> class abstraction,
typename E,
unsigned num >
......
This diff is collapsed.
......@@ -53,6 +53,8 @@ namespace oln
struct decl
{
stc_virtual_typedef(point);
stc_virtual_typedef(piter);
stc_virtual_typedef(fwd_piter);
stc_virtual_typedef(bkd_piter);
......
......@@ -54,16 +54,11 @@ namespace oln
decl() {
// constraint:
mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >,
mlc_is_a(bbox, abstract::bbox) > >::check();
// mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >,
// mlc_is_a(bbox, abstract::bbox) > >::check();
}
};
const oln_type_of(E, bbox)& bbox() const
{
return this->exact().impl_bbox();
}
protected:
topo()
......
......@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_PSET_RA_HH
# define OLENA_CORE_ABSTRACT_PSET_RA_HH
#ifndef OLENA_CORE_ABSTRACT_TOPO_RA_HH
# define OLENA_CORE_ABSTRACT_TOPO_RA_HH
# include <oln/core/abstract/pset.hh>
# include <oln/core/abstract/topo.hh>
......@@ -40,7 +40,7 @@ namespace oln
template <typename E>
class ra_pset : public virtual pset<E>
class ra_topo : public virtual topo<E>
{
typedef oln_type_of(E, point) point_t;
......@@ -52,7 +52,7 @@ namespace oln
}
protected:
ra_pset()
ra_topo()
{}
};
......@@ -61,14 +61,14 @@ namespace oln
template <typename E>
struct case_ < pset_ra_hierarchy, E, 1 >
struct case_ < topo_ra_hierarchy, E, 1 >
: where_< mlc::eq_< oln_type_of(E, ra), mlc::true_ > >
{
typedef abstract::ra_pset<E> ret;
typedef abstract::ra_topo<E> ret;
};
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_PSET_RA_HH
#endif // ! OLENA_CORE_ABSTRACT_TOPO_RA_HH
......@@ -48,7 +48,7 @@ namespace oln
// abstract
const bbox_t& bbox() const
{
return this->exact().impl_box();
return this->exact().impl_bbox();
}
// concrete
......
......@@ -28,8 +28,8 @@
#ifndef OLENA_CORE_GEN_BBOX_TOPO_HH
# define OLENA_CORE_GEN_BBOX_TOPO_HH
# include <oln/core/topo_entry.hh>
# include <oln/core/gen/bbox.hh>
# include <oln/core/topo_entry.hh>
......
......@@ -80,6 +80,23 @@ namespace oln
++nop_[0];
}
// template <typename T>
// fwd_piter_(const abstract::topo<T>& t)
// {
// mlc::assert_< mlc_is_a(T, abstract::topo_with_bbox) >::check();
// bb_ = t.exact().bbox();
// nop_ = bb_.pmax();
// ++nop_[0];
// }
// template <typename Data>
// fwd_piter_(const Data& data)
// : bb_(data.bbox())
// {
// nop_ = bb_.pmax();
// ++nop_[0];
// }
const bbox_<point>& bbox() const
{
return bb_;
......
// 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_IMAGE_ENTRY_HH
# define OLENA_CORE_IMAGE_ENTRY_HH
# include <oln/core/abstract/entry.hh>
# include <oln/core/abstract/image.hh>
namespace oln
{
/// Entry class for point sets: image_entry<E> is an alias for
/// entry< abstract::image, E>.
template <typename E>
struct image_entry : public entry< abstract::image, E>
{
protected:
image_entry() {}
};
/// Virtual types associated to image_entry<E>.
template <typename E>
struct vtypes< image_entry<E> >
{
typedef mlc::undefined topo_type;
typedef mlc::undefined grid_type;
// psite_type: see below
typedef mlc::undefined point_type;
// piter_type: see below
typedef mlc::undefined fwd_piter_type;
typedef mlc::undefined bkd_piter_type;
typedef mlc::undefined value_type;
// rvalue_type: see below
typedef mlc::undefined concrete_type;
};
template <typename E>
struct single_vtype< image_entry<E>, typedef_::psite_type >
{
typedef oln_type_of(E, point) ret;
};
template <typename E>
struct single_vtype< image_entry<E>, typedef_::piter_type >
{
typedef oln_type_of(E, fwd_piter) ret;
};
template <typename E>
struct single_vtype< image_entry<E>, typedef_::rvalue_type >
{
typedef oln_type_of(E, value) ret;
};
} // end of namespace oln
#endif // ! OLENA_CORE_IMAGE_ENTRY_HH
......@@ -54,6 +54,8 @@ namespace oln
struct vtypes< pset_entry<E> >
{
typedef mlc::undefined point_type;
typedef mlc::undefined piter_type;
typedef mlc::undefined fwd_piter_type;
typedef mlc::undefined bkd_piter_type;
......@@ -87,6 +89,13 @@ namespace oln
};
template <typename E>
struct single_vtype< pset_entry<E>, typedef_::piter_type >
{
typedef oln_type_of(E, fwd_piter) ret;
};
} // end of namespace oln
......
......@@ -30,12 +30,14 @@
# include <iostream>
# include <mlc/assert.hh>
# include <mlc/contract.hh>
# include <mlc/flags.hh>
# include <mlc/is_a.hh>
# include <mlc/cmp.hh>
# include <mlc/typedef.hh>
# include <mlc/value.hh>
# include <mlc/to_string.hh>
# include <stc/any.hh>
# include <stc/exact.hh>
......@@ -95,7 +97,7 @@ namespace oln
// mlc_decl_typedef(fwd_iter_type);
// mlc_decl_typedef(bkd_iter_type);
// mlc_decl_typedef(piter_type);
mlc_decl_typedef(piter_type);
mlc_decl_typedef(fwd_piter_type);
mlc_decl_typedef(bkd_piter_type);
......@@ -128,6 +130,7 @@ namespace oln
// mlc_decl_typedef(data_type);
// --------------------------------------------------------------------
mlc_decl_typedef(value_type);
mlc_decl_typedef(rvalue_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
......@@ -135,17 +138,19 @@ namespace oln
// mlc_decl_typedef(value_storage_type);
// mlc_decl_typedef(storage_type);
// --------------------------------------------------------------------
mlc_decl_typedef(psite_type);
mlc_decl_typedef(point_type);
mlc_decl_typedef(dpoint_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(image_type);
// mlc_decl_typedef(concrete_type);
// --------------------------------------------------------------------
mlc_decl_typedef(concrete_type);
mlc_decl_typedef(delegated_type);
mlc_decl_typedef(size_type);
mlc_decl_typedef(size_type); // FIXME: To be removed.
mlc_decl_typedef(topo_type);
mlc_decl_typedef(bbox_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
......
......@@ -11,9 +11,11 @@ AM_CPPFLAGS = \
check_PROGRAMS = \
grid \
image_entry
image_entry \
npoints
image_entry_SOURCES = image_entry.cc
grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
npoints_SOURCES = npoints.cc
TESTS = $(check_PROGRAMS)
// 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.
/// Test image2d.
#include <cassert>
#include <oln/basics2d.hh>
template <typename I>
unsigned npoints(const oln::abstract::image<I>& input)
{
oln_type_of(I, piter) p(input.topo());
unsigned count = 0;
for_all(p)
++count;
return count;
}
int
main()
{
oln::image2d<int> ima(3, 17);
assert(npoints(ima) == 51);
}
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