2006-09-07 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Start the topology hierarchy.
* oln/core/topo_entry.hh: New.
* oln/core/abstract/topo.hh: New.
* oln/core/abstract/topo_hierarchies.hh: New.
* oln/core/abstract/topo_with_bbox.hh: New.
* oln/core/abstract/topo_ra.hh: New.
* 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.
(dim): New vtype.
* oln/core/pset_entry.hh (single_vtype): Add vtype dim.
* oln/basics2d.hh: Include oln/core/gen/bbox_topo.hh.
Index: oln/core/topo_entry.hh
===================================================================
--- oln/core/topo_entry.hh (revision 0)
+++ oln/core/topo_entry.hh (revision 0)
@@ -0,0 +1,66 @@
+// 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_TOPO_ENTRY_HH
+# define OLENA_CORE_TOPO_ENTRY_HH
+
+# include <oln/core/abstract/entry.hh>
+# include <oln/core/abstract/topo.hh>
+
+
+
+namespace oln
+{
+
+
+ /// Entry class for point sets: topo_entry<E> is an alias for
+ /// entry< abstract::topo, E>.
+
+ template <typename E>
+ struct topo_entry : public entry< abstract::topo, E>
+ {
+ protected:
+ topo_entry() {}
+ };
+
+
+ /// Virtual types associated to topo_entry<E>.
+
+ template <typename E>
+ struct vtypes< topo_entry<E> >
+ {
+ typedef mlc::undefined bbox_type;
+ typedef mlc::undefined ra_type;
+
+ typedef mlc::undefined point_type;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_TOPO_ENTRY_HH
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 525)
+++ oln/core/typedefs.hh (working copy)
@@ -115,6 +115,7 @@
mlc_decl_typedef(fixed_type);
mlc_decl_typedef(ra_type);
+ mlc_decl_typedef(cnx_type);
/*------------------.
Index: oln/core/abstract/topo.hh
===================================================================
--- oln/core/abstract/topo.hh (revision 0)
+++ oln/core/abstract/topo.hh (revision 0)
@@ -0,0 +1,88 @@
+// 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_ABSTRACT_TOPO_HH
+# define OLENA_CORE_ABSTRACT_TOPO_HH
+
+# include <oln/core/typedefs.hh>
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ /// Abstract point class.
+ template <typename E>
+ class topo : public virtual stc::any__simple<E>,
+ public virtual oln::type
+ {
+ public:
+
+ struct decl
+ {
+ stc_virtual_typedef(bbox); // for being bboxed; provides .bbox()
+ stc_virtual_typedef(ra); // for random access; provides .has(p)
+
+ stc_virtual_typedef(point);
+
+ decl() {
+ // constraint:
+ 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()
+ {}
+
+ ~topo() { decl(); }
+
+ }; // end of class oln::abstract::topo<E>
+
+
+
+ } // end of namespace oln::abstract
+
+} // end of namespace oln
+
+
+
+# include <oln/core/abstract/topo_hierarchies.hh>
+
+
+
+#endif // ! OLENA_CORE_ABSTRACT_TOPO_HH
Index: oln/core/abstract/pset_hierarchies.hh
===================================================================
--- oln/core/abstract/pset_hierarchies.hh (revision 525)
+++ oln/core/abstract/pset_hierarchies.hh (working copy)
@@ -37,6 +37,7 @@
typedef hierarchy< abstract::pset, 1 > pset_fixed_hierarchy;
typedef hierarchy< abstract::pset, 2 > pset_ra_hierarchy;
typedef hierarchy< abstract::pset, 3 > pset_bboxed_hierarchy;
+ typedef hierarchy< abstract::pset, 4 > pset_cnx_hierarchy;
} // end of namespace oln
@@ -44,6 +45,7 @@
# include <oln/core/abstract/pset_fixed.hh>
# include <oln/core/abstract/pset_ra.hh>
# include <oln/core/abstract/pset_bboxed.hh>
+# include <oln/core/abstract/pset_cnx.hh>
Index: oln/core/abstract/pset_cnx.hh
===================================================================
--- oln/core/abstract/pset_cnx.hh (revision 0)
+++ oln/core/abstract/pset_cnx.hh (revision 0)
@@ -0,0 +1,83 @@
+// 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_ABSTRACT_PSET_CNX_HH
+# define OLENA_CORE_ABSTRACT_PSET_CNX_HH
+
+# include <oln/core/abstract/pset.hh>
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ template <typename E>
+ class cnx2d_pset : public virtual abstract::pset<E>
+ {
+ public:
+
+ unsigned nrows() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ unsigned ncols() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(1);
+ }
+
+ protected:
+
+ cnx2d_pset()
+ {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+
+ template <typename E>
+ struct case_ < pset_cnx_hierarchy, E, 1 >
+ : where_< mlc::and_list_< mlc::neq_< oln_type_of(E, bbox), mlc::none >,
+ mlc::eq_< oln_type_of(E, cnx), mlc::true_ >,
+ mlc::eq_< oln_type_of(E, grid), grid2d > > >
+ {
+ typedef abstract::cnx2d_pset<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_PSET_CNX_HH
+
Index: oln/core/abstract/topo_with_bbox.hh
===================================================================
--- oln/core/abstract/topo_with_bbox.hh (revision 0)
+++ oln/core/abstract/topo_with_bbox.hh (revision 0)
@@ -0,0 +1,81 @@
+// 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_ABSTRACT_TOPO_WITH_BBOX_HH
+# define OLENA_CORE_ABSTRACT_TOPO_WITH_BBOX_HH
+
+# include <oln/core/abstract/topo.hh>
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ template <typename E>
+ class topo_with_bbox : public virtual topo<E>
+ {
+ typedef oln_type_of(E, bbox) bbox_t;
+
+ public:
+
+ // abstract
+ const bbox_t& bbox() const
+ {
+ return this->exact().impl_box();
+ }
+
+ // concrete
+ operator bbox_t() const
+ {
+ return this->bbox();
+ }
+
+ protected:
+
+ topo_with_bbox()
+ {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+ template <typename E>
+ struct case_ < topo_with_bbox_hierarchy, E, 1 >
+ : where_< mlc::neq_< oln_type_of(E, bbox), mlc::none > >
+ {
+ typedef abstract::topo_with_bbox<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_TOPO_WITH_BBOX_HH
Index: oln/core/abstract/topo_hierarchies.hh
===================================================================
--- oln/core/abstract/topo_hierarchies.hh (revision 0)
+++ oln/core/abstract/topo_hierarchies.hh (revision 0)
@@ -0,0 +1,49 @@
+// 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_ABSTRACT_TOPO_HIERARCHIES_HH
+# define OLENA_CORE_ABSTRACT_TOPO_HIERARCHIES_HH
+
+# include <oln/core/abstract/topo.hh>
+
+
+namespace oln
+{
+
+ typedef hierarchy< abstract::topo, 1 > topo_ra_hierarchy;
+ typedef hierarchy< abstract::topo, 2 > topo_with_bbox_hierarchy;
+
+} // end of namespace oln
+
+
+# include <oln/core/abstract/topo_ra.hh>
+# include <oln/core/abstract/topo_with_bbox.hh>
+
+
+
+#endif // ! OLENA_CORE_ABSTRACT_TOPO_HIERARCHIES_HH
+
Index: oln/core/abstract/bbox.hh
===================================================================
--- oln/core/abstract/bbox.hh (revision 525)
+++ oln/core/abstract/bbox.hh (working copy)
@@ -53,6 +53,7 @@
{
typedef mlc::true_ ra_type;
typedef mlc::true_ fixed_type;
+ typedef mlc::true_ cnx_type;
typedef E bbox_type;
};
Index: oln/core/abstract/pset_bboxed.hh
===================================================================
--- oln/core/abstract/pset_bboxed.hh (revision 525)
+++ oln/core/abstract/pset_bboxed.hh (working copy)
@@ -55,11 +55,6 @@
return this->exact().impl_box();
}
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
const point_t& pmin() const
{
precondition(this->is_valid());
@@ -102,7 +97,6 @@
} // end of namespace oln::abstract
-
template <typename E>
struct case_ < pset_bboxed_hierarchy, E, 1 >
: where_< mlc::neq_< oln_type_of(E, bbox), mlc::none > >
@@ -115,4 +109,3 @@
#endif // ! OLENA_CORE_ABSTRACT_PSET_BBOXED_HH
-
Index: oln/core/abstract/topo_ra.hh
===================================================================
--- oln/core/abstract/topo_ra.hh (revision 0)
+++ oln/core/abstract/topo_ra.hh (revision 0)
@@ -0,0 +1,74 @@
+// 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_ABSTRACT_PSET_RA_HH
+# define OLENA_CORE_ABSTRACT_PSET_RA_HH
+
+# include <oln/core/abstract/pset.hh>
+
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ template <typename E>
+ class ra_pset : public virtual pset<E>
+ {
+ typedef oln_type_of(E, point) point_t;
+
+ public:
+
+ bool has(const point_t& p) const
+ {
+ return this->exact().impl_has(p);
+ }
+
+ protected:
+ ra_pset()
+ {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+ template <typename E>
+ struct case_ < pset_ra_hierarchy, E, 1 >
+ : where_< mlc::eq_< oln_type_of(E, ra), mlc::true_ > >
+ {
+ typedef abstract::ra_pset<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_PSET_RA_HH
Index: oln/core/abstract/pset.hh
===================================================================
--- oln/core/abstract/pset.hh (revision 525)
+++ oln/core/abstract/pset.hh (working copy)
@@ -45,7 +45,10 @@
{
public:
- // ...
+ bool is_valid() const
+ {
+ return this->exact().impl_is_valid();
+ }
struct decl
{
@@ -53,13 +56,15 @@
stc_virtual_typedef(fwd_piter);
stc_virtual_typedef(bkd_piter);
- stc_virtual_typedef(bbox);
- stc_virtual_typedef(ra);
- stc_virtual_typedef(fixed);
+ stc_virtual_typedef(bbox); // for being bboxed; provides .bbox()
+ stc_virtual_typedef(ra); // for random access; provides .has(p)
+ stc_virtual_typedef(fixed); // for fixed size; provides .npoints()
+ stc_virtual_typedef(cnx); // for connected; provides, e.g., .nrows()
// derived from point:
stc_virtual_typedef(coord);
stc_virtual_typedef(grid);
+ stc_virtual_typedef(dim);
decl() {
// coherence check:
Index: oln/core/2d/aliases.hh
===================================================================
--- oln/core/2d/aliases.hh (revision 525)
+++ oln/core/2d/aliases.hh (working copy)
@@ -38,6 +38,7 @@
template <typename C> class point2d_;
template <typename C> class dpoint2d_;
template <typename P> class bbox_;
+ template <typename P> class bbox_topo_;
template <typename P> class fwd_piter_;
template <typename P> class bkd_piter_;
class grid2d;
@@ -52,6 +53,7 @@
typedef bbox_<point2d> bbox2d;
typedef fwd_piter_<point2d> fwd_piter2d;
typedef bkd_piter_<point2d> bkd_piter2d;
+ typedef bbox_topo_<point2d> topo2d;
typedef point2d_<float> point2df;
typedef dpoint2d_<float> dpoint2df;
Index: oln/core/gen/bbox_topo.hh
===================================================================
--- oln/core/gen/bbox_topo.hh (revision 0)
+++ oln/core/gen/bbox_topo.hh (revision 0)
@@ -0,0 +1,95 @@
+// 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_GEN_BBOX_TOPO_HH
+# define OLENA_CORE_GEN_BBOX_TOPO_HH
+
+# include <oln/core/topo_entry.hh>
+# include <oln/core/gen/bbox.hh>
+
+
+
+namespace oln
+{
+
+
+ // Forward declarations.
+ template <typename point> class bbox_topo_;
+
+
+ // Super type declaration.
+ template <typename point>
+ struct set_super_type< bbox_topo_<point> >
+ {
+ typedef bbox_topo_<point> self_t;
+ typedef topo_entry<self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::bbox_<point>.
+ template <typename point>
+ struct vtypes< bbox_topo_<point> >
+ {
+ typedef bbox_<point> bbox_type;
+ typedef point point_type;
+ typedef mlc::true_ ra_type;
+ };
+
+
+ /// Bounding box topology based on a point class.
+ template <typename point>
+ class bbox_topo_ : public topo_entry< bbox_topo_<point> >
+ {
+ typedef bbox_<point> bbox_t;
+
+ public:
+
+ bbox_topo_()
+ {
+ }
+
+ bbox_topo_(const bbox_t& bb)
+ : bb_(bb)
+ {
+ }
+
+ const bbox_t& impl_bbox() const
+ {
+ return bb_;
+ }
+
+ protected:
+
+ bbox_<point> bb_;
+
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_GEN_BBOX_TOPO_HH
Index: oln/core/pset_entry.hh
===================================================================
--- oln/core/pset_entry.hh (revision 525)
+++ oln/core/pset_entry.hh (working copy)
@@ -79,6 +79,14 @@
};
+ template <typename E>
+ struct single_vtype< pset_entry<E>, typedef_::dim_type >
+ {
+ typedef oln_type_of(E, point) P;
+ typedef oln_type_of(P, dim) ret;
+ };
+
+
} // end of namespace oln
Index: oln/basics2d.hh
===================================================================
--- oln/basics2d.hh (revision 525)
+++ oln/basics2d.hh (working copy)
@@ -38,5 +38,7 @@
# include <oln/core/gen/fwd_piter.hh>
# include <oln/core/gen/bkd_piter.hh>
+# include <oln/core/gen/bbox_topo.hh>
+
#endif // ! OLENA_BASICS2D_HH