Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
09 Oct '06
2006-10-09 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Separate definition code from declaration code in olena.
* oln/core/type.hh: Split code.
* oln/core/point_set_entry.hh: Likewise.
* oln/core/automatic/image.hh: Likewise.
* oln/core/automatic/topology_having_bbox.hh: Likewise.
* oln/core/automatic/image_being_random_accessible.hh: Likewise.
* oln/core/automatic/image_having_neighborhood.hh: Likewise.
* oln/core/automatic/topology_being_random_accessible.hh: Likewise.
* oln/core/automatic/topology_having_subset.hh: Likewise.
* oln/core/automatic/image_being_mutable.hh: Likewise.
* oln/core/automatic/topology_having_neighborhood.hh: Likewise.
* oln/core/neighborhood_entry.hh: Likewise.
* oln/core/topology_entry.hh: Likewise.
* oln/core/image_entry.hh: Likewise.
* oln/core/abstract/iterator_on_points.hh: Likewise.
* oln/core/abstract/topology_having_bbox.hh: Likewise.
* oln/core/abstract/image.hh: Likewise.
* oln/core/abstract/image/type/binary.hh: Likewise.
* oln/core/abstract/image/type/data.hh: Likewise.
* oln/core/abstract/image/type/grey_level.hh: Likewise.
* oln/core/abstract/image/type/color.hh: Likewise.
* oln/core/abstract/image/type/label.hh: Likewise.
* oln/core/abstract/image/hybrid/classical.hh: Likewise.
* oln/core/abstract/image/mutability/hierarchy.hh: Likewise.
* oln/core/abstract/image/dimension/2d.hh: Likewise.
* oln/core/abstract/image/neighborhood/hierarchy.hh: Likewise.
* oln/core/abstract/image/accessibility/hierarchy.hh: Likewise.
* oln/core/abstract/image/bbox/hierarchy.hh: Likewise.
* oln/core/abstract/point_set_being_random_accessible.hh: Likewise.
* oln/core/abstract/grid.hh: Likewise.
* oln/core/abstract/iterator.hh: Likewise.
* oln/core/abstract/point.hh: Likewise.
* oln/core/abstract/bbox.hh: Likewise.
* oln/core/abstract/point_set_being_connected.hh: Likewise.
* oln/core/abstract/dpoint.hh: Likewise.
* oln/core/abstract/topology_being_random_accessible.hh: Likewise.
* oln/core/abstract/topology_having_subset.hh: Likewise.
* oln/core/abstract/topology_having_neighborhood.hh: Likewise.
* oln/core/abstract/entry.hh: Likewise.
* oln/core/abstract/point_set.hh: Likewise.
* oln/core/abstract/point_set_having_known_size.hh: Likewise.
* oln/core/abstract/neighborhood.hh: Likewise.
* oln/core/abstract/point_set_having_bbox.hh: Likewise.
* oln/core/abstract/topology.hh: Likewise.
* oln/core/2d/neighb2d.hh: Likewise.
* oln/core/2d/dpoint2d.hh: Likewise.
* oln/core/2d/array2d.hh: Likewise.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/2d/point2d.hh: Likewise.
* oln/core/gen/piter_isubset.hh: Likewise.
* oln/core/gen/topo_add_isubset.hh: Likewise.
* oln/core/gen/bbox.hh: Likewise.
* oln/core/gen/topo_bbox.hh: Likewise.
* oln/core/gen/neighb.hh: Likewise.
* oln/core/gen/fwd_piter_bbox.hh: Likewise.
* oln/core/gen/bbox_fwd_piter.hh: Likewise.
* oln/core/gen/fwd_niter_neighb.hh: Likewise.
* oln/core/gen/fwd_qiter_win.hh: Likewise.
* oln/core/gen/topo_lbbox.hh: Likewise.
* oln/core/gen/window.hh: Likewise.
* oln/core/gen/bbox_bkd_piter.hh: Likewise.
* oln/core/gen/bkd_piter_bbox.hh: Likewise.
* oln/core/gen/topo_add_nbh.hh: Likewise.
* oln/core/gen/mapimage.hh: Likewise.
* oln/core/internal/tracked_ptr.hh: Likewise.
* oln/core/internal/topology_morpher.hh: Likewise.
* oln/core/internal/point_nd.hh: Likewise.
* oln/core/internal/bbox_bkd_piter.hh: Likewise.
* oln/core/internal/bbox_fwd_piter.hh: Likewise.
* oln/core/internal/dpoint_nd.hh: Likewise.
* oln/basics2d.hh: Likewise.
* oln/morpher/add_isubset.hh: Likewise.
* oln/morpher/identity.hh: Likewise.
* oln/morpher/internal/image_extension.hh: Likewise.
* oln/morpher/add_neighborhood.hh: Likewise.
Index: oln/core/type.hh
===================================================================
--- oln/core/type.hh (revision 606)
+++ oln/core/type.hh (working copy)
@@ -35,9 +35,18 @@
struct type
{
protected:
- type() {}
+ type();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ type::type()
+ {
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/point_set_entry.hh
===================================================================
--- oln/core/point_set_entry.hh (revision 606)
+++ oln/core/point_set_entry.hh (working copy)
@@ -44,10 +44,21 @@
struct point_set_entry : public entry< abstract::point_set, E>
{
protected:
- point_set_entry() {}
+ point_set_entry();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ point_set_entry<E>::point_set_entry()
+ {
+ }
+
+# endif
+
+
/// Virtual types associated to point_set_entry<E>.
template <typename E>
Index: oln/core/automatic/image.hh
===================================================================
--- oln/core/automatic/image.hh (revision 606)
+++ oln/core/automatic/image.hh (working copy)
@@ -61,18 +61,30 @@
/// Delegation.
- const topo_t& impl_topo() const
- {
- return this->exact().delegate().topo();
- }
+ const topo_t& impl_topo() const;
+ rvalue_t impl_op_read(const psite_t& p) const;
- rvalue_t impl_op_read(const psite_t& p) const
- {
- return this->exact().delegate().operator()(p);
- }
-
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const typename set_impl<abstract::image, morpher::tag::identity, E>::topo_t&
+ set_impl<abstract::image, morpher::tag::identity, E>::impl_topo() const
+ {
+ return this->exact().delegate().topo();
+ }
+
+ template <typename E>
+ typename set_impl<abstract::image, morpher::tag::identity, E>::rvalue_t
+ set_impl<abstract::image, morpher::tag::identity, E>::impl_op_read(const typename set_impl<abstract::image, morpher::tag::identity, E>::psite_t& p) const
+ {
+ return this->exact().delegate().operator()(p);
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/automatic/topology_having_bbox.hh
===================================================================
--- oln/core/automatic/topology_having_bbox.hh (revision 606)
+++ oln/core/automatic/topology_having_bbox.hh (working copy)
@@ -60,13 +60,22 @@
public:
- const bbox_t& impl_bbox() const
- {
- return this->exact().delegate().bbox();
- }
+ const bbox_t& impl_bbox() const;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const typename set_impl< abstract::topology_having_bbox, morpher::tag::identity, E >::bbox_t&
+ set_impl< abstract::topology_having_bbox, morpher::tag::identity, E >::impl_bbox() const
+ {
+ return this->exact().delegate().bbox();
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/automatic/image_being_random_accessible.hh
===================================================================
--- oln/core/automatic/image_being_random_accessible.hh (revision 606)
+++ oln/core/automatic/image_being_random_accessible.hh (working copy)
@@ -59,19 +59,30 @@
public:
- bool impl_has(const point_t& p) const
- {
- return this->exact().topo().has(p);
- }
+ bool impl_has(const point_t& p) const;
+ bool impl_has_large(const point_t& p) const;
- bool impl_has_large(const point_t& p) const
- {
- return this->exact().has(p);
- }
-
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E, typename M>
+ bool
+ set_impl<abstract::image_being_random_accessible, M, E>::impl_has(const typename set_impl<abstract::image_being_random_accessible, M, E>::point_t& p) const
+ {
+ return this->exact().topo().has(p);
+ }
+
+ template <typename E, typename M>
+ bool
+ set_impl<abstract::image_being_random_accessible, M, E>::impl_has_large(const typename set_impl<abstract::image_being_random_accessible, M, E>::point_t& p) const
+ {
+ return this->exact().has(p);
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/automatic/image_having_neighborhood.hh
===================================================================
--- oln/core/automatic/image_having_neighborhood.hh (revision 606)
+++ oln/core/automatic/image_having_neighborhood.hh (working copy)
@@ -57,12 +57,21 @@
public:
/// Accessor delegation.
- const neighborhood_t& impl_neighborhood() const
- {
- return this->exact().delegate().neighborhood();
- }
+ const neighborhood_t& impl_neighborhood() const;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const typename set_impl< abstract::image_having_neighborhood, morpher::tag::identity, E>::neighborhood_t&
+ set_impl< abstract::image_having_neighborhood, morpher::tag::identity, E>::impl_neighborhood() const
+ {
+ return this->exact().delegate().neighborhood();
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/automatic/topology_being_random_accessible.hh
===================================================================
--- oln/core/automatic/topology_being_random_accessible.hh (revision 606)
+++ oln/core/automatic/topology_being_random_accessible.hh (working copy)
@@ -61,18 +61,29 @@
public:
- bool impl_has(const point_t& p) const
- {
- return this->exact().delegate().has(p);
- }
+ bool impl_has(const point_t& p) const;
+ bool impl_has_large(const point_t& p) const;
- bool impl_has_large(const point_t& p) const
- {
- return this->exact().delegate().has_large(p);
- }
-
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool
+ set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::impl_has(const typename set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::point_t& p) const
+ {
+ return this->exact().delegate().has(p);
+ }
+
+ bool
+ set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::impl_has_large(const typename set_impl< abstract::topology_being_random_accessible, morpher::tag::identity, E>::point_t& p) const
+ {
+ return this->exact().delegate().has_large(p);
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/automatic/topology_having_subset.hh
===================================================================
--- oln/core/automatic/topology_having_subset.hh (revision 607)
+++ oln/core/automatic/topology_having_subset.hh (working copy)
@@ -60,13 +60,22 @@
public:
- const subset_t& impl_subset() const
- {
- return this->exact().delegate().subset();
- }
+ const subset_t& impl_subset() const;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const typename set_impl< abstract::topology_having_subset, morpher::tag::identity, E >::subset_t&
+ set_impl< abstract::topology_having_subset, morpher::tag::identity, E >::impl_subset() const
+ {
+ return this->exact().delegate().subset();
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/automatic/image_being_mutable.hh
===================================================================
--- oln/core/automatic/image_being_mutable.hh (revision 606)
+++ oln/core/automatic/image_being_mutable.hh (working copy)
@@ -56,12 +56,20 @@
public:
/// Accessor delegation.
- lvalue_t& impl_op_readwrite(const psite_t& p) const
- {
- return this->exact().delegate().operator()(p);
- }
+ lvalue_t& impl_op_readwrite(const psite_t& p) const;
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ typename set_impl<abstract::image_being_mutable, morpher::tag::identity, E>::lvalue_t&
+ set_impl<abstract::image_being_mutable, morpher::tag::identity, E>::impl_op_readwrite(const typename set_impl<abstract::image_being_mutable, morpher::tag::identity, E>::psite_t& p) const
+ {
+ return this->exact().delegate().operator()(p);
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/automatic/topology_having_neighborhood.hh
===================================================================
--- oln/core/automatic/topology_having_neighborhood.hh (revision 606)
+++ oln/core/automatic/topology_having_neighborhood.hh (working copy)
@@ -60,13 +60,22 @@
public:
- const neighborhood_t& impl_neighborhood() const
- {
- return this->exact().delegate().neighborhood();
- }
+ const neighborhood_t& impl_neighborhood() const;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const typename set_impl< abstract::topology_having_neighborhood, morpher::tag::identity, E >::neighborhood_t&
+ set_impl< abstract::topology_having_neighborhood, morpher::tag::identity, E >::impl_neighborhood() const
+ {
+ return this->exact().delegate().neighborhood();
+ }
+
+# endif
+
} // end of namespace oln::automatic
} // end of namespace oln
Index: oln/core/neighborhood_entry.hh
===================================================================
--- oln/core/neighborhood_entry.hh (revision 606)
+++ oln/core/neighborhood_entry.hh (working copy)
@@ -44,10 +44,20 @@
struct neighborhood_entry : public entry< abstract::neighborhood, E>
{
protected:
- neighborhood_entry() {}
+ neighborhood_entry();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ neighborhood_entry<E>::neighborhood_entry()
+ {
+ }
+
+# endif
+
+
/// Virtual types associated to neighborhood_entry<E>.
template <typename E>
Index: oln/core/topology_entry.hh
===================================================================
--- oln/core/topology_entry.hh (revision 607)
+++ oln/core/topology_entry.hh (working copy)
@@ -44,10 +44,20 @@
struct topology_entry : public entry< abstract::topology, E>
{
protected:
- topology_entry() {}
+ topology_entry();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ topology_entry<E>::topology_entry()
+ {
+ }
+
+# endif
+
+
/// Virtual types associated to topology_entry<E>.
template <typename E>
Index: oln/core/image_entry.hh
===================================================================
--- oln/core/image_entry.hh (revision 607)
+++ oln/core/image_entry.hh (working copy)
@@ -44,10 +44,21 @@
struct image_entry : public entry<abstract::image, E>
{
protected:
- image_entry() {}
+ image_entry();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ image_entry<E>::image_entry()
+ {
+ }
+
+# endif
+
+
+
/// Virtual types associated to image_entry<E>.
template <typename E>
Index: oln/core/abstract/iterator_on_points.hh
===================================================================
--- oln/core/abstract/iterator_on_points.hh (revision 606)
+++ oln/core/abstract/iterator_on_points.hh (working copy)
@@ -68,39 +68,63 @@
public:
- point_t to_point() const
- {
- precondition(this->is_valid());
- return this->exact().impl_to_point();
- }
+ point_t to_point() const;
- const point_t* point_adr() const
- {
- return this->exact().impl_point_adr();
- }
+ const point_t* point_adr() const;
// Concrete method.
- operator point_t() const
- {
- precondition(this->is_valid());
- return this->to_point();
- }
+ operator point_t() const;
protected:
- iterator_on_points()
- {
- }
+ iterator_on_points();
- ~iterator_on_points()
- {
- mlc::assert_defined_< point_t >::check();
- mlc::assert_< mlc_is_a(point_t, abstract::point) >::check();
- }
+ ~iterator_on_points();
}; // end of class oln::abstract::iterator_on_points<E>
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ typename iterator_on_points<E>::point_t
+ iterator_on_points<E>::to_point() const
+ {
+ precondition(this->is_valid());
+ return this->exact().impl_to_point();
+ }
+
+ template <typename E>
+ const typename iterator_on_points<E>::point_t*
+ iterator_on_points<E>::point_adr() const
+ {
+ return this->exact().impl_point_adr();
+ }
+
+ template <typename E>
+ // Concrete method.
+ iterator_on_points<E>::operator typename iterator_on_points<E>::point_t() const
+ {
+ precondition(this->is_valid());
+ return this->to_point();
+ }
+
+ template <typename E>
+ iterator_on_points<E>::iterator_on_points()
+ {
+ }
+
+ template <typename E>
+ iterator_on_points<E>::~iterator_on_points()
+ {
+ mlc::assert_defined_< typename iterator_on_points<E>::point_t >::check();
+ mlc::assert_< mlc_is_a(typename iterator_on_points<E>::point_t, abstract::point) >::check();
+ }
+
+
+# endif
+
} // end of namespace oln::abstract
Index: oln/core/abstract/topology_having_bbox.hh
===================================================================
--- oln/core/abstract/topology_having_bbox.hh (revision 606)
+++ oln/core/abstract/topology_having_bbox.hh (working copy)
@@ -48,30 +48,50 @@
public:
// abstract
- const bbox_t& bbox() const
- {
- return this->exact().impl_bbox();
- }
+ const bbox_t& bbox() const;
// abstract
- bbox_t& bbox()
- {
- return this->exact().impl_bbox();
- }
+ bbox_t& bbox();
// concrete
- operator bbox_t() const
- {
- return this->bbox();
- }
+ operator bbox_t() const;
protected:
- topology_having_bbox()
- {}
+ topology_having_bbox();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const oln_type_of(E, bbox)&
+ topology_having_bbox<E>::bbox() const
+ {
+ return this->exact().impl_bbox();
+ }
+
+ template <typename E>
+ oln_type_of(E, bbox)&
+ topology_having_bbox<E>::bbox()
+ {
+ return this->exact().impl_bbox();
+ }
+
+ template <typename E>
+ topology_having_bbox<E>::operator oln_type_of(E, bbox)() const
+ {
+ return this->bbox();
+ }
+
+ template <typename E>
+ topology_having_bbox<E>::topology_having_bbox()
+ {
+ }
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 606)
+++ oln/core/abstract/image.hh (working copy)
@@ -63,33 +63,24 @@
struct decl
{
- stc_virtual_typedef(topo);
- stc_virtual_typedef(grid);
+// stc_virtual_typedef(topo);
+// stc_virtual_typedef(grid);
- stc_virtual_typedef(psite);
- stc_virtual_typedef(point);
+// stc_virtual_typedef(psite);
+// stc_virtual_typedef(point);
- stc_virtual_typedef(piter);
- stc_virtual_typedef(fwd_piter);
- stc_virtual_typedef(bkd_piter);
+// // stc_virtual_typedef(piter);
+// // stc_virtual_typedef(fwd_piter);
+// // stc_virtual_typedef(bkd_piter);
- stc_virtual_typedef(value);
- stc_virtual_typedef(rvalue);
+// stc_virtual_typedef(value);
+// stc_virtual_typedef(rvalue);
- stc_virtual_typedef(concrete);
+// stc_virtual_typedef(concrete);
- stc_virtual_typedef(morpher);
+// stc_virtual_typedef(morpher);
- decl()
- {
- mlc::assert_< mlc_is_a(topo, abstract::topology) >::check();
- mlc::assert_< mlc_is_a(grid, abstract::grid) >::check();
- mlc::assert_< mlc_is_a(piter, abstract::iterator_on_points) >::check();
- mlc::assert_< mlc_is_a(fwd_piter, abstract::iterator_on_points) >::check();
- mlc::assert_< mlc_is_a(bkd_piter, abstract::iterator_on_points) >::check();
- // FIXME: Rec.
- // mlc::assert_< mlc_is_a(concrete, abstract::image) >::check();
- }
+ decl();
};
@@ -116,34 +107,71 @@
** topo2d.
*/
- const topo_t& topo() const
- {
- return this->exact().impl_topo();
- }
+ const topo_t& topo() const;
/*! \brief Gives access to the value stored at \a p in the
** current image.
*/
- rvalue_t operator()(const psite_t& p) const
- {
- return this->exact().impl_op_read(p);
- }
+ rvalue_t operator()(const psite_t& p) const;
protected:
/*! \brief Constructor (protected, empty).
*/
- image() {}
+ image();
/*! \brief Destructor.
*/
- virtual ~image() { decl(); }
+ virtual ~image();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ image<E>::decl::decl()
+ {
+// mlc::assert_< mlc_is_a(topo, abstract::topology) >::check();
+// mlc::assert_< mlc_is_a(grid, abstract::grid) >::check();
+// mlc::assert_< mlc_is_a(piter, abstract::iterator_on_points) >::check();
+// mlc::assert_< mlc_is_a(fwd_piter, abstract::iterator_on_points) >::check();
+// mlc::assert_< mlc_is_a(bkd_piter, abstract::iterator_on_points) >::check();
+ // FIXME: Rec.
+ // mlc::assert_< mlc_is_a(concrete, abstract::image) >::check();
+ }
+
+ template <typename E>
+ image<E>::image()
+ {
+ }
+
+ template <typename E>
+ image<E>::~image()
+ {
+ decl();
+ }
+
+ template <typename E>
+ const typename image<E>::topo_t&
+ image<E>::topo() const
+ {
+ return this->exact().impl_topo();
+ }
+
+ template <typename E>
+ typename image<E>::rvalue_t
+ image<E>::operator()(const typename image<E>::psite_t& p) const
+ {
+ return this->exact().impl_op_read(p);
+ }
+
+# endif
+
+
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/image/type/binary.hh
===================================================================
--- oln/core/abstract/image/type/binary.hh (revision 606)
+++ oln/core/abstract/image/type/binary.hh (working copy)
@@ -45,9 +45,19 @@
{
protected:
/// Constructor (protected, empty).
- binary_image() {}
+ binary_image();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ binary_image<E>::binary_image()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/image/type/data.hh
===================================================================
--- oln/core/abstract/image/type/data.hh (revision 606)
+++ oln/core/abstract/image/type/data.hh (working copy)
@@ -43,9 +43,18 @@
{
protected:
/// Constructor (protected, empty).
- data_image() {}
+ data_image();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ data_image<E>::data_image()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/image/type/grey_level.hh
===================================================================
--- oln/core/abstract/image/type/grey_level.hh (revision 606)
+++ oln/core/abstract/image/type/grey_level.hh (working copy)
@@ -49,9 +49,18 @@
{
protected:
/// Constructor (protected, empty).
- grey_level_image() {}
+ grey_level_image();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ grey_level_image<E>::grey_level_image()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/image/type/color.hh
===================================================================
--- oln/core/abstract/image/type/color.hh (revision 606)
+++ oln/core/abstract/image/type/color.hh (working copy)
@@ -43,9 +43,18 @@
{
protected:
/// Constructor (protected, empty).
- color_image() {}
+ color_image();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ color_image<E>::color_image()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/image/type/label.hh
===================================================================
--- oln/core/abstract/image/type/label.hh (revision 606)
+++ oln/core/abstract/image/type/label.hh (working copy)
@@ -45,9 +45,18 @@
{
protected:
/// Constructor (protected, empty).
- label_image() {}
+ label_image();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ label_image<E>::label_image()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/image/hybrid/classical.hh
===================================================================
--- oln/core/abstract/image/hybrid/classical.hh (revision 606)
+++ oln/core/abstract/image/hybrid/classical.hh (working copy)
@@ -47,8 +47,7 @@
public virtual abstract::image_being_random_accessible<E>
{
protected:
- classical_image()
- {}
+ classical_image();
};
template <typename E>
@@ -57,10 +56,24 @@
public virtual abstract::image2d<E>
{
protected:
- classical_2d_image()
- {}
+ classical_2d_image();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ classical_image<E>::classical_image()
+ {
+ }
+
+ template <typename E>
+ classical_2d_image<E>::classical_2d_image()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
Index: oln/core/abstract/image/mutability/hierarchy.hh
===================================================================
--- oln/core/abstract/image/mutability/hierarchy.hh (revision 606)
+++ oln/core/abstract/image/mutability/hierarchy.hh (working copy)
@@ -37,8 +37,8 @@
{
/*-------------------------.
- | Dimension abstractions. |
- `-------------------------*/
+ | Dimension abstractions. |
+ `-------------------------*/
namespace abstract
{
@@ -67,27 +67,47 @@
using image<E>::operator();
- lvalue_t& operator()(const psite_t& p)
- {
- return this->exact().impl_op_readwrite(p);
- }
+ lvalue_t& operator()(const psite_t& p);
protected:
/// Constructor (protected, empty).
- image_being_mutable() {}
+ image_being_mutable();
/// Destructor (protected).
- ~image_being_mutable() { decl(); }
+ ~image_being_mutable();
};
-
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ typename image_being_mutable<E>::lvalue_t&
+ image_being_mutable<E>::operator()(const typename image_being_mutable<E>::psite_t& p)
+ {
+ return this->exact().impl_op_readwrite(p);
+ }
+
+ template <typename E>
+ image_being_mutable<E>::image_being_mutable()
+ {
+ }
+
+ template <typename E>
+ image_being_mutable<E>::~image_being_mutable()
+ {
+ decl();
+ }
+
+# endif
+
} // end of namespace oln::abstract
/*-------------------.
- | Dimension switch. |
- `-------------------*/
+ | Dimension switch. |
+ `-------------------*/
/// With mutability.
template <typename E>
Index: oln/core/abstract/image/dimension/2d.hh
===================================================================
--- oln/core/abstract/image/dimension/2d.hh (revision 606)
+++ oln/core/abstract/image/dimension/2d.hh (working copy)
@@ -45,8 +45,18 @@
{
protected:
/// Constructor (protected, empty).
- image2d() {}
+ image2d();
};
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ image2d<E>::image2d()
+ {
+ }
+
+# endif
} // end of namespace oln::abstract
Index: oln/core/abstract/image/neighborhood/hierarchy.hh
===================================================================
--- oln/core/abstract/image/neighborhood/hierarchy.hh (revision 607)
+++ oln/core/abstract/image/neighborhood/hierarchy.hh (working copy)
@@ -70,20 +70,41 @@
stc_virtual_typedef(bkd_niter);
};
- const neighborhood_t& neighborhood() const
- {
- return this->topo().neighborhood();
- }
+ const neighborhood_t& neighborhood() const;
protected:
/// Constructor (protected, empty).
- image_having_neighborhood() {}
+ image_having_neighborhood();
/// Destructor (protected).
- ~image_having_neighborhood() { decl(); }
+ ~image_having_neighborhood();
};
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const typename image_having_neighborhood<E>::neighborhood_t&
+ image_having_neighborhood<E>::neighborhood() const
+ {
+ return this->topo().neighborhood();
+ }
+
+ template <typename E>
+ image_having_neighborhood<E>::image_having_neighborhood()
+ {
+ }
+
+ template <typename E>
+ image_having_neighborhood<E>::~image_having_neighborhood()
+ {
+ decl();
+ }
+
+# endif
} // end of namespace oln::abstract
Index: oln/core/abstract/image/accessibility/hierarchy.hh
===================================================================
--- oln/core/abstract/image/accessibility/hierarchy.hh (revision 606)
+++ oln/core/abstract/image/accessibility/hierarchy.hh (working copy)
@@ -53,22 +53,39 @@
public:
// Abstract method.
- bool has(const point_t& p) const
- {
- return this->exact().impl_has(p);
- }
+ bool has(const point_t& p) const;
// Abstract method.
- bool has_large(const point_t& p) const
- {
- return this->exact().impl_has_large(p);
- }
+ bool has_large(const point_t& p) const;
protected:
/// Constructor (protected, empty).
- image_being_random_accessible() {}
+ image_being_random_accessible();
};
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool image_being_random_accessible<E>::has(const typename image_being_random_accessible<E>::point_t& p) const
+ {
+ return this->exact().impl_has(p);
+ }
+
+ template <typename E>
+ bool image_being_random_accessible<E>::has_large(const typename image_being_random_accessible<E>::point_t& p) const
+ {
+ return this->exact().impl_has_large(p);
+ }
+
+ template <typename E>
+ image_being_random_accessible<E>::image_being_random_accessible()
+ {
+ }
+
+# endif
} // end of namespace oln::abstract
Index: oln/core/abstract/image/bbox/hierarchy.hh
===================================================================
--- oln/core/abstract/image/bbox/hierarchy.hh (revision 606)
+++ oln/core/abstract/image/bbox/hierarchy.hh (working copy)
@@ -36,8 +36,8 @@
{
/*-------------------------.
- | Dimension abstractions. |
- `-------------------------*/
+ | Dimension abstractions. |
+ `-------------------------*/
namespace abstract
{
@@ -59,45 +59,76 @@
{
stc_virtual_typedef(bbox);
- decl()
- {
- mlc::assert_< mlc_is_a(bbox, abstract::bbox) >::check();
- }
+ decl();
};
// Concrete method.
- const bbox_t& bbox() const
- {
- return this->topo().bbox();
- }
+ const bbox_t& bbox() const;
// Concrete method.
- const point_t& pmin() const
- {
- return this->topo().bbox().pmin();
- }
+ const point_t& pmin() const;
// Concrete method.
- const point_t& pmax() const
- {
- return this->topo().bbox().pmax();
- }
+ const point_t& pmax() const;
protected:
/// Constructor (protected, empty).
+ image_having_bbox();
- image_having_bbox() {}
/// Destructor.
- virtual ~image_having_bbox() { decl(); }
+ virtual ~image_having_bbox();
};
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ image_having_bbox<E>::decl::decl()
+ {
+ mlc::assert_< mlc_is_a(bbox, abstract::bbox) >::check();
+ }
+
+ template <typename E>
+ const typename image_having_bbox<E>::bbox_t&
+ image_having_bbox<E>::bbox() const
+ {
+ return this->topo().bbox();
+ }
+
+ template <typename E>
+ const typename image_having_bbox<E>::point_t&
+ image_having_bbox<E>::pmin() const
+ {
+ return this->topo().bbox().pmin();
+ }
+
+ template <typename E>
+ const typename image_having_bbox<E>::point_t&
+ image_having_bbox<E>::pmax() const
+ {
+ return this->topo().bbox().pmax();
+ }
+
+ template <typename E>
+ image_having_bbox<E>::image_having_bbox()
+ {
+ }
+
+ template <typename E>
+ image_having_bbox<E>::~image_having_bbox()
+ {
+ decl();
+ }
+
+# endif
} // end of namespace oln::abstract
/*-------------------.
- | Dimension switch. |
- `-------------------*/
+ | Dimension switch. |
+ `-------------------*/
/// With bbox.
template <typename E>
Index: oln/core/abstract/point_set_being_random_accessible.hh
===================================================================
--- oln/core/abstract/point_set_being_random_accessible.hh (revision 606)
+++ oln/core/abstract/point_set_being_random_accessible.hh (working copy)
@@ -46,17 +46,29 @@
public:
- bool has(const point_t& p) const
- {
- return this->exact().impl_has(p);
- }
+ bool has(const point_t& p) const;
protected:
- point_set_being_random_accessible()
- {}
+ point_set_being_random_accessible();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool point_set_being_random_accessible<E>::has(const point_t& p) const
+ {
+ return this->exact().impl_has(p);
+ }
+
+ template <typename E>
+ point_set_being_random_accessible<E>::point_set_being_random_accessible()
+ {
+ }
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/grid.hh
===================================================================
--- oln/core/abstract/grid.hh (revision 606)
+++ oln/core/abstract/grid.hh (working copy)
@@ -52,10 +52,19 @@
struct grid : public virtual stc::any__simple<E>
{
protected:
- grid()
- {}
+ grid();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ grid<E>::grid()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/iterator.hh
===================================================================
--- oln/core/abstract/iterator.hh (revision 606)
+++ oln/core/abstract/iterator.hh (working copy)
@@ -46,36 +46,56 @@
{
public:
- void start()
- {
- this->exact().impl_start();
- }
+ void start();
- void next()
- {
- precondition(this->is_valid());
- this->exact().impl_next();
- }
+ void next();
- void invalidate()
- {
- this->exact().impl_invalidate();
- }
+ void invalidate();
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
+ bool is_valid() const;
protected:
- iterator()
- {
- }
+ iterator();
}; // end of class oln::abstract::iterator<E>
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ void iterator<E>::start()
+ {
+ this->exact().impl_start();
+ }
+
+ template <typename E>
+ void iterator<E>::next()
+ {
+ precondition(this->is_valid());
+ this->exact().impl_next();
+ }
+
+ template <typename E>
+ void iterator<E>::invalidate()
+ {
+ this->exact().impl_invalidate();
+ }
+
+ template <typename E>
+ bool iterator<E>::is_valid() const
+ {
+ return this->exact().impl_is_valid();
+ }
+
+ template <typename E>
+ iterator<E>::iterator()
+ {
+ }
+
+# endif
+
} // end of namespace oln::abstract
Index: oln/core/abstract/point.hh
===================================================================
--- oln/core/abstract/point.hh (revision 606)
+++ oln/core/abstract/point.hh (working copy)
@@ -71,7 +71,6 @@
class point : public stc::any__simple<E>,
public oln::type
{
- typedef E exact_t;
typedef oln_type_of(E, dpoint) dpoint_t;
public:
@@ -80,19 +79,10 @@
/// \{
/// Operator ==.
- bool operator==(const exact_t& rhs) const
- {
- return this->exact().impl_equal(rhs);
- }
+ bool operator==(const E& rhs) const;
template <typename P>
- bool operator==(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_equal(rhs.exact());
- }
+ bool operator==(const abstract::point<P>& rhs) const;
/// \}
@@ -100,19 +90,10 @@
/// \{
/// Operator !=.
- bool operator!=(const exact_t& rhs) const
- {
- return not (*this == rhs);
- }
+ bool operator!=(const E& rhs) const;
template <typename P>
- bool operator!=(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return not (*this == rhs);
- }
+ bool operator!=(const abstract::point<P>& rhs) const;
/// \}
@@ -120,19 +101,10 @@
/// \{
/// Operator <.
- bool operator<(const exact_t& rhs) const
- {
- return this->exact().impl_less(rhs);
- }
+ bool operator<(const E& rhs) const;
template <typename P>
- bool operator<(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_less(rhs.exact());
- }
+ bool operator<(const abstract::point<P>& rhs) const;
/// \}
@@ -140,19 +112,10 @@
/// \{
/// Operator >.
- bool operator>(const exact_t& rhs) const
- {
- return rhs < *this;
- }
+ bool operator>(const E& rhs) const;
template <typename P>
- bool operator>(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return rhs < *this;
- }
+ bool operator>(const abstract::point<P>& rhs) const;
/// \}
@@ -160,19 +123,10 @@
/// \{
/// Operator >=.
- bool operator>=(const exact_t& rhs) const
- {
- return not (*this < rhs);
- }
+ bool operator>=(const E& rhs) const;
template <typename P>
- bool operator>=(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return not (*this < rhs);
- }
+ bool operator>=(const abstract::point<P>& rhs) const;
/// \}
@@ -180,19 +134,10 @@
/// \{
/// Operator <=.
- bool operator<=(const exact_t& rhs) const
- {
- return not (rhs < *this);
- }
+ bool operator<=(const E& rhs) const;
template <typename P>
- bool operator<=(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return not (rhs < *this);
- }
+ bool operator<=(const abstract::point<P>& rhs) const;
/// \}
@@ -200,19 +145,10 @@
/// \{
/// Operator +=.
- exact_t& operator+=(const dpoint_t& rhs)
- {
- return this->exact().impl_plus_equal(rhs);
- }
+ E& operator+=(const dpoint_t& rhs);
template <typename D>
- exact_t& operator+=(const abstract::dpoint<D>& rhs)
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_plus_equal(rhs.exact());
- }
+ E& operator+=(const abstract::dpoint<D>& rhs);
/// \}
@@ -220,19 +156,10 @@
/// \{
/// Operator +.
- exact_t operator+(const dpoint_t& rhs) const
- {
- return this->exact().impl_plus(rhs);
- }
+ E operator+(const dpoint_t& rhs) const;
template <typename D>
- xtd_op_plus_trait(E,D) operator+(const abstract::dpoint<D>& rhs)
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_plus(rhs.exact());
- }
+ xtd_op_plus_trait(E,D) operator+(const abstract::dpoint<D>& rhs) const;
/// \}
@@ -240,19 +167,10 @@
/// \{
/// Operator -=.
- exact_t& operator-=(const dpoint_t& rhs)
- {
- return this->exact().impl_minus_equal(rhs);
- }
+ E& operator-=(const dpoint_t& rhs);
template <typename D>
- exact_t& operator-=(const abstract::dpoint<D>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_minus_equal(rhs.exact());
- }
+ E& operator-=(const abstract::dpoint<D>& rhs) const;
/// \}
@@ -260,19 +178,10 @@
/// \{
/// Operator -.
- exact_t operator-(const dpoint_t& rhs) const
- {
- return this->exact().impl_minus(rhs);
- }
+ E operator-(const dpoint_t& rhs) const;
template <typename D>
- xtd_op_minus_trait(E, D) operator-(const abstract::dpoint<D>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_minus(rhs.exact());
- }
+ xtd_op_minus_trait(E, D) operator-(const abstract::dpoint<D>& rhs) const;
/// \}
@@ -280,39 +189,220 @@
/// \{
/// Operator -.
- dpoint_t operator-(const exact_t& rhs) const
- {
- return this->exact().impl_minus(rhs);
- }
+ dpoint_t operator-(const E& rhs) const;
template <typename P>
- xtd_op_minus_trait(E, P) operator-(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_type_of(E, grid),
- oln_type_of(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_minus(rhs.exact());
- }
+ xtd_op_minus_trait(E, P) operator-(const abstract::point<P>& rhs) const;
/// \}
- protected:
-
- point()
- {}
-
~point()
{
- mlc::assert_defined_< oln_type_of(E, grid) >::check();
- mlc::assert_defined_< oln_type_of(E, dpoint) >::check();
- mlc::assert_defined_< oln_type_of(E, coord) >::check();
- mlc::assert_defined_< oln_type_of(E, dim) >::check();
+ // FIXME: See code below.
}
+ protected:
+
+ point();
+
}; // end of class oln::abstract::point<E>
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool point<E>::operator==(const E& rhs) const
+ {
+ return this->exact().impl_equal(rhs);
+ }
+
+ template <typename E>
+ template <typename P>
+ bool point<E>::operator==(const abstract::point<P>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(P, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return this->exact().impl_equal(rhs.exact());
+ }
+
+ template <typename E>
+ bool point<E>::operator!=(const E& rhs) const
+ {
+ return not (*this == rhs);
+ }
+
+ template <typename E>
+ template <typename P>
+ bool point<E>::operator!=(const abstract::point<P>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(P, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return not (*this == rhs);
+ }
+
+ template <typename E>
+ bool point<E>::operator<(const E& rhs) const
+ {
+ return this->exact().impl_less(rhs);
+ }
+
+ template <typename E>
+ template <typename P>
+ bool point<E>::operator<(const abstract::point<P>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(P, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return this->exact().impl_less(rhs.exact());
+ }
+
+ template <typename E>
+ bool point<E>::operator>(const E& rhs) const
+ {
+ return rhs < *this;
+ }
+
+ template <typename E>
+ template <typename P>
+ bool point<E>::operator>(const abstract::point<P>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(P, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return rhs < *this;
+ }
+
+ template <typename E>
+ bool point<E>::operator>=(const E& rhs) const
+ {
+ return not (*this < rhs);
+ }
+
+ template <typename E>
+ template <typename P>
+ bool point<E>::operator>=(const abstract::point<P>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(P, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return not (*this < rhs);
+ }
+
+ template <typename E>
+ bool point<E>::operator<=(const E& rhs) const
+ {
+ return not (rhs < *this);
+ }
+
+ template <typename E>
+ template <typename P>
+ bool point<E>::operator<=(const abstract::point<P>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(P, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return not (rhs < *this);
+ }
+
+ template <typename E>
+ E& point<E>::operator+=(const typename point<E>::dpoint_t& rhs)
+ {
+ return this->exact().impl_plus_equal(rhs);
+ }
+
+ template <typename E>
+ template <typename D>
+ E& point<E>::operator+=(const abstract::dpoint<D>& rhs)
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(D, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return this->exact().impl_plus_equal(rhs.exact());
+ }
+
+ template <typename E>
+ E point<E>::operator+(const typename point<E>::dpoint_t& rhs) const
+ {
+ return this->exact().impl_plus(rhs);
+ }
+
+ template <typename E>
+ template <typename D>
+ xtd_op_plus_trait(E,D) point<E>::operator+(const abstract::dpoint<D>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(D, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return this->exact().impl_plus(rhs.exact());
+ }
+
+ template <typename E>
+ E& point<E>::operator-=(const typename point<E>::dpoint_t& rhs)
+ {
+ return this->exact().impl_minus_equal(rhs);
+ }
+
+ template <typename E>
+ template <typename D>
+ E& point<E>::operator-=(const abstract::dpoint<D>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(D, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return this->exact().impl_minus_equal(rhs.exact());
+ }
+
+ template <typename E>
+ E point<E>::operator-(const typename point<E>::dpoint_t& rhs) const
+ {
+ return this->exact().impl_minus(rhs);
+ }
+
+ template <typename E>
+ template <typename D>
+ xtd_op_minus_trait(E, D) point<E>::operator-(const abstract::dpoint<D>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(D, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return this->exact().impl_minus(rhs.exact());
+ }
+
+ template <typename E>
+ typename point<E>::dpoint_t point<E>::operator-(const E& rhs) const
+ {
+ return this->exact().impl_minus(rhs);
+ }
+
+ template <typename E>
+ template <typename P>
+ xtd_op_minus_trait(E, P) point<E>::operator-(const abstract::point<P>& rhs) const
+ {
+ mlc::assert_equal_< oln_type_of(E, grid),
+ oln_type_of(P, grid),
+ oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
+ return this->exact().impl_minus(rhs.exact());
+ }
+
+ template <typename E>
+ point<E>::point()
+ {}
+
+// template <typename E>
+// point<E>::~point()
+// {
+// mlc::assert_defined_< oln_type_of(E, grid) >::check();
+// mlc::assert_defined_< oln_type_of(E, dpoint) >::check();
+// mlc::assert_defined_< oln_type_of(E, coord) >::check();
+// mlc::assert_defined_< oln_type_of(E, dim) >::check();
+// }
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/bbox.hh
===================================================================
--- oln/core/abstract/bbox.hh (revision 606)
+++ oln/core/abstract/bbox.hh (working copy)
@@ -45,32 +45,56 @@
{
public:
- void print(std::ostream& ostr) const
- {
- this->exact().impl_print(ostr);
- }
-
- friend
- std::ostream& operator<<(std::ostream& ostr, const abstract::bbox<E>& bb)
- {
- bb.print(ostr);
- return ostr;
- }
+ void print(std::ostream& ostr) const;
- const E& impl_bbox() const
+ const E& impl_bbox() const;
+
+ ~bbox()
{
- return this->exact();
}
protected:
- bbox()
- {
- }
+ bbox();
}; // end of class oln::abstract::bbox<E>
+# ifndef OLN_INCLUDE_ONLY
+
+
+ template <typename E>
+ void bbox<E>::print(std::ostream& ostr) const
+ {
+ this->exact().impl_print(ostr);
+ }
+
+ template <typename E>
+ std::ostream& operator<<(std::ostream& ostr, const abstract::bbox<E>& bb)
+ {
+ bb.print(ostr);
+ return ostr;
+ }
+
+ template <typename E>
+ const E& bbox<E>::impl_bbox() const
+ {
+ return this->exact();
+ }
+
+ template <typename E>
+ bbox<E>::bbox()
+ {
+ }
+
+// template <typename E>
+// bbox<E>::~bbox()
+// {
+// }
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/point_set_being_connected.hh
===================================================================
--- oln/core/abstract/point_set_being_connected.hh (revision 606)
+++ oln/core/abstract/point_set_being_connected.hh (working copy)
@@ -43,16 +43,11 @@
{
public:
- unsigned nindices() const
- {
- precondition(this->is_valid());
- return this->exact().len(0);
- }
+ unsigned nindices() const;
protected:
- point_set_being_1d_connected()
- {}
+ point_set_being_1d_connected();
};
@@ -61,54 +56,102 @@
{
public:
- unsigned nrows() const
- {
- precondition(this->is_valid());
- return this->exact().len(0);
- }
+ unsigned nrows() const;
- unsigned ncols() const
- {
- precondition(this->is_valid());
- return this->exact().len(1);
- }
+ unsigned ncols() const;
protected:
- point_set_being_2d_connected()
- {}
+ point_set_being_2d_connected();
+
};
+
template <typename E>
class point_set_being_3d_connected : public virtual abstract::point_set<E>
{
public:
- unsigned nslices() const
- {
- precondition(this->is_valid());
- return this->exact().len(0);
- }
+ unsigned nslices() const;
- unsigned nrows() const
- {
- precondition(this->is_valid());
- return this->exact().len(1);
- }
+ unsigned nrows() const;
- unsigned ncols() const
- {
- precondition(this->is_valid());
- return this->exact().len(2);
- }
+ unsigned ncols() const;
protected:
- point_set_being_3d_connected()
- {}
+ point_set_being_3d_connected();
+
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ template <typename E>
+ unsigned point_set_being_1d_connected<E>::nindices() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ template <typename E>
+ point_set_being_1d_connected<E>::point_set_being_1d_connected()
+ {
+ }
+
+
+ template <typename E>
+ unsigned point_set_being_2d_connected<E>::nrows() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ template <typename E>
+ unsigned point_set_being_2d_connected<E>::ncols() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(1);
+ }
+
+ template <typename E>
+ point_set_being_2d_connected<E>::point_set_being_2d_connected()
+ {
+ }
+
+
+ template <typename E>
+ unsigned point_set_being_3d_connected<E>::nslices() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ template <typename E>
+ unsigned point_set_being_3d_connected<E>::nrows() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(1);
+ }
+
+ template <typename E>
+ unsigned point_set_being_3d_connected<E>::ncols() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(2);
+ }
+
+ template <typename E>
+ point_set_being_3d_connected<E>::point_set_being_3d_connected()
+ {
+ }
+
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/dpoint.hh
===================================================================
--- oln/core/abstract/dpoint.hh (revision 606)
+++ oln/core/abstract/dpoint.hh (working copy)
@@ -72,35 +72,66 @@
{
public:
- bool operator==(const abstract::dpoint<E>& rhs) const
- {
- return this->exact().impl_eq(rhs.exact());
- }
+ bool operator==(const abstract::dpoint<E>& rhs) const;
+ bool operator!=(const abstract::dpoint<E>& rhs) const;
- bool operator!=(const abstract::dpoint<E>& rhs) const { return not (*this == rhs); }
+ bool operator< (const abstract::dpoint<E>& rhs) const;
+ bool operator> (const abstract::dpoint<E>& rhs) const;
+ bool operator>=(const abstract::dpoint<E>& rhs) const;
+ bool operator<=(const abstract::dpoint<E>& rhs) const;
- bool operator<(const abstract::dpoint<E>& rhs) const
+ ~dpoint()
{
- return this->exact().impl_less(rhs.exact());
+ // FIXME: Code is below.
}
- bool operator> (const abstract::dpoint<E>& rhs) const { return rhs < *this; }
- bool operator>=(const abstract::dpoint<E>& rhs) const { return not (*this < rhs); }
- bool operator<=(const abstract::dpoint<E>& rhs) const { return not (rhs < *this); }
-
protected:
- dpoint()
- {}
- ~dpoint() {
- mlc::assert_defined_< oln_type_of(E, grid) >::check();
- mlc::assert_defined_< oln_type_of(E, point) >::check();
- mlc::assert_defined_< oln_type_of(E, coord) >::check();
- mlc::assert_defined_< oln_type_of(E, dim) >::check();
- }
+ dpoint();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool dpoint<E>::operator==(const abstract::dpoint<E>& rhs) const
+ {
+ return this->exact().impl_eq(rhs.exact());
+ }
+
+ template <typename E>
+ bool dpoint<E>::operator!=(const abstract::dpoint<E>& rhs) const { return not (*this == rhs); }
+
+ template <typename E>
+ bool dpoint<E>::operator<(const abstract::dpoint<E>& rhs) const
+ {
+ return this->exact().impl_less(rhs.exact());
+ }
+
+ template <typename E>
+ bool dpoint<E>::operator> (const abstract::dpoint<E>& rhs) const { return rhs < *this; }
+
+ template <typename E>
+ bool dpoint<E>::operator>=(const abstract::dpoint<E>& rhs) const { return not (*this < rhs); }
+
+ template <typename E>
+ bool dpoint<E>::operator<=(const abstract::dpoint<E>& rhs) const { return not (rhs < *this); }
+
+ template <typename E>
+ dpoint<E>::dpoint()
+ {}
+
+// template <typename E>
+// dpoint<E>::~dpoint() {
+// mlc::assert_defined_< oln_type_of(E, grid) >::check();
+// mlc::assert_defined_< oln_type_of(E, point) >::check();
+// mlc::assert_defined_< oln_type_of(E, coord) >::check();
+// mlc::assert_defined_< oln_type_of(E, dim) >::check();
+// }
+
+# endif
+
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/topology_being_random_accessible.hh
===================================================================
--- oln/core/abstract/topology_being_random_accessible.hh (revision 606)
+++ oln/core/abstract/topology_being_random_accessible.hh (working copy)
@@ -47,23 +47,39 @@
public:
- bool has(const point_t& p) const
- {
- return this->exact().impl_has(p);
- }
+ bool has(const point_t& p) const;
- bool has_large(const point_t& p) const
- {
- return this->exact().impl_has_large(p);
- }
+ bool has_large(const point_t& p) const;
protected:
- topology_being_random_accessible()
- {}
+ topology_being_random_accessible();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool topology_being_random_accessible<E>::has(const oln_type_of(E, point)& p) const
+ {
+ return this->exact().impl_has(p);
+ }
+
+ template <typename E>
+ bool topology_being_random_accessible<E>::has_large(const oln_type_of(E, point)& p) const
+ {
+ return this->exact().impl_has_large(p);
+ }
+
+ template <typename E>
+ topology_being_random_accessible<E>::topology_being_random_accessible()
+ {
+ }
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/topology_having_subset.hh
===================================================================
--- oln/core/abstract/topology_having_subset.hh (revision 607)
+++ oln/core/abstract/topology_having_subset.hh (working copy)
@@ -48,18 +48,30 @@
public:
// abstract
- const subset_t& subset() const
- {
- return this->exact().impl_subset();
- }
+ const subset_t& subset() const;
protected:
- topology_having_subset()
- {}
+ topology_having_subset();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const oln_type_of(E, subset)&
+ topology_having_subset<E>::subset() const
+ {
+ return this->exact().impl_subset();
+ }
+
+ template <typename E>
+ topology_having_subset<E>::topology_having_subset()
+ {}
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/topology_having_neighborhood.hh
===================================================================
--- oln/core/abstract/topology_having_neighborhood.hh (revision 606)
+++ oln/core/abstract/topology_having_neighborhood.hh (working copy)
@@ -48,24 +48,41 @@
public:
// abstract
- const neighborhood_t& neighborhood() const
- {
- return this->exact().impl_neighborhood();
- }
+ const neighborhood_t& neighborhood() const;
// concrete
- operator neighborhood_t() const
- {
- return this->neighborhood();
- }
+ operator neighborhood_t() const;
protected:
- topology_having_neighborhood()
- {}
+ topology_having_neighborhood();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const oln_type_of(E, neighborhood)&
+ topology_having_neighborhood<E>::neighborhood() const
+ {
+ return this->exact().impl_neighborhood();
+ }
+
+ template <typename E>
+ topology_having_neighborhood<E>::operator oln_type_of(E, neighborhood)() const
+ {
+ return this->neighborhood();
+ }
+
+ template <typename E>
+ topology_having_neighborhood<E>::topology_having_neighborhood()
+ {
+ }
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/entry.hh
===================================================================
--- oln/core/abstract/entry.hh (revision 606)
+++ oln/core/abstract/entry.hh (working copy)
@@ -93,8 +93,21 @@
typename mlc::is_defined_< oln::case_< oln::hierarchy<abstraction, num>,
E, 1 > >::eval >
{
+ ~entry_node();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template < template <class> class abstraction,
+ typename E,
+ unsigned num >
+ entry_node<abstraction, E, num>::~entry_node()
+ {
+ }
+
+# endif
+
} // end of namespace oln::internal
@@ -114,13 +127,29 @@
typename E >
struct entry : public internal::entry_node<abstraction, E, 1>
{
+ ~entry();
protected:
- entry()
- {
- }
+ entry();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template < template <class> class abstraction,
+ typename E >
+ entry<abstraction, E>::entry()
+ {
+ }
+
+ template < template <class> class abstraction,
+ typename E >
+ entry<abstraction, E>::~entry()
+ {
+ }
+
+# endif
+
+
// Super type declaration.
template < template <class> class abstraction,
typename E >
Index: oln/core/abstract/point_set.hh
===================================================================
--- oln/core/abstract/point_set.hh (revision 606)
+++ oln/core/abstract/point_set.hh (working copy)
@@ -45,10 +45,7 @@
{
public:
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
+ bool is_valid() const;
struct decl
{
@@ -68,26 +65,52 @@
stc_virtual_typedef(grid);
stc_virtual_typedef(dim);
- decl() {
- // coherence check:
- mlc::assert_equal_< oln_type_of(fwd_piter, grid),
- oln_type_of(point, grid) >::check();
- mlc::assert_equal_< oln_type_of(bkd_piter, grid),
- oln_type_of(point, grid) >::check();
- }
+ decl();
};
+ ~point_set()
+ {
+ }
+
protected:
- point_set()
- {}
+ point_set();
- ~point_set() { decl(); }
-
}; // end of class oln::abstract::point_set<E>
+# ifndef OLN_INCLUDE_ONLY
+ template <typename E>
+ bool point_set<E>::is_valid() const
+ {
+ return this->exact().impl_is_valid();
+ }
+
+ template <typename E>
+ point_set<E>::decl::decl()
+ {
+ // coherence check:
+ mlc::assert_equal_< oln_type_of(fwd_piter, grid),
+ oln_type_of(point, grid) >::check();
+ mlc::assert_equal_< oln_type_of(bkd_piter, grid),
+ oln_type_of(point, grid) >::check();
+ }
+
+ template <typename E>
+ point_set<E>::point_set()
+ {
+ }
+
+// template <typename E>
+// point_set<E>::~point_set()
+// {
+// decl();
+// }
+
+# endif
+
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/point_set_having_known_size.hh
===================================================================
--- oln/core/abstract/point_set_having_known_size.hh (revision 606)
+++ oln/core/abstract/point_set_having_known_size.hh (working copy)
@@ -44,17 +44,30 @@
{
public:
- unsigned npoints() const
- {
- return this->exact().impl_npoints();
- }
+ unsigned npoints() const;
protected:
- point_set_having_known_size()
- {}
+ point_set_having_known_size();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ unsigned
+ point_set_having_known_size<E>::npoints() const
+ {
+ return this->exact().impl_npoints();
+ }
+
+ template <typename E>
+ point_set_having_known_size<E>::point_set_having_known_size()
+ {
+ }
+
+# endif
+
+
} // end of namespace oln::abstract
Index: oln/core/abstract/neighborhood.hh
===================================================================
--- oln/core/abstract/neighborhood.hh (revision 606)
+++ oln/core/abstract/neighborhood.hh (working copy)
@@ -45,30 +45,51 @@
{
public:
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
+ bool is_valid() const;
struct decl
{
stc_virtual_typedef(grid);
- decl() {
- }
+ decl();
};
protected:
- neighborhood()
- {}
+ neighborhood();
+ ~neighborhood();
- ~neighborhood() { decl(); }
-
}; // end of class oln::abstract::neighborhood<E>
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool neighborhood<E>::is_valid() const
+ {
+ return this->exact().impl_is_valid();
+ }
+
+ template <typename E>
+ neighborhood<E>::neighborhood()
+ {
+ }
+
+ template <typename E>
+ neighborhood<E>::~neighborhood()
+ {
+ decl();
+ }
+
+ template <typename E>
+ neighborhood<E>::decl::decl()
+ {
+ }
+
+# endif
+
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/abstract/point_set_having_bbox.hh
===================================================================
--- oln/core/abstract/point_set_having_bbox.hh (revision 606)
+++ oln/core/abstract/point_set_having_bbox.hh (working copy)
@@ -50,52 +50,82 @@
public:
- const bbox_t& bbox() const
- {
- return this->exact().impl_box();
- }
+ const bbox_t& bbox() const;
- // FIXME: attributes should be removed from this abstract class.
+ const point_t& pmin() const;
- const point_t& pmin() const
- {
- precondition(this->is_valid());
- return pmin_;
- }
+ coord_t pmin(unsigned i) const;
- coord_t pmin(unsigned i) const
- {
- precondition(this->is_valid() and i < n);
- return pmin_[i];
- }
+ const point_t& pmax() const;
- const point_t& pmax() const
- {
- precondition(this->is_valid());
- return pmax_;
- }
+ coord_t pmax(unsigned i) const;
- coord_t pmax(unsigned i) const
- {
- precondition(this->is_valid() and i < n);
- return pmax_[i];
- }
+ unsigned len(unsigned i) const;
- unsigned len(unsigned i) const
- {
- precondition(this->is_valid() and i < n);
- return pmax_[i] - pmin_[i] + 1;
- }
-
protected:
- point_set_having_bbox()
- {}
+ point_set_having_bbox();
point_t pmin_, pmax_;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ const typename point_set_having_bbox<E>::bbox_t&
+ point_set_having_bbox<E>::bbox() const
+ {
+ return this->exact().impl_box();
+ }
+
+ template <typename E>
+ const typename point_set_having_bbox<E>::point_t&
+ point_set_having_bbox<E>::pmin() const
+ {
+ precondition(this->is_valid());
+ return pmin_;
+ }
+
+ template <typename E>
+ typename point_set_having_bbox<E>::coord_t
+ point_set_having_bbox<E>::pmin(unsigned i) const
+ {
+ precondition(this->is_valid() and i < n);
+ return pmin_[i];
+ }
+
+ template <typename E>
+ const typename point_set_having_bbox<E>::point_t&
+ point_set_having_bbox<E>::pmax() const
+ {
+ precondition(this->is_valid());
+ return pmax_;
+ }
+
+ template <typename E>
+ typename point_set_having_bbox<E>::coord_t
+ point_set_having_bbox<E>::pmax(unsigned i) const
+ {
+ precondition(this->is_valid() and i < n);
+ return pmax_[i];
+ }
+
+ template <typename E>
+ unsigned
+ point_set_having_bbox<E>::len(unsigned i) const
+ {
+ precondition(this->is_valid() and i < n);
+ return pmax_[i] - pmin_[i] + 1;
+ }
+
+ template <typename E>
+ point_set_having_bbox<E>::point_set_having_bbox()
+ {}
+
+# endif
+
} // end of namespace oln::abstract
Index: oln/core/abstract/topology.hh
===================================================================
--- oln/core/abstract/topology.hh (revision 606)
+++ oln/core/abstract/topology.hh (working copy)
@@ -59,24 +59,43 @@
stc_virtual_typedef(morpher);
- decl() {
- // constraint:
-// mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >,
-// mlc_is_a(bbox, abstract::bbox) > >::check();
- }
+ decl();
};
protected:
- topology()
- {}
+ topology();
- ~topology() { decl(); }
+ ~topology();
}; // end of class oln::abstract::topology<E>
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ topology<E>::decl::decl()
+ {
+ // constraint:
+// mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >,
+// mlc_is_a(bbox, abstract::bbox) > >::check();
+ }
+
+ template <typename E>
+ topology<E>::topology()
+ {
+ }
+
+ template <typename E>
+ topology<E>::~topology()
+ {
+ decl();
+ }
+
+# endif
+
+
} // end of namespace oln::abstract
} // end of namespace oln
Index: oln/core/2d/neighb2d.hh
===================================================================
--- oln/core/2d/neighb2d.hh (revision 607)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -40,71 +40,71 @@
namespace internal
{
+ neighb2d mk_c4();
+ neighb2d mk_c8();
+ neighb2d mk_c2_row();
+ neighb2d mk_c2_col();
+
+
+# ifndef OLN_INCLUDE_ONLY
+
neighb2d mk_c4()
{
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1, 0));
- flower = false;
- }
+ neighb2d the_;
+ the_
+ .add(dpoint2d(0, 1))
+ .add(dpoint2d(1, 0));
return the_;
}
neighb2d mk_c8()
{
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1,-1))
- .add(dpoint2d(1, 0))
- .add(dpoint2d(1, 1));
- flower = false;
- }
+ neighb2d the_;
+ the_
+ .add(dpoint2d(0, 1))
+ .add(dpoint2d(1,-1))
+ .add(dpoint2d(1, 0))
+ .add(dpoint2d(1, 1));
return the_;
}
neighb2d mk_c2_row()
{
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(0, 1));
- flower = false;
- }
+ neighb2d the_;
+ the_
+ .add(dpoint2d(0, 1));
return the_;
}
neighb2d mk_c2_col()
{
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(1, 0));
- flower = false;
- }
+ neighb2d the_;
+ the_
+ .add(dpoint2d(1, 0));
return the_;
}
+# endif
+
} // end of namespace oln::internal
- static const neighb2d c4 = internal::mk_c4();
- static const neighb2d c8 = internal::mk_c8();
- static const neighb2d c2r = internal::mk_c2_row();
- static const neighb2d c2c = internal::mk_c2_col();
+ extern const neighb2d c4;
+ extern const neighb2d c8;
+ extern const neighb2d c2r;
+ extern const neighb2d c2c;
+# ifndef OLN_INCLUDE_ONLY
+
+ const neighb2d c4 = internal::mk_c4();
+ const neighb2d c8 = internal::mk_c8();
+ const neighb2d c2r = internal::mk_c2_row();
+ const neighb2d c2c = internal::mk_c2_col();
+
+# endif
+
+
} // end of namespace oln
Index: oln/core/2d/dpoint2d.hh
===================================================================
--- oln/core/2d/dpoint2d.hh (revision 606)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -64,37 +64,63 @@
{
typedef dpoint2d_<C> self_t;
typedef stc_get_super(dpoint2d_<C>) super_t;
- typedef oln_type_of(self_t, coord) coord_t;
using super_t::v_;
public:
/// Ctor.
- dpoint2d_()
- {
- }
+ dpoint2d_();
/// Ctor.
- dpoint2d_(const xtd::vec<2,coord_t>& v)
- : super_t(v)
- {
- }
+ dpoint2d_(const xtd::vec<2,C>& v);
/// Ctor.
- dpoint2d_(coord_t row, coord_t col)
- : super_t(xtd::mk_vec(row, col))
- {
- }
+ dpoint2d_(C row, C col);
- coord_t row() const { return v_[0]; }
- coord_t& row() { return v_[0]; }
+ C row() const;
+ C& row();
- coord_t col() const { return v_[1]; }
- coord_t& col() { return v_[1]; }
+ C col() const;
+ C& col();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename C>
+ dpoint2d_<C>::dpoint2d_()
+ {
+ }
+
+ /// Ctor.
+ template <typename C>
+ dpoint2d_<C>::dpoint2d_(const xtd::vec<2,C>& v)
+ : super_t(v)
+ {
+ }
+
+ /// Ctor.
+ template <typename C>
+ dpoint2d_<C>::dpoint2d_(C row, C col)
+ : super_t(xtd::mk_vec(row, col))
+ {
+ }
+
+ template <typename C>
+ C dpoint2d_<C>::row() const { return v_[0]; }
+
+ template <typename C>
+ C& dpoint2d_<C>::row() { return v_[0]; }
+
+ template <typename C>
+ C dpoint2d_<C>::col() const { return v_[1]; }
+
+ template <typename C>
+ C& dpoint2d_<C>::col() { return v_[1]; }
+
+# endif
+
} // end of namespace oln
Index: oln/core/2d/array2d.hh
===================================================================
--- oln/core/2d/array2d.hh (revision 606)
+++ oln/core/2d/array2d.hh (working copy)
@@ -44,65 +44,21 @@
/// Ctor.
array2d(coord_t imin, coord_t jmin,
- coord_t imax, coord_t jmax) :
- imin_(imin),
- jmin_(jmin),
- imax_(imax),
- jmax_(jmax)
- {
- precondition(imax >= imin and jmax >= jmin);
- ilen_ = imax - imin + 1;
- jlen_ = jmax - jmin + 1;
- allocate_();
- }
+ coord_t imax, coord_t jmax);
/// Ctor.
- array2d(coord_t ilen, coord_t jlen) :
- imin_(0),
- jmin_(0),
- ilen_(ilen),
- jlen_(jlen)
- {
- precondition(ilen > 0 and jlen > 0);
- imax_ = imin_ + ilen_;
- jmax_ = jmin_ + ilen_;
- allocate_();
- }
+ array2d(coord_t ilen, coord_t jlen);
/// Dtor.
- ~array2d()
- {
- deallocate_();
- }
+ ~array2d();
- value_t operator()(coord_t i, coord_t j) const
- {
- precondition(has(i, j));
- return array_[i][j];
- }
+ value_t operator()(coord_t i, coord_t j) const;
- value_t& operator()(coord_t i, coord_t j)
- {
- precondition(has(i, j));
- return array_[i][j];
- }
+ value_t& operator()(coord_t i, coord_t j);
- bool has(coord_t i, coord_t j) const
- {
- return
- i >= imin_ and i <= imax_ and
- j >= jmin_ and j <= jmax_;
- }
+ bool has(coord_t i, coord_t j) const;
- size_t memsize() const
- {
- return
- // buffer_
- size_t(ilen_) * size_t(jlen_) * sizeof(value_t)
- +
- // array_
- size_t(ilen_) * sizeof(value_t*);
- }
+ size_t memsize() const;
protected:
@@ -113,31 +69,112 @@
private:
- void allocate_()
- {
- buffer_ = new value_t[size_t(ilen_) * size_t(jlen_)];
- array_ = new value_t*[size_t(ilen_)];
- value_t* buf = buffer_ - jmin_;
- for (coord_t i = 0; i < ilen_; ++i)
- {
- array_[i] = buf;
- buf += jlen_;
- }
- array_ -= imin_;
- }
+ void allocate_();
- void deallocate_()
- {
- precondition(buffer_ != 0 and array_ != 0);
- delete[] buffer_;
- buffer_ = 0; // safety
- array_ += imin_;
- delete[] array_;
- array_ = 0; // safety
- }
+ void deallocate_();
};
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename value_t, typename coord_t>
+ array2d<value_t, coord_t>::array2d(coord_t imin, coord_t jmin,
+ coord_t imax, coord_t jmax) :
+ imin_(imin),
+ jmin_(jmin),
+ imax_(imax),
+ jmax_(jmax)
+ {
+ precondition(imax >= imin and jmax >= jmin);
+ ilen_ = imax - imin + 1;
+ jlen_ = jmax - jmin + 1;
+ allocate_();
+ }
+
+ template <typename value_t, typename coord_t>
+ /// Ctor.
+ array2d<value_t, coord_t>::array2d(coord_t ilen, coord_t jlen) :
+ imin_(0),
+ jmin_(0),
+ ilen_(ilen),
+ jlen_(jlen)
+ {
+ precondition(ilen > 0 and jlen > 0);
+ imax_ = imin_ + ilen_;
+ jmax_ = jmin_ + ilen_;
+ allocate_();
+ }
+
+ template <typename value_t, typename coord_t>
+ /// Dtor.
+ array2d<value_t, coord_t>::~array2d()
+ {
+ deallocate_();
+ }
+
+ template <typename value_t, typename coord_t>
+ value_t array2d<value_t, coord_t>::operator()(coord_t i, coord_t j) const
+ {
+ precondition(has(i, j));
+ return array_[i][j];
+ }
+
+ template <typename value_t, typename coord_t>
+ value_t& array2d<value_t, coord_t>::operator()(coord_t i, coord_t j)
+ {
+ precondition(has(i, j));
+ return array_[i][j];
+ }
+
+ template <typename value_t, typename coord_t>
+ bool array2d<value_t, coord_t>::has(coord_t i, coord_t j) const
+ {
+ return
+ i >= imin_ and i <= imax_ and
+ j >= jmin_ and j <= jmax_;
+ }
+
+ template <typename value_t, typename coord_t>
+ size_t array2d<value_t, coord_t>::memsize() const
+ {
+ return
+ // buffer_
+ size_t(ilen_) * size_t(jlen_) * sizeof(value_t)
+ +
+ // array_
+ size_t(ilen_) * sizeof(value_t*);
+ }
+
+ template <typename value_t, typename coord_t>
+ void array2d<value_t, coord_t>::allocate_()
+ {
+ buffer_ = new value_t[size_t(ilen_) * size_t(jlen_)];
+ array_ = new value_t*[size_t(ilen_)];
+ value_t* buf = buffer_ - jmin_;
+ for (coord_t i = 0; i < ilen_; ++i)
+ {
+ array_[i] = buf;
+ buf += jlen_;
+ }
+ array_ -= imin_;
+ }
+
+ template <typename value_t, typename coord_t>
+ void array2d<value_t, coord_t>::deallocate_()
+ {
+ precondition(buffer_ != 0 and array_ != 0);
+ delete[] buffer_;
+ buffer_ = 0; // safety
+ array_ += imin_;
+ delete[] array_;
+ array_ = 0; // safety
+ }
+
+# endif
+
+
} // end of namespace oln
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 607)
+++ oln/core/2d/image2d.hh (working copy)
@@ -78,43 +78,16 @@
public:
/// Ctor using sizes.
- image2d(unsigned nrows, unsigned ncols, unsigned border = 2)
- : topo_(bbox2d(point2d(0, 0 ),
- point2d(nrows - 1, ncols - 1)),
- border),
- data_(new array_t(0 - border, 0 - border,
- nrows - 1 + border, ncols - 1 + border))
- {
- }
+ image2d(unsigned nrows, unsigned ncols, unsigned border = 2);
/// Ctor using an existing topology.
- image2d(const topo2d& topo)
- : topo_(topo),
- data_(new array_t(topo.bbox().pmin().row(),
- topo.bbox().pmin().col(),
- topo.bbox().pmax().row(),
- topo.bbox().pmax().col()))
- {
- }
+ image2d(const topo2d& topo);
- const topo2d& impl_topo() const
- {
- return topo_;
- }
+ const topo2d& impl_topo() const;
- T impl_op_read(const point2d& p) const
- {
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
- }
+ T impl_op_read(const point2d& p) const;
- T& impl_op_readwrite(const point2d& p)
- {
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
- }
+ T& impl_op_readwrite(const point2d& p);
private:
@@ -123,6 +96,55 @@
};
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ image2d<T>::image2d(unsigned nrows, unsigned ncols, unsigned border)
+ : topo_(bbox2d(point2d(0, 0 ),
+ point2d(nrows - 1, ncols - 1)),
+ border),
+ data_(new array_t(0 - border, 0 - border,
+ nrows - 1 + border, ncols - 1 + border))
+ {
+ }
+
+ /// Ctor using an existing topology.
+ template <typename T>
+ image2d<T>::image2d(const topo2d& topo)
+ : topo_(topo),
+ data_(new array_t(topo.bbox().pmin().row(),
+ topo.bbox().pmin().col(),
+ topo.bbox().pmax().row(),
+ topo.bbox().pmax().col()))
+ {
+ }
+
+ 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
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.row(), p.col());
+ }
+
+ template <typename T>
+ T& image2d<T>::impl_op_readwrite(const point2d& p)
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.row(), p.col());
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/2d/point2d.hh
===================================================================
--- oln/core/2d/point2d.hh (revision 606)
+++ oln/core/2d/point2d.hh (working copy)
@@ -72,37 +72,72 @@
{
typedef point2d_<C> self_t;
typedef stc_get_super(point2d_<C>) super_t;
- typedef oln_type_of(self_t, coord) coord_t;
using super_t::v_;
public:
/// Ctor.
- point2d_()
- {
- }
+ point2d_();
/// Ctor.
- point2d_(coord_t row, coord_t col)
- : super_t (xtd::mk_vec(row, col))
- {
- }
+ point2d_(C row, C col);
/// Ctor.
- point2d_(const xtd::vec<2,coord_t>& v)
- : super_t(v)
+ point2d_(const xtd::vec<2,C>& v);
+
+ ///Dtor.
+ ~point2d_()
{
}
- coord_t row() const { return v_[0]; }
- coord_t& row() { return v_[0]; }
+ C row() const;
+ C& row();
- coord_t col() const { return v_[1]; }
- coord_t& col() { return v_[1]; }
+ C col() const;
+ C& col();
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename C>
+ point2d_<C>::point2d_()
+ {
+ }
+
+ template <typename C>
+ point2d_<C>::point2d_(C row, C col)
+ : super_t (xtd::mk_vec(row, col))
+ {
+ }
+
+ template <typename C>
+ point2d_<C>::point2d_(const xtd::vec<2,C>& v)
+ : super_t(v)
+ {
+ }
+
+// template <typename C>
+// point2d_<C>::~point2d_()
+// {
+// }
+
+ template <typename C>
+ C point2d_<C>::row() const { return v_[0]; }
+
+ template <typename C>
+ C& point2d_<C>::row() { return v_[0]; }
+
+ template <typename C>
+ C point2d_<C>::col() const { return v_[1]; }
+
+ template <typename C>
+ C& point2d_<C>::col() { return v_[1]; }
+
+# endif
+
} // end of namespace oln
# include <oln/core/2d/dpoint2d.hh>
Index: oln/core/gen/piter_isubset.hh
===================================================================
--- oln/core/gen/piter_isubset.hh (revision 607)
+++ oln/core/gen/piter_isubset.hh (working copy)
@@ -74,67 +74,108 @@
public:
template <typename T>
- piter_isubset_(const abstract::topology<T>& topo)
- : p_(topo),
- isubset_(topo.exact().subset())
- {
- }
-
+ piter_isubset_(const abstract::topology<T>& topo);
+
template <typename P, typename T>
- piter_isubset_(const P& p, const abstract::topology<T>& topo)
- : p_(p, topo),
- isubset_(topo.exact().subset())
- {
- }
+ piter_isubset_(const P& p, const abstract::topology<T>& topo);
- void impl_start()
- {
- p_.start();
- while (p_.is_valid() and isubset_(p_) == false)
- p_.next();
- }
+ void impl_start();
- void impl_next()
- {
- do
- p_.next();
- while (p_.is_valid() and isubset_(p_) == false);
- }
+ void impl_next();
- void impl_invalidate()
- {
- p_.invalidate();
- }
+ void impl_invalidate();
- bool impl_is_valid() const
- {
- return p_.is_valid();
- }
+ bool impl_is_valid() const;
- point_t impl_to_point() const
- {
- return p_.to_point();
- }
-
- const point_t* impl_point_adr() const
- {
- return p_.point_adr();
- }
+ point_t impl_to_point() const;
- const topo_t topo() const
- {
- topo_t tmp(p_.topo(), isubset_);
- return tmp;
- }
+ const point_t* impl_point_adr() const;
+ const topo_t topo() const;
+
protected:
piter_t p_;
const isubset_t& isubset_;
}; // end of class oln::piter_isubset_<point>
-
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename piter_t, typename isubset_t>
+ template <typename T>
+ piter_isubset_<piter_t, isubset_t>::piter_isubset_(const abstract::topology<T>& topo)
+ : p_(topo),
+ isubset_(topo.exact().subset())
+ {
+ }
+
+ template <typename piter_t, typename isubset_t>
+ template <typename P, typename T>
+ piter_isubset_<piter_t, isubset_t>::piter_isubset_(const P& p, const abstract::topology<T>& topo)
+ : p_(p, topo),
+ isubset_(topo.exact().subset())
+ {
+ }
+
+ template <typename piter_t, typename isubset_t>
+ void
+ piter_isubset_<piter_t, isubset_t>::impl_start()
+ {
+ p_.start();
+ while (p_.is_valid() and isubset_(p_) == false)
+ p_.next();
+ }
+
+ template <typename piter_t, typename isubset_t>
+ void
+ piter_isubset_<piter_t, isubset_t>::impl_next()
+ {
+ do
+ p_.next();
+ while (p_.is_valid() and isubset_(p_) == false);
+ }
+
+ template <typename piter_t, typename isubset_t>
+ void
+ piter_isubset_<piter_t, isubset_t>::impl_invalidate()
+ {
+ p_.invalidate();
+ }
+
+ template <typename piter_t, typename isubset_t>
+ bool
+ piter_isubset_<piter_t, isubset_t>::impl_is_valid() const
+ {
+ return p_.is_valid();
+ }
+
+ template <typename piter_t, typename isubset_t>
+ typename piter_isubset_<piter_t, isubset_t>::point_t
+ piter_isubset_<piter_t, isubset_t>::impl_to_point() const
+ {
+ return p_.to_point();
+ }
+
+ template <typename piter_t, typename isubset_t>
+ const typename piter_isubset_<piter_t, isubset_t>::point_t*
+ piter_isubset_<piter_t, isubset_t>::impl_point_adr() const
+ {
+ return p_.point_adr();
+ }
+
+ template <typename piter_t, typename isubset_t>
+ const typename piter_isubset_<piter_t, isubset_t>::topo_t
+ piter_isubset_<piter_t, isubset_t>::topo() const
+ {
+ topo_t tmp(p_.topo(), isubset_);
+ return tmp;
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/topo_add_isubset.hh
===================================================================
--- oln/core/gen/topo_add_isubset.hh (revision 607)
+++ oln/core/gen/topo_add_isubset.hh (working copy)
@@ -67,41 +67,20 @@
public:
- topo_add_isubset()
- {
- }
+ topo_add_isubset();
- topo_add_isubset(const topo_t& topo, const isubset_t& isubset)
- : topo_(topo),
- isubset_(isubset)
- {
- }
+ topo_add_isubset(const topo_t& topo, const isubset_t& isubset);
- bool impl_has(const point_t& p) const
- {
- return topo_.has(p) and isubset_(p) == true;
- }
-
- bool impl_has_large(const point_t& p) const
- {
- return topo_.has(p) and isubset_(p) == true;
- }
+ bool impl_has(const point_t& p) const;
- const topo_t& delegate() const
- {
- return topo_;
- }
+ bool impl_has_large(const point_t& p) const;
- const isubset_t& impl_subset() const
- {
- return isubset_;
- }
+ const topo_t& delegate() const;
- operator topo_t() const
- {
- return topo_;
- }
+ const isubset_t& impl_subset() const;
+ operator topo_t() const;
+
protected:
topo_t topo_;
@@ -109,6 +88,57 @@
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename topo_t, typename isubset_t>
+ topo_add_isubset<topo_t, isubset_t>::topo_add_isubset()
+ {
+ }
+
+ template <typename topo_t, typename isubset_t>
+ topo_add_isubset<topo_t, isubset_t>::topo_add_isubset(const topo_t& topo, const isubset_t& isubset)
+ : topo_(topo),
+ isubset_(isubset)
+ {
+ }
+
+ template <typename topo_t, typename isubset_t>
+ bool
+ topo_add_isubset<topo_t, isubset_t>::impl_has(const point_t& p) const
+ {
+ return topo_.has(p) and isubset_(p) == true;
+ }
+
+ template <typename topo_t, typename isubset_t>
+ bool
+ topo_add_isubset<topo_t, isubset_t>::impl_has_large(const point_t& p) const
+ {
+ return topo_.has(p) and isubset_(p) == true;
+ }
+
+ template <typename topo_t, typename isubset_t>
+ const topo_t&
+ topo_add_isubset<topo_t, isubset_t>::delegate() const
+ {
+ return topo_;
+ }
+
+ template <typename topo_t, typename isubset_t>
+ const isubset_t&
+ topo_add_isubset<topo_t, isubset_t>::impl_subset() const
+ {
+ return isubset_;
+ }
+
+ template <typename topo_t, typename isubset_t>
+ topo_add_isubset<topo_t, isubset_t>::operator topo_t() const
+ {
+ return topo_;
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/bbox.hh
===================================================================
--- oln/core/gen/bbox.hh (revision 606)
+++ oln/core/gen/bbox.hh (working copy)
@@ -37,29 +37,29 @@
{
// Forward declarations.
- template <typename point> class bbox_;
- template <typename point> class bbox_fwd_piter_;
- template <typename point> class bbox_bkd_piter_;
+ template <typename point_t> class bbox_;
+ template <typename point_t> class bbox_fwd_piter_;
+ template <typename point_t> class bbox_bkd_piter_;
// Super type declaration.
- template <typename point>
- struct set_super_type< bbox_<point> >
+ template <typename point_t>
+ struct set_super_type< bbox_<point_t> >
{
- typedef bbox_<point> self_t;
+ typedef bbox_<point_t> self_t;
typedef point_set_entry<self_t> ret;
};
- /// Virtual types associated to oln::bbox_<point>.
- template <typename point>
- struct vtypes< bbox_<point> >
+ /// Virtual types associated to oln::bbox_<point_t>.
+ template <typename point_t>
+ struct vtypes< bbox_<point_t> >
{
- typedef point point_type;
- typedef bbox_fwd_piter_<point> fwd_piter_type;
- typedef bbox_bkd_piter_<point> bkd_piter_type;
+ typedef point_t point_type;
+ typedef bbox_fwd_piter_<point_t> fwd_piter_type;
+ typedef bbox_bkd_piter_<point_t> bkd_piter_type;
- typedef bbox_<point> bbox_type;
+ typedef bbox_<point_t> bbox_type;
typedef mlc::true_ is_random_accessible_type;
typedef mlc::true_ has_know_size_type;
@@ -68,153 +68,197 @@
/// Bounding box class based on a point class.
- template <typename point>
- class bbox_ : public point_set_entry< bbox_<point> >,
- private mlc::assert_< mlc_is_a(point, abstract::point) >
+ template <typename point_t>
+ class bbox_ : public point_set_entry< bbox_<point_t> >,
+ private mlc::assert_< mlc_is_a(point_t, abstract::point) >
{
- typedef point point_t;
- typedef bbox_<point> self_t;
+ typedef bbox_<point_t> self_t;
typedef point_set_entry<self_t> super_t;
- typedef oln_type_of(point, coord) coord_t;
+ typedef oln_type_of(point_t, coord) coord_t;
typedef oln_type_of(point_t, dim) dim;
enum { n = mlc_value(dim) };
public:
- bbox_()
- {
- flush();
- }
+ bbox_();
- bbox_(const point_t& pmin, const point_t& pmax)
- {
- this->pmin_ = pmin;
- this->pmax_ = pmax;
- is_valid_ = true;
+ bbox_(const point_t& pmin, const point_t& pmax);
- for (unsigned i = 0; i < n; ++i)
- precondition(pmax[i] >= pmin[i]);
- }
+ bbox_(const bbox_<point_t>& rhs);
- bbox_(const self_t& rhs)
- {
- // FIXME: Remove these 3 lines?
- precondition(rhs.is_valid());
- for (unsigned i = 0; i < n; ++i)
- precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+ bbox_<point_t>& operator=(const bbox_<point_t>& rhs);
- this->pmin_ = rhs.pmin_;
- this->pmax_ = rhs.pmax_;
- is_valid_ = rhs.is_valid_;
+ unsigned impl_npoints() const;
- for (unsigned i = 0; i < n; ++i)
- postcondition(this->pmax_[i] >= this->pmin_[i]);
- }
+ bool impl_has(const point_t& p) const;
- self_t& operator=(const self_t& rhs)
- {
- // FIXME: Remove these 3 lines?
- precondition(rhs.is_valid());
- for (unsigned i = 0; i < n; ++i)
- precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+ void flush();
- this->pmin_ = rhs.pmin_;
- this->pmax_ = rhs.pmax_;
- is_valid_ = rhs.is_valid_;
+ void init_with(const point_t& p);
- for (unsigned i = 0; i < n; ++i)
- postcondition(this->pmax_[i] >= this->pmin_[i]);
+ void update_with(const point_t& p);
- return *this;
- }
-
- unsigned impl_npoints() const
- {
- unsigned count = 1;
- for (unsigned i = 0; i < n; ++i)
- count *= this->len(i);
- return count;
- }
+ void take(const point_t& p);
- bool impl_has(const point_t& p) const
- {
- precondition(is_valid_);
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
- return false;
- return true;
- }
+ // FIXME: Add "update : (rhs : exact)"
- void flush()
- {
- is_valid_ = false;
- }
+ bool includes(const bbox_<point_t>& rhs) const;
- void init_with(const point_t& p)
- {
- precondition(not is_valid_);
- this->pmin_ = p;
- this->pmax_ = p;
- is_valid_ = true;
- }
+ bool impl_is_valid() const;
- void update_with(const point_t& p)
- {
- precondition(is_valid_);
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i])
- this->pmin_[i] = p[i];
- else if (p[i] > this->pmax_[i])
- this->pmax_[i] = p[i];
- }
+ void impl_print(std::ostream& ostr) const;
- void take(const point_t& p)
- {
- if (not is_valid_)
- {
- init_with(p);
- return;
- }
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i])
- this->pmin_[i] = p[i];
- else if (p[i] > this->pmax_[i])
- this->pmax_[i] = p[i];
- }
+ protected:
- // FIXME: Add "update : (rhs : exact)"
+ bool is_valid_;
- bool includes(const self_t& rhs) const
- {
- precondition(is_valid_ and rhs.is_valid());
- for (unsigned i = 0; i < n; ++i)
- if (rhs.pmin()[i] < this->pmin_[i] or rhs.pmax()[i] > this->pmax_[i])
- return false;
- return true;
- }
+ }; // end of class oln::bbox_<point_t>
- bool impl_is_valid() const
- {
- return is_valid_;
- }
- void impl_print(std::ostream& ostr) const
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ bbox_<point_t>::bbox_()
+ {
+ flush();
+ }
+
+ template <typename point_t>
+ bbox_<point_t>::bbox_(const point_t& pmin, const point_t& pmax)
+ {
+ this->pmin_ = pmin;
+ this->pmax_ = pmax;
+ is_valid_ = true;
+
+ for (unsigned i = 0; i < n; ++i)
+ precondition(pmax[i] >= pmin[i]);
+ }
+
+ template <typename point_t>
+ bbox_<point_t>::bbox_(const bbox_<point_t>& rhs)
+ {
+ // FIXME: Remove these 3 lines?
+ precondition(rhs.is_valid());
+ for (unsigned i = 0; i < n; ++i)
+ precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+
+ this->pmin_ = rhs.pmin_;
+ this->pmax_ = rhs.pmax_;
+ is_valid_ = rhs.is_valid_;
+
+ for (unsigned i = 0; i < n; ++i)
+ postcondition(this->pmax_[i] >= this->pmin_[i]);
+ }
+
+ template <typename point_t>
+ bbox_<point_t>& bbox_<point_t>::operator=(const bbox_<point_t>& rhs)
+ {
+ // FIXME: Remove these 3 lines?
+ precondition(rhs.is_valid());
+ for (unsigned i = 0; i < n; ++i)
+ precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+
+ this->pmin_ = rhs.pmin_;
+ this->pmax_ = rhs.pmax_;
+ is_valid_ = rhs.is_valid_;
+
+ for (unsigned i = 0; i < n; ++i)
+ postcondition(this->pmax_[i] >= this->pmin_[i]);
+
+ return *this;
+ }
+
+ template <typename point_t>
+ unsigned bbox_<point_t>::impl_npoints() const
+ {
+ unsigned count = 1;
+ for (unsigned i = 0; i < n; ++i)
+ count *= this->len(i);
+ return count;
+ }
+
+ template <typename point_t>
+ bool bbox_<point_t>::impl_has(const point_t& p) const
+ {
+ precondition(is_valid_);
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
+ return false;
+ return true;
+ }
+
+ template <typename point_t>
+ void bbox_<point_t>::flush()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename point_t>
+ void bbox_<point_t>::init_with(const point_t& p)
+ {
+ precondition(not is_valid_);
+ this->pmin_ = p;
+ this->pmax_ = p;
+ is_valid_ = true;
+ }
+
+ template <typename point_t>
+ void bbox_<point_t>::update_with(const point_t& p)
+ {
+ precondition(is_valid_);
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] < this->pmin_[i])
+ this->pmin_[i] = p[i];
+ else if (p[i] > this->pmax_[i])
+ this->pmax_[i] = p[i];
+ }
+
+ template <typename point_t>
+ void bbox_<point_t>::take(const point_t& p)
+ {
+ if (not is_valid_)
{
- ostr << "{ pmin=" << this->pmin_
- << ", pmax=" << this->pmax_
- << ", valid=" << is_valid_
- << " }";
+ init_with(p);
+ return;
}
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] < this->pmin_[i])
+ this->pmin_[i] = p[i];
+ else if (p[i] > this->pmax_[i])
+ this->pmax_[i] = p[i];
+ }
- protected:
+ template <typename point_t>
+ bool bbox_<point_t>::includes(const bbox_<point_t>& rhs) const
+ {
+ precondition(is_valid_ and rhs.is_valid());
+ for (unsigned i = 0; i < n; ++i)
+ if (rhs.pmin()[i] < this->pmin_[i] or rhs.pmax()[i] > this->pmax_[i])
+ return false;
+ return true;
+ }
- bool is_valid_;
+ template <typename point_t>
+ bool bbox_<point_t>::impl_is_valid() const
+ {
+ return is_valid_;
+ }
- }; // end of class oln::bbox_<point>
+ template <typename point_t>
+ void bbox_<point_t>::impl_print(std::ostream& ostr) const
+ {
+ ostr << "{ pmin=" << this->pmin_
+ << ", pmax=" << this->pmax_
+ << ", valid=" << is_valid_
+ << " }";
+ }
+# endif
+
} // end of namespace oln
Index: oln/core/gen/topo_bbox.hh
===================================================================
--- oln/core/gen/topo_bbox.hh (revision 607)
+++ oln/core/gen/topo_bbox.hh (working copy)
@@ -70,39 +70,19 @@
public:
- topo_bbox_()
- {
- }
+ topo_bbox_();
- topo_bbox_(const bbox_t& bb)
- : bb_(bb)
- {
- }
+ topo_bbox_(const bbox_t& bb);
- const bbox_t& impl_bbox() const
- {
- return bb_;
- }
+ const bbox_t& impl_bbox() const;
- bbox_t& impl_bbox()
- {
- return bb_;
- }
+ bbox_t& impl_bbox();
- bbox_t& impl_lbbox()
- {
- return bb_;
- }
+ bbox_t& impl_lbbox();
- bool impl_has(const point& p) const
- {
- return bb_.has(p);
- }
+ bool impl_has(const point& p) const;
- bool impl_has_large(const point& p) const
- {
- return bb_.has(p);
- }
+ bool impl_has_large(const point& p) const;
protected:
@@ -111,6 +91,57 @@
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point>
+ topo_bbox_<point>::topo_bbox_()
+ {
+ }
+
+ template <typename point>
+ topo_bbox_<point>::topo_bbox_(const typename topo_bbox_<point>::bbox_t& bb)
+ : bb_(bb)
+ {
+ }
+
+ template <typename point>
+ const typename topo_bbox_<point>::bbox_t&
+ topo_bbox_<point>::impl_bbox() const
+ {
+ return bb_;
+ }
+
+ template <typename point>
+ typename topo_bbox_<point>::bbox_t&
+ topo_bbox_<point>::impl_bbox()
+ {
+ return bb_;
+ }
+
+ template <typename point>
+ typename topo_bbox_<point>::bbox_t&
+ topo_bbox_<point>::impl_lbbox()
+ {
+ return bb_;
+ }
+
+ template <typename point>
+ bool
+ topo_bbox_<point>::impl_has(const point& p) const
+ {
+ return bb_.has(p);
+ }
+
+ template <typename point>
+ bool
+ topo_bbox_<point>::impl_has_large(const point& p) const
+ {
+ return lbb_.has(p);
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/neighb.hh
===================================================================
--- oln/core/gen/neighb.hh (revision 606)
+++ oln/core/gen/neighb.hh (working copy)
@@ -70,34 +70,16 @@
public:
- neighb_()
- {
- }
+ neighb_();
- self_t& add(const dpoint& dp)
- {
- s_.insert(dp);
- s_.insert(-dp);
- update_();
- return *this;
- }
+ neighb_<dpoint>& add(const dpoint& dp);
template <typename D>
- self_t& add(const abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
+ neighb_<dpoint>& add(const abstract::dpoint<D>& dp);
- unsigned card() const
- {
- return v_.size();
- }
+ unsigned card() const;
- dpoint dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
+ dpoint dp(unsigned i) const;
// void print(std::ostream& ostr) const;
// friend std::ostream& operator<<(std::ostream& ostr, const neighb_<dpoint>& nbh);
@@ -107,14 +89,58 @@
std::set<dpoint> s_;
std::vector<dpoint> v_;
- void update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
- }
+ void update_();
}; // end of class oln::neighb_<dpoint>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ template <typename dpoint>
+ neighb_<dpoint>::neighb_()
+ {
+ }
+
+ template <typename dpoint>
+ neighb_<dpoint>& neighb_<dpoint>::add(const dpoint& dp)
+ {
+ s_.insert(dp);
+ s_.insert(-dp);
+ update_();
+ return *this;
+ }
+
+ template <typename dpoint>
+ template <typename D>
+ neighb_<dpoint>& neighb_<dpoint>::add(const abstract::dpoint<D>& dp)
+ {
+ return this->add(dp.exact());
+ }
+
+ template <typename dpoint>
+ unsigned neighb_<dpoint>::card() const
+ {
+ return v_.size();
+ }
+
+ template <typename dpoint>
+ dpoint neighb_<dpoint>::dp(unsigned i) const
+ {
+ precondition(i < v_.size());
+ return v_[i];
+ }
+
+ template <typename dpoint>
+ void neighb_<dpoint>::update_()
+ {
+ v_.clear();
+ std::copy(s_.begin(), s_.end(),
+ std::back_inserter(v_));
+ }
+
+# endif
} // end of namespace oln
Index: oln/core/gen/fwd_niter_neighb.hh
===================================================================
--- oln/core/gen/fwd_niter_neighb.hh (revision 607)
+++ oln/core/gen/fwd_niter_neighb.hh (working copy)
@@ -73,80 +73,49 @@
template <typename P, typename T>
fwd_niter_neighb_(const abstract::iterator_on_points<P>& it,
- const abstract::topology<T>& topo)
- : p_ref_(it.point_adr()),
- nbh_(topo.exact().neighborhood())
- {
- precondition(nbh_.card() > 0);
- i_ = -1;
- }
+ const abstract::topology<T>& topo);
-// template <typename P, typename N>
-// fwd_niter_neighb_(const abstract::iterator_on_points<P>& it,
-// const abstract::neighborhood<N>& nbh)
-// : p_ref_(it.point_adr()),
-// nbh_(nbh.exact())
-// {
-// precondition(nbh_.card() > 0);
-// i_ = -1;
-// }
+ // template <typename P, typename N>
+ // fwd_niter_neighb_(const abstract::iterator_on_points<P>& it,
+ // const abstract::neighborhood<N>& nbh)
+ // : p_ref_(it.point_adr()),
+ // nbh_(nbh.exact())
+ // {
+ // precondition(nbh_.card() > 0);
+ // i_ = -1;
+ // }
-// template <typename P, typename T>
-// fwd_niter_neighb_(const abstract::point<P>& p,
-// const abstract::topology<T>& topo)
-// : p_ref_(&(p.exact())),
-// nbh_(topo.exact().neighborhood())
-// {
-// precondition(nbh_.card() > 0);
-// i_ = -1;
-// }
+ // template <typename P, typename T>
+ // fwd_niter_neighb_(const abstract::point<P>& p,
+ // const abstract::topology<T>& topo)
+ // : p_ref_(&(p.exact())),
+ // nbh_(topo.exact().neighborhood())
+ // {
+ // precondition(nbh_.card() > 0);
+ // i_ = -1;
+ // }
-// template <typename P, typename N>
-// fwd_niter_neighb_(const abstract::point<P>& p,
-// const abstract::neighborhood<N>& nbh)
-// : p_ref_(&(p.exact())),
-// nbh_(nbh.exact())
-// {
-// precondition(nbh_.card() > 0);
-// i_ = -1;
-// }
+ // template <typename P, typename N>
+ // fwd_niter_neighb_(const abstract::point<P>& p,
+ // const abstract::neighborhood<N>& nbh)
+ // : p_ref_(&(p.exact())),
+ // nbh_(nbh.exact())
+ // {
+ // precondition(nbh_.card() > 0);
+ // i_ = -1;
+ // }
- void impl_start()
- {
- i_ = 0;
- p_ = *p_ref_+ nbh_.dp(i_);
- }
+ void impl_start();
- void impl_next()
- {
- ++i_;
- if (i_ == int(nbh_.card()))
- {
- i_ = -1;
- return;
- }
- p_ = *p_ref_ + nbh_.dp(i_);
- }
+ void impl_next();
- void impl_invalidate()
- {
- i_ = -1;
- }
+ void impl_invalidate();
- bool impl_is_valid() const
- {
- return i_ != -1;
- }
+ bool impl_is_valid() const;
- point_t impl_to_point() const
- {
- return p_;
- }
+ point_t impl_to_point() const;
- const point_t* impl_point_adr() const
- {
- return &p_;
- }
+ const point_t* impl_point_adr() const;
protected:
@@ -158,6 +127,73 @@
}; // end of class oln::fwd_niter_neighb_<point_t>
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ template <typename P, typename T>
+ fwd_niter_neighb_<point_t>::fwd_niter_neighb_(const abstract::iterator_on_points<P>& it,
+ const abstract::topology<T>& topo)
+ : p_ref_(it.point_adr()),
+ nbh_(topo.exact().neighborhood())
+ {
+ precondition(nbh_.card() > 0);
+ i_ = -1;
+ }
+
+ template <typename point_t>
+ void
+ fwd_niter_neighb_<point_t>::impl_start()
+ {
+ i_ = 0;
+ p_ = *p_ref_+ nbh_.dp(i_);
+ }
+
+ template <typename point_t>
+ void
+ fwd_niter_neighb_<point_t>::impl_next()
+ {
+ ++i_;
+ if (i_ == int(nbh_.card()))
+ {
+ i_ = -1;
+ return;
+ }
+ p_ = *p_ref_ + nbh_.dp(i_);
+ }
+
+ template <typename point_t>
+ void
+ fwd_niter_neighb_<point_t>::impl_invalidate()
+ {
+ i_ = -1;
+ }
+
+ template <typename point_t>
+ bool
+ fwd_niter_neighb_<point_t>::impl_is_valid() const
+ {
+ return i_ != -1;
+ }
+
+ template <typename point_t>
+ point_t
+ fwd_niter_neighb_<point_t>::impl_to_point() const
+ {
+ return p_;
+ }
+
+ template <typename point_t>
+ const point_t*
+ fwd_niter_neighb_<point_t>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+# endif
+
+
} // end of namespace oln
Index: oln/core/gen/bbox_fwd_piter.hh
===================================================================
--- oln/core/gen/bbox_fwd_piter.hh (revision 606)
+++ oln/core/gen/bbox_fwd_piter.hh (working copy)
@@ -69,14 +69,21 @@
public:
- bbox_fwd_piter_(const bbox_<point>& bb)
- : super_t(bb)
- {
- }
-
+ bbox_fwd_piter_(const bbox_<point>& bb);
+
}; // end of class oln::bbox_fwd_piter_<point>
-
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point>
+ bbox_fwd_piter_<point>::bbox_fwd_piter_(const bbox_<point>& bb)
+ : super_t(bb)
+ {
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/fwd_piter_bbox.hh
===================================================================
--- oln/core/gen/fwd_piter_bbox.hh (revision 607)
+++ oln/core/gen/fwd_piter_bbox.hh (working copy)
@@ -72,27 +72,44 @@
public:
template <typename T>
- fwd_piter_bbox_(const abstract::topology<T>& topo)
- : super_t(topo.exact().bbox())
- {
- }
+ fwd_piter_bbox_(const abstract::topology<T>& topo);
- void print(std::ostream& ostr) const
- {
- ostr << "{ p=" << this->p_
- << " }";
- }
+ void print(std::ostream& ostr) const;
- friend
- std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<point_t>& t)
- {
- t.print(ostr);
- return ostr;
- }
-
}; // end of class oln::fwd_piter_bbox_<point>
-
+
+ template <typename point_t>
+ std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<point_t>& t);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ template <typename T>
+ fwd_piter_bbox_<point_t>::fwd_piter_bbox_(const abstract::topology<T>& topo)
+ : super_t(topo.exact().bbox())
+ {
+ }
+
+ template <typename point_t>
+ void fwd_piter_bbox_<point_t>::print(std::ostream& ostr) const
+ {
+ ostr << "{ p=" << this->p_
+ << " }";
+ }
+
+ template <typename point_t>
+ std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<point_t>& t)
+ {
+ t.print(ostr);
+ return ostr;
+ }
+
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/fwd_qiter_win.hh
===================================================================
--- oln/core/gen/fwd_qiter_win.hh (revision 607)
+++ oln/core/gen/fwd_qiter_win.hh (working copy)
@@ -73,60 +73,22 @@
template <typename P, typename D>
fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
- const window_<D>& win)
- : p_ref_(it.point_adr()),
- win_(win)
- {
- precondition(win_.card() > 0);
- i_ = -1;
- }
-
+ const window_<D>& win);
template <typename P, typename D>
fwd_qiter_win_(const abstract::point<P>& p,
- const window_<D>& win)
- : p_ref_(&(p.exact())),
- win_(win)
- {
- precondition(win_.card() > 0);
- i_ = -1;
- }
+ const window_<D>& win);
- void impl_start()
- {
- i_ = 0;
- p_ = *p_ref_+ win_.dp(i_);
- }
+ void impl_start();
- void impl_next()
- {
- ++i_;
- if (i_ == int(win_.card()))
- {
- i_ = -1;
- return;
- }
- p_ = *p_ref_ + win_.dp(i_);
- }
+ void impl_next();
- void impl_invalidate()
- {
- i_ = -1;
- }
+ void impl_invalidate();
- bool impl_is_valid() const
- {
- return i_ != -1;
- }
+ bool impl_is_valid() const;
- point_t impl_to_point() const
- {
- return p_;
- }
+ point_t impl_to_point() const;
- const point_t* impl_point_adr() const
- {
- return &p_;
- }
+ const point_t* impl_point_adr() const;
protected:
@@ -136,8 +98,84 @@
point_t p_;
}; // end of class oln::fwd_qiter_win_<point_t>
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ template <typename P, typename D>
+ fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
+ const window_<D>& win)
+ : p_ref_(it.point_adr()),
+ win_(win)
+ {
+ precondition(win_.card() > 0);
+ i_ = -1;
+ }
+
+ template <typename point_t>
+ template <typename P, typename D>
+ fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::point<P>& p,
+ const window_<D>& win)
+ : p_ref_(&(p.exact())),
+ win_(win)
+ {
+ precondition(win_.card() > 0);
+ i_ = -1;
+ }
+
+ template <typename point_t>
+ void
+ fwd_qiter_win_<point_t>::impl_start()
+ {
+ i_ = 0;
+ p_ = *p_ref_+ win_.dp(i_);
+ }
+
+ template <typename point_t>
+ void
+ fwd_qiter_win_<point_t>::impl_next()
+ {
+ ++i_;
+ if (i_ == int(win_.card()))
+ {
+ i_ = -1;
+ return;
+ }
+ p_ = *p_ref_ + win_.dp(i_);
+ }
+
+ template <typename point_t>
+ void
+ fwd_qiter_win_<point_t>::impl_invalidate()
+ {
+ i_ = -1;
+ }
+
+ template <typename point_t>
+ bool
+ fwd_qiter_win_<point_t>::impl_is_valid() const
+ {
+ return i_ != -1;
+ }
+
+ template <typename point_t>
+ point_t
+ fwd_qiter_win_<point_t>::impl_to_point() const
+ {
+ return p_;
+ }
+
+ template <typename point_t>
+ const point_t*
+ fwd_qiter_win_<point_t>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/window.hh
===================================================================
--- oln/core/gen/window.hh (revision 607)
+++ oln/core/gen/window.hh (working copy)
@@ -44,49 +44,77 @@
public:
- window_()
- {
- }
+ window_();
- self_t& add(const dpoint& dp)
- {
- s_.insert(dp);
- update_();
- return *this;
- }
+ window_<dpoint>& add(const dpoint& dp);
template <typename D>
- self_t& add(const abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
+ window_<dpoint>& add(const abstract::dpoint<D>& dp);
- unsigned card() const
- {
- return v_.size();
- }
+ unsigned card() const;
- dpoint dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
+ dpoint dp(unsigned i) const;
protected:
std::set<dpoint> s_;
std::vector<dpoint> v_;
- void update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
- }
+ void update_();
}; // end of class oln::window_<dpoint>
-
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename dpoint>
+ window_<dpoint>::window_()
+ {
+ }
+
+ template <typename dpoint>
+ window_<dpoint>&
+ window_<dpoint>::add(const dpoint& dp)
+ {
+ s_.insert(dp);
+ update_();
+ return *this;
+ }
+
+ template <typename dpoint>
+ template <typename D>
+ window_<dpoint>&
+ window_<dpoint>::add(const abstract::dpoint<D>& dp)
+ {
+ return this->add(dp.exact());
+ }
+
+ template <typename dpoint>
+ unsigned
+ window_<dpoint>::card() const
+ {
+ return v_.size();
+ }
+
+ template <typename dpoint>
+ dpoint
+ window_<dpoint>::dp(unsigned i) const
+ {
+ precondition(i < v_.size());
+ return v_[i];
+ }
+
+ template <typename dpoint>
+ void
+ window_<dpoint>::update_()
+ {
+ v_.clear();
+ std::copy(s_.begin(), s_.end(),
+ std::back_inserter(v_));
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/topo_lbbox.hh
===================================================================
--- oln/core/gen/topo_lbbox.hh (revision 606)
+++ oln/core/gen/topo_lbbox.hh (working copy)
@@ -68,38 +68,17 @@
public:
- topo_lbbox_()
- {
- }
+ topo_lbbox_();
- topo_lbbox_(const bbox_t& bb, unsigned border)
- : bb_(bb), border_(border)
- {
- typedef oln_type_of(point, dpoint) dpoint_t;
- dpoint_t dp;
- dp.set_all(border);
- lbb_ = bbox_<point>(bb_.pmin() - dp, bb_.pmax() + dp);
- }
+ topo_lbbox_(const bbox_t& bb, unsigned border);
- const bbox_t& impl_bbox() const
- {
- return bb_;
- }
+ const bbox_t& impl_bbox() const;
- bool impl_has(const point& p) const
- {
- return bb_.has(p);
- }
+ bool impl_has(const point& p) const;
- bool impl_has_large(const point& p) const
- {
- return lbb_.has(p);
- }
+ bool impl_has_large(const point& p) const;
- const bbox_t& lbbox() const
- {
- return lbb_;
- }
+ const bbox_t& lbbox() const;
protected:
@@ -110,6 +89,54 @@
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point>
+ topo_lbbox_<point>::topo_lbbox_()
+ {
+ }
+
+ template <typename point>
+ topo_lbbox_<point>::topo_lbbox_(const typename topo_lbbox_<point>::bbox_t& bb,
+ unsigned border)
+ : bb_(bb), border_(border)
+ {
+ typedef oln_type_of(point, dpoint) dpoint_t;
+ dpoint_t dp;
+ dp.set_all(border);
+ lbb_ = bbox_<point>(bb_.pmin() - dp, bb_.pmax() + dp);
+ }
+
+ template <typename point>
+ const typename topo_lbbox_<point>::bbox_t&
+ topo_lbbox_<point>::impl_bbox() const
+ {
+ return bb_;
+ }
+
+ template <typename point>
+ bool
+ topo_lbbox_<point>::impl_has(const point& p) const
+ {
+ return bb_.has(p);
+ }
+
+ template <typename point>
+ bool
+ topo_lbbox_<point>::impl_has_large(const point& p) const
+ {
+ return lbb_.has(p);
+ }
+
+ template <typename point>
+ const typename topo_lbbox_<point>::bbox_t&
+ topo_lbbox_<point>::lbbox() const
+ {
+ return lbb_;
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/bkd_piter_bbox.hh
===================================================================
--- oln/core/gen/bkd_piter_bbox.hh (revision 607)
+++ oln/core/gen/bkd_piter_bbox.hh (working copy)
@@ -72,27 +72,43 @@
public:
template <typename T>
- bkd_piter_bbox_(const abstract::topology<T>& topo)
- : super_t(topo.exact().bbox())
- {
- }
+ bkd_piter_bbox_(const abstract::topology<T>& topo);
- void print(std::ostream& ostr) const
- {
- ostr << "{ p=" << this->p_
- << " }";
- }
+ void print(std::ostream& ostr) const;
- friend
- std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<point_t>& t)
- {
- t.print(ostr);
- return ostr;
- }
-
}; // end of class oln::bkd_piter_bbox_<point_t>
-
+
+ template <typename point_t>
+ std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<point_t>& t);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t>
+ template <typename T>
+ bkd_piter_bbox_<point_t>::bkd_piter_bbox_(const abstract::topology<T>& topo)
+ : super_t(topo.exact().bbox())
+ {
+ }
+
+ template <typename point_t>
+ void bkd_piter_bbox_<point_t>::print(std::ostream& ostr) const
+ {
+ ostr << "{ p=" << this->p_
+ << " }";
+ }
+
+ template <typename point_t>
+ std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<point_t>& t)
+ {
+ t.print(ostr);
+ return ostr;
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/bbox_bkd_piter.hh
===================================================================
--- oln/core/gen/bbox_bkd_piter.hh (revision 606)
+++ oln/core/gen/bbox_bkd_piter.hh (working copy)
@@ -69,14 +69,21 @@
public:
- bbox_bkd_piter_(const bbox_<point>& bb)
- : super_t(bb)
- {
- }
+ bbox_bkd_piter_(const bbox_<point>& bb);
}; // end of class oln::bbox_bkd_piter_<point>
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point>
+ bbox_bkd_piter_<point>::bbox_bkd_piter_(const bbox_<point>& bb)
+ : super_t(bb)
+ {
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/mapimage.hh
===================================================================
--- oln/core/gen/mapimage.hh (revision 606)
+++ oln/core/gen/mapimage.hh (working copy)
@@ -81,33 +81,15 @@
public:
/// Ctor.
- mapimage(const value_t& val)
- : val_(val)
- {
- }
+ mapimage(const value_t& val);
- const topo_t& impl_topo() const
- {
- return topo_;
- }
+ const topo_t& impl_topo() const;
- value_t impl_op_read(const point_t& p) const
- {
- if (not has(p))
- return val_;
- return data_[p];
- }
+ value_t impl_op_read(const point_t& p) const;
- value_t& impl_op_readwrite(const point_t& p)
- {
- topo_.bbox().take(p);
- return data_[p];
- }
+ value_t& impl_op_readwrite(const point_t& p);
- bool impl_has(const point_t& p) const
- {
- return data_.find(p) != data_.end();
- }
+ bool impl_has(const point_t& p) const;
private:
@@ -117,6 +99,47 @@
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename point_t, typename value_t>
+ mapimage<point_t, value_t>::mapimage(const value_t& val)
+ : val_(val)
+ {
+ }
+
+ template <typename point_t, typename value_t>
+ const typename mapimage<point_t, value_t>::topo_t&
+ mapimage<point_t, value_t>::impl_topo() const
+ {
+ return topo_;
+ }
+
+ template <typename point_t, typename value_t>
+ value_t
+ mapimage<point_t, value_t>::impl_op_read(const point_t& p) const
+ {
+ if (not has(p))
+ return val_;
+ return data_[p];
+ }
+
+ template <typename point_t, typename value_t>
+ value_t&
+ mapimage<point_t, value_t>::impl_op_readwrite(const point_t& p)
+ {
+ topo_.bbox().take(p);
+ return data_[p];
+ }
+
+ template <typename point_t, typename value_t>
+ bool
+ mapimage<point_t, value_t>::impl_has(const point_t& p) const
+ {
+ return data_.find(p) != data_.end();
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/gen/topo_add_nbh.hh
===================================================================
--- oln/core/gen/topo_add_nbh.hh (revision 606)
+++ oln/core/gen/topo_add_nbh.hh (working copy)
@@ -69,31 +69,15 @@
{
public:
- topo_add_nbh()
- {
- }
+ topo_add_nbh();
- topo_add_nbh(const topo_t& topo, const nbh_t& nbh)
- : topo_(topo),
- nbh_(nbh)
- {
- }
+ topo_add_nbh(const topo_t& topo, const nbh_t& nbh);
+ const nbh_t& impl_neighborhood() const;
- const nbh_t& impl_neighborhood() const
- {
- return nbh_;
- }
+ const topo_t& delegate() const;
- const topo_t& delegate() const
- {
- return topo_;
- }
+ operator topo_t() const;
- operator topo_t() const
- {
- return topo_;
- }
-
protected:
topo_t topo_;
@@ -101,6 +85,40 @@
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename topo_t, typename nbh_t>
+ topo_add_nbh<topo_t, nbh_t>::topo_add_nbh()
+ {
+ }
+
+ template <typename topo_t, typename nbh_t>
+ topo_add_nbh<topo_t, nbh_t>::topo_add_nbh(const topo_t& topo, const nbh_t& nbh)
+ : topo_(topo),
+ nbh_(nbh)
+ {
+ }
+
+ template <typename topo_t, typename nbh_t>
+ const nbh_t& topo_add_nbh<topo_t, nbh_t>::impl_neighborhood() const
+ {
+ return nbh_;
+ }
+
+ template <typename topo_t, typename nbh_t>
+ const topo_t& topo_add_nbh<topo_t, nbh_t>::delegate() const
+ {
+ return topo_;
+ }
+
+ template <typename topo_t, typename nbh_t>
+ topo_add_nbh<topo_t, nbh_t>::operator topo_t() const
+ {
+ return topo_;
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/internal/tracked_ptr.hh
===================================================================
--- oln/core/internal/tracked_ptr.hh (revision 606)
+++ oln/core/internal/tracked_ptr.hh (working copy)
@@ -47,164 +47,233 @@
holders_t* holders_;
/// Coercion towards Boolean (for arithmetical tests).
- operator bool() const
- {
- invariant_();
- return ptr_ != 0;
- }
+ operator bool() const;
/// Negation (for arithmetical tests).
- bool operator not() const
- {
- invariant_();
- return not bool(*this);
- }
+ bool operator not() const;
/*! \brief Mimics the behavior of op-> for a pointer in the const case.
**
** \invariant Pointer proxy exists.
*/
- const T*const operator->() const
- {
- invariant_();
- precondition(ptr_ != 0);
- return ptr_;
- }
+ const T*const operator->() const;
/*! \brief Mimics the behavior of op-> for a pointer in the mutable case.
**
** \invariant Pointer proxy exists.
*/
- T*const operator->()
- {
- invariant_();
- precondition(ptr_ != 0);
- return ptr_;
- }
+ T*const operator->();
/// Ctor.
- tracked_ptr() :
- ptr_(0),
- holders_(0)
- {
- invariant_();
- }
+ tracked_ptr();
/// Ctor.
- tracked_ptr(T* ptr) :
- ptr_(ptr)
- {
- if (ptr == 0)
- holders_ = 0;
- else
- {
- holders_ = new holders_t;
- holders_->insert(this);
- }
- invariant_();
- }
+ tracked_ptr(T* ptr);
/// Cpy ctor.
- tracked_ptr(const self_t& rhs) :
- ptr_(rhs.ptr_),
- holders_(rhs.holders_)
- {
- rhs.invariant_();
- if (ptr_ != 0)
- holders_->insert(this);
- invariant_();
- }
+ tracked_ptr(const tracked_ptr<T>& rhs);
/// Assignment.
- self_t& operator=(const self_t& rhs)
- {
- invariant_();
- rhs.invariant_();
- if (&rhs == this or rhs.ptr_ == ptr_)
- // no-op
- return *this;
- clean_();
- ptr_ = rhs.ptr_;
- holders_ = rhs.holders_;
- holders_->insert(this);
- return *this;
- }
+ tracked_ptr<T>& operator=(const tracked_ptr<T>& rhs);
/// Assignment.
- self_t& operator=(T* ptr)
- {
- invariant_();
- if (ptr == ptr_)
- // no-op
- return *this;
- clean_();
- ptr_ = ptr;
- if (ptr == 0)
- holders_ = 0;
- else
- {
- holders_ = new holders_t;
- holders_->insert(this);
- }
- return *this;
- }
+ tracked_ptr<T>& operator=(T* ptr);
/// Dtor.
- ~tracked_ptr()
- {
- clean_();
- }
+ ~tracked_ptr();
- void invariant_() const
- {
- invariant((ptr_ and holders_) or (not ptr_ and not holders_));
- if (ptr_ == 0)
- return;
- invariant(holders_->size() > 0);
- self_t* this_ = const_cast<self_t*>(this);
- invariant(holders_->find(this_) != holders_->end());
- typename holders_t::const_iterator i;
- for (i = holders_->begin(); i != holders_->end(); ++i)
- invariant((*i)->ptr_ == ptr_);
- }
+ void invariant_() const;
- void clean_()
- {
- invariant_();
- if (ptr_ == 0)
- // no-op
- return;
- if (holders_->size() == 1)
- {
- delete ptr_;
- delete holders_;
- }
- else
- holders_->erase(this);
- ptr_ = 0;
- holders_ = 0;
- invariant_();
- }
+ void clean_();
- friend std::ostream& operator<<(std::ostream& ostr, const self_t& tp)
- {
- ostr << "tracked_ptr @ " << (&tp)
- << " { ptr = " << tp.ptr_
- << " / holders = ";
- if (tp.holders_ == 0)
- ostr << "0";
- else
- {
- typename holders_t::const_iterator i;
- for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i)
- ostr << (*i) << ' ';
- }
- ostr << " }";
- return ostr;
- }
};
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ tracked_ptr<T>::
+ tracked_ptr<T>::operator bool() const
+ {
+ invariant_();
+ return ptr_ != 0;
+ }
+
+ template <typename T>
+ /// Negation (for arithmetical tests).
+ bool tracked_ptr<T>::operator not() const
+ {
+ invariant_();
+ return not bool(*this);
+ }
+
+ template <typename T>
+ /*! \brief Mimics the behavior of op-> for a pointer in the const case.
+ **
+ ** \invariant Pointer proxy exists.
+ */
+ const T*const tracked_ptr<T>::operator->() const
+ {
+ invariant_();
+ precondition(ptr_ != 0);
+ return ptr_;
+ }
+
+ template <typename T>
+ /*! \brief Mimics the behavior of op-> for a pointer in the mutable case.
+ **
+ ** \invariant Pointer proxy exists.
+ */
+ T*const tracked_ptr<T>::operator->()
+ {
+ invariant_();
+ precondition(ptr_ != 0);
+ return ptr_;
+ }
+
+ template <typename T>
+ /// Ctor.
+ tracked_ptr<T>::tracked_ptr() :
+ ptr_(0),
+ holders_(0)
+ {
+ invariant_();
+ }
+
+ template <typename T>
+ /// Ctor.
+ tracked_ptr<T>::tracked_ptr(T* ptr) :
+ ptr_(ptr)
+ {
+ typedef std::set<tracked_ptr<T>*> holders_t;
+
+ if (ptr == 0)
+ holders_ = 0;
+ else
+ {
+ holders_ = new holders_t;
+ holders_->insert(this);
+ }
+ invariant_();
+ }
+
+ template <typename T>
+ /// Cpy ctor.
+ tracked_ptr<T>::tracked_ptr(const tracked_ptr<T>& rhs) :
+ ptr_(rhs.ptr_),
+ holders_(rhs.holders_)
+ {
+ rhs.invariant_();
+ if (ptr_ != 0)
+ holders_->insert(this);
+ invariant_();
+ }
+
+ template <typename T>
+ /// Assignment.
+ tracked_ptr<T>& tracked_ptr<T>::operator=(const tracked_ptr<T>& rhs)
+ {
+ invariant_();
+ rhs.invariant_();
+ if (&rhs == this or rhs.ptr_ == ptr_)
+ // no-op
+ return *this;
+ clean_();
+ ptr_ = rhs.ptr_;
+ holders_ = rhs.holders_;
+ holders_->insert(this);
+ return *this;
+ }
+
+ template <typename T>
+ /// Assignment.
+ tracked_ptr<T>& tracked_ptr<T>::operator=(T* ptr)
+ {
+ typedef std::set<tracked_ptr<T>*> holders_t;
+
+ invariant_();
+ if (ptr == ptr_)
+ // no-op
+ return *this;
+ clean_();
+ ptr_ = ptr;
+ if (ptr == 0)
+ holders_ = 0;
+ else
+ {
+ holders_ = new holders_t;
+ holders_->insert(this);
+ }
+ return *this;
+ }
+
+ /// Dtor.
+ template <typename T>
+ tracked_ptr<T>::~tracked_ptr()
+ {
+ clean_();
+ }
+
+ template <typename T>
+ void tracked_ptr<T>::invariant_() const
+ {
+ typedef std::set<tracked_ptr<T>*> holders_t;
+
+ invariant((ptr_ and holders_) or (not ptr_ and not holders_));
+ if (ptr_ == 0)
+ return;
+ invariant(holders_->size() > 0);
+ tracked_ptr<T>* this_ = const_cast<tracked_ptr<T>*>(this);
+ invariant(holders_->find(this_) != holders_->end());
+ typename holders_t::const_iterator i;
+ for (i = holders_->begin(); i != holders_->end(); ++i)
+ invariant((*i)->ptr_ == ptr_);
+ }
+
+ template <typename T>
+ void tracked_ptr<T>::clean_()
+ {
+ invariant_();
+ if (ptr_ == 0)
+ // no-op
+ return;
+ if (holders_->size() == 1)
+ {
+ delete ptr_;
+ delete holders_;
+ }
+ else
+ holders_->erase(this);
+ ptr_ = 0;
+ holders_ = 0;
+ invariant_();
+ }
+
+ template <typename T>
+ std::ostream& operator<<(std::ostream& ostr, const tracked_ptr<T>& tp)
+ {
+ typedef std::set<tracked_ptr<T>*> holders_t;
+
+ ostr << "tracked_ptr @ " << (&tp)
+ << " { ptr = " << tp.ptr_
+ << " / holders = ";
+ if (tp.holders_ == 0)
+ ostr << "0";
+ else
+ {
+ typename holders_t::const_iterator i;
+ for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i)
+ ostr << (*i) << ' ';
+ }
+ ostr << " }";
+ return ostr;
+ }
+
+
+# endif
+
} // end of namespace oln::internal
} // end of namespace oln
Index: oln/core/internal/topology_morpher.hh
===================================================================
--- oln/core/internal/topology_morpher.hh (revision 606)
+++ oln/core/internal/topology_morpher.hh (working copy)
@@ -70,9 +70,18 @@
struct topology_morpher : public topology_entry<E>
{
protected:
- topology_morpher() {}
+ topology_morpher();
};
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Topo, typename E>
+ topology_morpher<Topo, E>::topology_morpher()
+ {
+ }
+
+# endif
+
} // end of namespace oln::internal
Index: oln/core/internal/point_nd.hh
===================================================================
--- oln/core/internal/point_nd.hh (revision 606)
+++ oln/core/internal/point_nd.hh (working copy)
@@ -75,100 +75,164 @@
typedef oln_type_of(E, coord) coord_t;
typedef oln_type_of(E, dpoint) dpoint_t;
+
public:
enum { n = mlc_value(dim) };
+ typedef xtd::vec<n,coord_t> vec_t;
- coord_t operator[](unsigned i) const
- {
- assert(i < n);
- return v_[i];
- }
-
- coord_t& operator[](unsigned i)
- {
- assert(i < n);
- return v_[i];
- }
+ coord_t operator[](unsigned i) const;
+ coord_t& operator[](unsigned i);
- bool impl_equal(const self_t& rhs) const
- {
- return v_ == rhs.vec();
- }
+ bool impl_equal(const self_t& rhs) const;
- bool impl_less(const self_t& rhs) const
- {
- return xtd::lexi_less(v_, rhs.vec());
- }
+ bool impl_less(const self_t& rhs) const;
- E& impl_plus_equal(const dpoint_t& rhs)
- {
- v_ += rhs.vec();
- return this->exact();
- }
+ E& impl_plus_equal(const dpoint_t& rhs);
- E impl_plus(const dpoint_t& rhs) const
- {
- E tmp(v_ + rhs.vec());
- return tmp;
- }
+ E impl_plus(const dpoint_t& rhs) const;
- E& impl_minus_equal(const dpoint_t& rhs)
- {
- v_ += rhs.vec();
- return this->exact();
- }
+ E& impl_minus_equal(const dpoint_t& rhs);
- E impl_minus(const dpoint_t& rhs) const
- {
- E tmp(v_ - rhs.vec());
- return tmp;
- }
+ E impl_minus(const dpoint_t& rhs) const;
- dpoint_t impl_minus(const self_t& rhs) const
- {
- dpoint_t tmp(v_ - rhs.vec());
- return tmp;
- }
+ dpoint_t impl_minus(const self_t& rhs) const;
- const xtd::vec<n,coord_t>& vec() const
- {
- return v_;
- }
+ const vec_t& vec() const;
protected:
/// Ctor.
- point_nd()
- {}
+ point_nd();
/// Ctor.
- point_nd(const xtd::vec<n,coord_t>& v) :
- v_(v)
- {}
+ point_nd(const vec_t& v);
- typedef xtd::vec<n,coord_t> vec_t;
+ /// Dtor.
+ ~point_nd()
+ {
+ }
+
vec_t v_;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ typename point_nd<E>::coord_t
+ point_nd<E>::operator[](unsigned i) const
+ {
+ assert(i < n);
+ return v_[i];
+ }
+
+ template <typename E>
+ typename point_nd<E>::coord_t&
+ point_nd<E>::operator[](unsigned i)
+ {
+ assert(i < n);
+ return v_[i];
+ }
+
+ template <typename E>
+ bool point_nd<E>::impl_equal(const self_t& rhs) const
+ {
+ return v_ == rhs.vec();
+ }
+
+ template <typename E>
+ bool point_nd<E>::impl_less(const self_t& rhs) const
+ {
+ return xtd::lexi_less(v_, rhs.vec());
+ }
+
+ template <typename E>
+ E& point_nd<E>::impl_plus_equal(const dpoint_t& rhs)
+ {
+ v_ += rhs.vec();
+ return this->exact();
+ }
+
+ template <typename E>
+ E point_nd<E>::impl_plus(const dpoint_t& rhs) const
+ {
+ E tmp(v_ + rhs.vec());
+ return tmp;
+ }
+
+ template <typename E>
+ E& point_nd<E>::impl_minus_equal(const typename point_nd<E>::dpoint_t& rhs)
+ {
+ v_ += rhs.vec();
+ return this->exact();
+ }
+
+ template <typename E>
+ E point_nd<E>::impl_minus(const typename point_nd<E>::dpoint_t& rhs) const
+ {
+ E tmp(v_ - rhs.vec());
+ return tmp;
+ }
+
+ template <typename E>
+ typename point_nd<E>::dpoint_t
+ point_nd<E>::impl_minus(const self_t& rhs) const
+ {
+ typename point_nd<E>::dpoint_t tmp(v_ - rhs.vec());
+ return tmp;
+ }
+
+ template <typename E>
+ const typename point_nd<E>::vec_t&
+ point_nd<E>::vec() const
+ {
+ return v_;
+ }
+
+ template <typename E>
+ point_nd<E>::point_nd()
+ {}
+
+ template <typename E>
+ point_nd<E>::point_nd(const typename point_nd<E>::vec_t& v) :
+ v_(v)
+ {}
+
+// template <typename E>
+// point_nd<E>::~point_nd()
+// {}
+
+# endif
+
+
+
} // end of namespace oln::internal
+
template <typename E>
+ std::ostream& operator<<(std::ostream& ostr, const internal::point_nd<E>& p);
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
std::ostream& operator<<(std::ostream& ostr, const internal::point_nd<E>& p)
{
ostr << p.vec();
return ostr;
}
+# endif
+
/// internal::point_nd + internal::dpoint_nd
template <typename P, typename D>
struct case_ < xtd::op_plus, mlc::pair_<P,D>,
oln::id::op_plus_pointnd_dpointnd >
- : where_< mlc::and_< mlc_is_a(P, internal::point_nd),
- mlc_is_a(D, internal::dpoint_nd) > >
+ : where_< mlc::and_< mlc_is_a(P, internal::point_nd),
+ mlc_is_a(D, internal::dpoint_nd) > >
{
typedef oln_type_of(P, coord) P_coord;
typedef oln_type_of(D, coord) D_coord;
@@ -182,8 +246,8 @@
template <typename P, typename D>
struct case_ < xtd::op_minus, mlc::pair_<P,D>,
oln::id::op_minus_pointnd_dpointnd >
- : where_< mlc::and_< mlc_is_a(P, internal::point_nd),
- mlc_is_a(D, internal::dpoint_nd) > >
+ : where_< mlc::and_< mlc_is_a(P, internal::point_nd),
+ mlc_is_a(D, internal::dpoint_nd) > >
{
typedef oln_type_of(P, coord) P_coord;
typedef oln_type_of(D, coord) D_coord;
@@ -197,8 +261,8 @@
template <typename P1, typename P2>
struct case_ < xtd::op_minus, mlc::pair_<P1,P2>,
oln::id::op_minus_pointnd_pointnd >
- : where_< mlc::and_< mlc_is_a(P1, internal::point_nd),
- mlc_is_a(P2, internal::point_nd) > >
+ : where_< mlc::and_< mlc_is_a(P1, internal::point_nd),
+ mlc_is_a(P2, internal::point_nd) > >
{
typedef oln_type_of(P1, coord) P1_coord;
typedef oln_type_of(P2, coord) P2_coord;
Index: oln/core/internal/bbox_bkd_piter.hh
===================================================================
--- oln/core/internal/bbox_bkd_piter.hh (revision 606)
+++ oln/core/internal/bbox_bkd_piter.hh (working copy)
@@ -64,61 +64,21 @@
public:
- bbox_bkd_piter(const bbox_<point_t>& bb)
- : p_(),
- bb_(bb)
- {
- nop_ = bb_.pmin();
- --nop_[0];
- }
+ bbox_bkd_piter(const bbox_<point_t>& bb);
- const bbox_<point_t>& bbox() const
- {
- return bb_;
- }
+ const bbox_<point_t>& bbox() const;
- void impl_start()
- {
- p_ = bb_.pmax();
- invariant(implies(p_ != nop_, bb_.has(p_)));
- }
+ void impl_start();
- void impl_next()
- {
- invariant(implies(p_ != nop_, bb_.has(p_)));
- for (int i = point_t::n - 1; i >= 0; --i)
- if (p_[i] == bb_.pmin(i))
- p_[i] = bb_.pmax(i);
- else
- {
- --p_[i];
- break;
- }
- if (p_ == bb_.pmax())
- p_ = nop_;
- }
+ void impl_next();
- void impl_invalidate()
- {
- invariant(implies(p_ != nop_, bb_.has(p_)));
- p_ = nop_;
- }
+ void impl_invalidate();
- bool impl_is_valid() const
- {
- invariant(implies(p_ != nop_, bb_.has(p_)));
- return p_ != nop_;
- }
+ bool impl_is_valid() const;
- point_t impl_to_point() const
- {
- return p_;
- }
+ point_t impl_to_point() const;
- const point_t* impl_point_adr() const
- {
- return &p_;
- }
+ const point_t* impl_point_adr() const;
protected:
@@ -129,6 +89,85 @@
}; // end of class oln::internal::bbox_bkd_piter<E>
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bbox_bkd_piter<E>::bbox_bkd_piter(const bbox_<oln_type_of(E, point)>& bb)
+ : p_(),
+ bb_(bb)
+ {
+ nop_ = bb_.pmin();
+ --nop_[0];
+ }
+
+ template <typename E>
+ const bbox_<oln_type_of(E, point)>&
+ bbox_bkd_piter<E>::bbox() const
+ {
+ return bb_;
+ }
+
+ template <typename E>
+ void
+ bbox_bkd_piter<E>::impl_start()
+ {
+ p_ = bb_.pmax();
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ }
+
+ template <typename E>
+ void
+ bbox_bkd_piter<E>::impl_next()
+ {
+ typedef oln_type_of(E, point) point_t;
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ for (int i = point_t::n - 1; i >= 0; --i)
+ if (p_[i] == bb_.pmin(i))
+ p_[i] = bb_.pmax(i);
+ else
+ {
+ --p_[i];
+ break;
+ }
+ if (p_ == bb_.pmax())
+ p_ = nop_;
+ }
+
+ template <typename E>
+ void
+ bbox_bkd_piter<E>::impl_invalidate()
+ {
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ p_ = nop_;
+ }
+
+ template <typename E>
+ bool
+ bbox_bkd_piter<E>::impl_is_valid() const
+ {
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ return p_ != nop_;
+ }
+
+ template <typename E>
+ oln_type_of(E, point)
+ bbox_bkd_piter<E>::impl_to_point() const
+ {
+ return p_;
+ }
+
+ template <typename E>
+ const oln_type_of(E, point)*
+ bbox_bkd_piter<E>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+# endif
+
+
} // end of namespace oln::internal
} // end of namespace oln
Index: oln/core/internal/bbox_fwd_piter.hh
===================================================================
--- oln/core/internal/bbox_fwd_piter.hh (revision 606)
+++ oln/core/internal/bbox_fwd_piter.hh (working copy)
@@ -64,61 +64,21 @@
public:
- bbox_fwd_piter(const bbox_<point_t>& bb)
- : p_(),
- bb_(bb)
- {
- nop_ = bb_.pmax();
- ++nop_[0];
- }
+ bbox_fwd_piter(const bbox_<point_t>& bb);
- const bbox_<point_t>& bbox() const
- {
- return bb_;
- }
+ const bbox_<point_t>& bbox() const;
- void impl_start()
- {
- p_ = bb_.pmin();
- invariant(implies(p_ != nop_, bb_.has(p_)));
- }
+ void impl_start();
- void impl_next()
- {
- invariant(implies(p_ != nop_, bb_.has(p_)));
- for (int i = point_t::n - 1; i >= 0; --i)
- if (p_[i] == bb_.pmax(i))
- p_[i] = bb_.pmin(i);
- else
- {
- ++p_[i];
- break;
- }
- if (p_ == bb_.pmin())
- p_ = nop_;
- }
+ void impl_next();
- void impl_invalidate()
- {
- invariant(implies(p_ != nop_, bb_.has(p_)));
- p_ = nop_;
- }
+ void impl_invalidate();
- bool impl_is_valid() const
- {
- invariant(implies(p_ != nop_, bb_.has(p_)));
- return p_ != nop_;
- }
+ bool impl_is_valid() const;
- point_t impl_to_point() const
- {
- return p_;
- }
+ point_t impl_to_point() const;
- const point_t* impl_point_adr() const
- {
- return &p_;
- }
+ const point_t* impl_point_adr() const;
protected:
@@ -129,6 +89,85 @@
}; // end of class oln::internal::bbox_fwd_piter<E>
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bbox_fwd_piter<E>::bbox_fwd_piter(const bbox_<typename bbox_fwd_piter<E>::point_t>& bb)
+ : p_(),
+ bb_(bb)
+ {
+ nop_ = bb_.pmax();
+ ++nop_[0];
+ }
+
+ template <typename E>
+ const bbox_<typename bbox_fwd_piter<E>::point_t>&
+ bbox_fwd_piter<E>::bbox() const
+ {
+ return bb_;
+ }
+
+ template <typename E>
+ void
+ bbox_fwd_piter<E>::impl_start()
+ {
+ p_ = bb_.pmin();
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ }
+
+ template <typename E>
+ void
+ bbox_fwd_piter<E>::impl_next()
+ {
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ typedef typename bbox_fwd_piter<E>::point_t point_t;
+ for (int i = point_t::n - 1; i >= 0; --i)
+ if (p_[i] == bb_.pmax(i))
+ p_[i] = bb_.pmin(i);
+ else
+ {
+ ++p_[i];
+ break;
+ }
+ if (p_ == bb_.pmin())
+ p_ = nop_;
+ }
+
+ template <typename E>
+ void
+ bbox_fwd_piter<E>::impl_invalidate()
+ {
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ p_ = nop_;
+ }
+
+ template <typename E>
+ bool
+ bbox_fwd_piter<E>::impl_is_valid() const
+ {
+ invariant(implies(p_ != nop_, bb_.has(p_)));
+ return p_ != nop_;
+ }
+
+ template <typename E>
+ typename bbox_fwd_piter<E>::point_t
+ bbox_fwd_piter<E>::impl_to_point() const
+ {
+ return p_;
+ }
+
+ template <typename E>
+ const typename bbox_fwd_piter<E>::point_t*
+ bbox_fwd_piter<E>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+# endif
+
+
} // end of namespace oln::internal
} // end of namespace oln
Index: oln/core/internal/dpoint_nd.hh
===================================================================
--- oln/core/internal/dpoint_nd.hh (revision 606)
+++ oln/core/internal/dpoint_nd.hh (working copy)
@@ -64,59 +64,101 @@
public:
enum { n = mlc_value(dim) };
+ typedef xtd::vec<n,coord_t> vec_t;
- bool impl_equal(const self_t& rhs) const
- {
- return v_ == rhs.v_;
- }
+ bool impl_equal(const dpoint_nd<E>& rhs) const;
- coord_t operator[](unsigned i) const
- {
- assert(i < n);
- return v_[i];
- }
+ coord_t operator[](unsigned i) const;
- coord_t& operator[](unsigned i)
- {
- assert(i < n);
- return v_[i];
- }
+ coord_t& operator[](unsigned i);
- void set_all(const coord_t& c)
- {
- v_.set_all(c);
- }
+ void set_all(const coord_t& c);
- const xtd::vec<n,coord_t>& vec() const
- {
- return v_;
- }
+ const vec_t& vec() const;
- exact_t operator-() const
- {
- exact_t tmp(-v_);
- return tmp;
- }
+ E operator-() const;
- bool impl_less(const self_t& rhs) const
- {
- return xtd::lexi_less(v_, rhs.vec());
- }
+ bool impl_less(const dpoint_nd<E>& rhs) const;
protected:
/// Ctor.
- dpoint_nd()
- {}
+ dpoint_nd();
/// Ctor.
- dpoint_nd(const xtd::vec<n,coord_t>& v) :
- v_(v)
- {}
+ dpoint_nd(const vec_t& v);
- xtd::vec<n,coord_t> v_;
+ vec_t v_;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ bool
+ dpoint_nd<E>::impl_equal(const dpoint_nd<E>& rhs) const
+ {
+ return v_ == rhs.v_;
+ }
+
+ template <typename E>
+ typename dpoint_nd<E>::coord_t
+ dpoint_nd<E>::operator[](unsigned i) const
+ {
+ assert(i < n);
+ return v_[i];
+ }
+
+ template <typename E>
+ typename dpoint_nd<E>::coord_t&
+ dpoint_nd<E>::operator[](unsigned i)
+ {
+ assert(i < n);
+ return v_[i];
+ }
+
+ template <typename E>
+ void
+ dpoint_nd<E>::set_all(const typename dpoint_nd<E>::coord_t& c)
+ {
+ v_.set_all(c);
+ }
+
+ template <typename E>
+ const typename dpoint_nd<E>::vec_t&
+ dpoint_nd<E>::vec() const
+ {
+ return v_;
+ }
+
+ template <typename E>
+ E
+ dpoint_nd<E>::operator-() const
+ {
+ E tmp(-v_);
+ return tmp;
+ }
+
+ template <typename E>
+ bool
+ dpoint_nd<E>::impl_less(const dpoint_nd<E>& rhs) const
+ {
+ return xtd::lexi_less(v_, rhs.vec());
+ }
+
+ template <typename E>
+ dpoint_nd<E>::dpoint_nd()
+ {}
+
+ template <typename E>
+ dpoint_nd<E>::dpoint_nd(const typename dpoint_nd<E>::vec_t& v) :
+ v_(v)
+ {}
+
+
+# endif
+
+
} // end of namespace oln::internal
@@ -125,7 +167,7 @@
template <typename D>
struct case_ < xtd::op_uminus, D,
oln::id::op_uminus_dpointnd >
- : where_< mlc_is_a(D, internal::dpoint_nd) >
+ : where_< mlc_is_a(D, internal::dpoint_nd) >
{
typedef stc_to_exact(D) ret;
};
Index: oln/basics2d.hh
===================================================================
--- oln/basics2d.hh (revision 607)
+++ oln/basics2d.hh (working copy)
@@ -35,25 +35,17 @@
# include <oln/core/2d/grid2d.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/topo_lbbox.hh>
-namespace oln { template class topo_lbbox_<point2d>; }
# include <oln/core/gen/fwd_piter_bbox.hh>
-namespace oln { template class fwd_piter_bbox_<point2d>; }
-
# include <oln/core/gen/bkd_piter_bbox.hh>
-namespace oln { template class bkd_piter_bbox_<point2d>; }
# include <oln/core/gen/neighb.hh>
-namespace oln { template class neighb_<dpoint2d>; }
# include <oln/core/2d/neighb2d.hh>
# include <oln/core/2d/image2d.hh>
Index: oln/morpher/add_isubset.hh
===================================================================
--- oln/morpher/add_isubset.hh (revision 607)
+++ oln/morpher/add_isubset.hh (working copy)
@@ -106,29 +106,54 @@
// FIXME: Handle the constness.
- add_isubset(const Image& image, const Isubset& isubset) :
- super_t(image),
- topo_(image.topo(), isubset)
- {
- mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Isubset, grid)>::check();
- // FIXME: check that Image is without a isubset
- }
+ add_isubset(const Image& image, const Isubset& isubset);
+ const topo_t& impl_topo() const;
- const topo_t& impl_topo() const
- {
- return topo_;
- }
-
protected:
topo_t topo_;
};
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Image, typename Isubset>
+ add_isubset<Image, Isubset>::add_isubset(const Image& image, const Isubset& isubset) :
+ super_t(image),
+ topo_(image.topo(), isubset)
+ {
+ mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Isubset, grid)>::check();
+ // FIXME: check that Image is without a isubset
+ }
+
+ template <typename Image, typename Isubset>
+ const typename add_isubset<Image, Isubset>::topo_t&
+ add_isubset<Image, Isubset>::impl_topo() const
+ {
+ return topo_;
+ }
+
+# endif
+
+
} // end of namespace oln::morpher
+
template <typename I, typename S>
morpher::add_isubset<I, S>
operator | (const abstract::image<I>& image,
+ const abstract::binary_image<S>& isubset);
+
+ // FIXME: Register this operator.
+ // FIXME: Add mutable version.
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I, typename S>
+ morpher::add_isubset<I, S>
+ operator | (const abstract::image<I>& image,
const abstract::binary_image<S>& isubset)
{
mlc::assert_equal_<oln_type_of(I, grid), oln_type_of(S, grid)>::check();
@@ -137,10 +162,8 @@
return tmp;
}
- // FIXME: Register this operator.
- // FIXME: Add mutable version.
+# endif
-
} // end of namespace oln
Index: oln/morpher/identity.hh
===================================================================
--- oln/morpher/identity.hh (revision 606)
+++ oln/morpher/identity.hh (working copy)
@@ -63,13 +63,21 @@
public:
// FIXME: Handle the constness.
- identity(const Image& image) :
- super_t(image)
- {
- }
+ identity(const Image& image);
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Image>
+ identity<Image>::identity(const Image& image) :
+ super_t(image)
+ {
+ }
+
+# endif
+
} // end of namespace oln::morpher
} // end of namespace oln
Index: oln/morpher/internal/image_extension.hh
===================================================================
--- oln/morpher/internal/image_extension.hh (revision 607)
+++ oln/morpher/internal/image_extension.hh (working copy)
@@ -85,20 +85,32 @@
// }
// FIXME: Handle the constness.
- image_extension(const Image& image) :
- image_(image)
- {
- }
+ image_extension(const Image& image);
+ const Image& delegate() const;
- const Image& delegate() const
- {
- return image_;
- }
-
protected:
Image image_;
};
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Image, typename Exact>
+ image_extension<Image, Exact>::image_extension(const Image& image) :
+ image_(image)
+ {
+ }
+
+ template <typename Image, typename Exact>
+ const Image&
+ image_extension<Image, Exact>::delegate() const
+ {
+ return image_;
+ }
+
+# endif
+
} // end of namespace oln::morpher::internal
} // end of namespace oln::morpher
Index: oln/morpher/add_neighborhood.hh
===================================================================
--- oln/morpher/add_neighborhood.hh (revision 607)
+++ oln/morpher/add_neighborhood.hh (working copy)
@@ -81,34 +81,53 @@
// FIXME: Handle the constness.
-// template <typename I, typename N>
-// add_neighborhood(const abstract::image<I>& image, const N& nbh)
-// : super_t(image)
-// {
-// }
+ // template <typename I, typename N>
+ // add_neighborhood(const abstract::image<I>& image, const N& nbh)
+ // : super_t(image)
+ // {
+ // }
- add_neighborhood(const Image& image, const Neighb& nbh) :
- super_t(image),
- topo_(image.topo(), nbh)
- {
- mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Neighb, grid)>::check();
- // FIXME: check that Image is without a nbh
- }
+ add_neighborhood(const Image& image, const Neighb& nbh);
+ const topo_t& impl_topo() const;
- const topo_t& impl_topo() const
- {
- return topo_;
- }
-
protected:
topo_t topo_;
};
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Image, typename Neighb>
+ add_neighborhood<Image, Neighb>::add_neighborhood(const Image& image, const Neighb& nbh) :
+ super_t(image),
+ topo_(image.topo(), nbh)
+ {
+ mlc::assert_equal_<oln_type_of(Image, grid), oln_type_of(Neighb, grid)>::check();
+ // FIXME: check that Image is without a nbh
+ }
+
+ template <typename Image, typename Neighb>
+ const typename add_neighborhood<Image, Neighb>::topo_t&
+ add_neighborhood<Image, Neighb>::impl_topo() const
+ {
+ return topo_;
+ }
+
+# endif
+
} // end of namespace oln::morpher
+
template <typename I, typename N>
morpher::add_neighborhood<I, N>
+ operator + (const abstract::image<I>& image, const abstract::neighborhood<N>& nbh);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I, typename N>
+ morpher::add_neighborhood<I, N>
operator + (const abstract::image<I>& image,
const abstract::neighborhood<N>& nbh)
{
@@ -118,6 +137,7 @@
return tmp;
}
+# endif
} // end of namespace oln
1
0
607: Decouple iterators from image topology; update neighborhood tools and start to add window tools.
by Thierry GERAUD 05 Oct '06
by Thierry GERAUD 05 Oct '06
05 Oct '06
2006-10-05 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Decouple iterators from image topology; update neighborhood tools
and start to add window tools.
* oln/core/automatic/topology_having_subset.hh: New.
* oln/core/abstract/topology_having_subset.hh: New.
* oln/core/gen/fwd_niter_neighb.hh: New.
* oln/core/gen/fwd_qiter_win.hh: New.
* oln/core/gen/window.hh: New.
* oln/core/typedefs.hh
(qiter_type, fwd_qiter_type, bkd_qiter_type): Uncomment.
(niter_type, fwd_niter_type, bkd_niter_type): Uncomment.
(isubset): Rename into...
(subset_type): ...this.
* oln/core/macros.hh
(oln_type_of, oln_deduce_type_of, oln_type_of_): Rely on direct access.
(oln_check_type_of, oln_check_type_of_): Rely on direct access.
(oln_deduce_direct_type_of): New.
* oln/core/topology_entry.hh (subset_type): New.
* oln/core/image_entry.hh (fwd_piter_type, bkd_piter_type): Move
from vtypes to single_vtype.
(fwd_qiter_type): New.
* oln/core/abstract/topology_hierarchies.hh
(topology_hierarchy_wrt_subset): New.
(include): Add topology_having_subset.hh.
* oln/core/abstract/image/neighborhood/hierarchy.hh
(niter, fwd_niter, bkd_niter): New in decl.
* oln/core/2d/aliases.hh
(fwd_piter_bbox_, bkd_piter_bbox_): Change param letter.
(fwd_piter2d, bkd_piter2d): Update.
* oln/core/2d/neighb2d.hh (c4, c8, c2_row, c2_col): Rename into...
(mk_c4, mk_c8, mk_c2_row, mk_c2_col): ...these in namespace internal.
(c4, c8, c2r, c2c): New objects.
* oln/core/gen/piter_isubset.hh (piter_isubset_): New ctor for
iterators around a point.
(topo): Return a copy.
(change_topology_): Remove; obsolete.
* oln/core/gen/topo_add_isubset.hh (isubset_type): Rename into...
(subset_type): ...this.
(isubset): Rename into...
(impl_subset): ...this.
* oln/core/gen/topo_bbox.hh (impl_lbbox): New; experimental!
* oln/core/gen/fwd_piter_bbox.hh (fwd_piter_bbox_): Change parameter
from topo to point; update.
(topo): Remove this method; obsolete.
(change_topology_): Remove; obsolete.
(topo_): Remove this attribute; obsolete.
* oln/core/gen/bkd_piter_bbox.hh: Likewise.
* oln/basics2d.hh: Update.
* oln/Makefile.am (nobase_oln_HEADERS): Update.
* oln/core/2d/image2d.hh
(fwd_piter_type, bkd_piter_type): Move these definitions into...
* oln/core/fwd_piter.hh: ... this new file.
* oln/morpher/add_isubset.hh: Likewise.
* oln/morpher/add_neighborhood.hh: Likewise.
* oln/morpher/internal/image_extension.hh (image_): Change from
const& to plain type.
Index: oln/core/fwd_piter.hh
===================================================================
--- oln/core/fwd_piter.hh (revision 0)
+++ oln/core/fwd_piter.hh (revision 0)
@@ -0,0 +1,131 @@
+// 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_FWD_PITER_HH
+# define OLN_CORE_FWD_PITER_HH
+
+# include <oln/core/abstract/entry.hh>
+# include <oln/core/abstract/image.hh>
+
+
+namespace oln
+{
+
+ // morpher::add_isubset<Image, Isubset>
+
+ namespace morpher {
+ template <typename Image, typename Isubset> struct add_isubset;
+ }
+ template <typename piter_t, typename isubset_t> class piter_isubset_;
+
+
+ template <typename Image, typename Isubset>
+ struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::fwd_piter_type >
+ {
+ typedef piter_isubset_<oln_type_of(Image, fwd_piter), Isubset> ret;
+ };
+
+ template <typename Image, typename Isubset>
+ struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::bkd_piter_type >
+ {
+ typedef piter_isubset_<oln_type_of(Image, bkd_piter), Isubset> ret;
+ };
+
+
+ template <typename Image, typename Isubset>
+ struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::fwd_qiter_type >
+ {
+ typedef piter_isubset_<oln_type_of(Image, fwd_qiter), Isubset> ret;
+ };
+
+ template <typename Image, typename Isubset>
+ struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::bkd_qiter_type >
+ {
+ typedef piter_isubset_<oln_type_of(Image, bkd_qiter), Isubset> ret;
+ };
+
+
+ template <typename Image, typename Isubset>
+ struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::fwd_niter_type >
+ {
+ typedef piter_isubset_<oln_type_of(Image, fwd_niter), Isubset> ret;
+ };
+
+ template <typename Image, typename Isubset>
+ struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::bkd_niter_type >
+ {
+ typedef piter_isubset_<oln_type_of(Image, bkd_niter), Isubset> ret;
+ };
+
+
+ // morpher::add_neighborhood<Image, Isubset>
+
+ namespace morpher {
+ template <typename Image, typename Neighb> struct add_neighborhood;
+ }
+ template <typename point_t> class fwd_niter_neighb_;
+
+ template <typename Image, typename Neighb>
+ struct single_vtype< morpher::add_neighborhood<Image, Neighb>, typedef_::fwd_niter_type >
+ {
+ private:
+ typedef oln_type_of(Image, point) point_t;
+ public:
+ typedef fwd_niter_neighb_<point_t> ret;
+ };
+
+ template <typename Image, typename Neighb>
+ struct single_vtype< morpher::add_neighborhood<Image, Neighb>, typedef_::bkd_niter_type >
+ {
+ private:
+ typedef oln_type_of(Image, point) point_t;
+ public:
+ typedef fwd_niter_neighb_<point_t> ret; // FIXME: should be bkd but not yet impled!
+ };
+
+
+ // image2d<T>
+
+ template <typename T> class image2d;
+
+ template <typename T>
+ struct single_vtype< image2d<T>, typedef_::fwd_piter_type >
+ {
+ typedef fwd_piter2d ret;
+ };
+
+ template <typename T>
+ struct single_vtype< image2d<T>, typedef_::bkd_piter_type >
+ {
+ typedef bkd_piter2d ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_FWD_PITER_HH
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 606)
+++ oln/core/typedefs.hh (working copy)
@@ -90,13 +90,13 @@
mlc_decl_typedef(fwd_piter_type);
mlc_decl_typedef(bkd_piter_type);
-// mlc_decl_typedef(qiter_type);
-// mlc_decl_typedef(fwd_qiter_type);
-// mlc_decl_typedef(bkd_qiter_type);
+ mlc_decl_typedef(qiter_type);
+ mlc_decl_typedef(fwd_qiter_type);
+ mlc_decl_typedef(bkd_qiter_type);
-// mlc_decl_typedef(niter_type);
-// mlc_decl_typedef(fwd_niter_type);
-// mlc_decl_typedef(bkd_niter_type);
+ mlc_decl_typedef(niter_type);
+ mlc_decl_typedef(fwd_niter_type);
+ mlc_decl_typedef(bkd_niter_type);
// --------------------------------------------------------------------
@@ -134,7 +134,7 @@
mlc_decl_typedef(dpoint_type);
mlc_decl_typedef(neighborhood_type);
- mlc_decl_typedef(isubset);
+ mlc_decl_typedef(subset_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
Index: oln/core/macros.hh
===================================================================
--- oln/core/macros.hh (revision 606)
+++ oln/core/macros.hh (working copy)
@@ -38,23 +38,32 @@
/// an oln type \a OlnType whose category is not specified (version to be
/// used inside a template).
# define oln_type_of(OlnType, Alias) \
- stc_type_of(oln, void, OlnType, Alias)
+ stc_direct_type_of(oln, void, OlnType, Alias)
+// FIXME: Remove direct_ above.
/// FIXME: Temporary macro to be able to perform "oln_type_of(oln_type_of(A, B), C)".
# define oln_deduce_type_of(OlnType, Alias1, Alias2) \
-typename oln::type_of_<void, \
- typename oln::type_of_<void, OlnType, oln::typedef_::Alias1##_type >::ret, \
+typename oln::direct_type_of_<void, \
+ typename oln::direct_type_of_<void, OlnType, oln::typedef_::Alias1##_type >::ret, \
oln::typedef_::Alias2##_type >::ret
+// FIXME: Remove direct_ *twice* above.
+# define oln_deduce_direct_type_of(OlnType, Alias1, Alias2) \
+typename oln::direct_type_of_<void, \
+ typename oln::direct_type_of_<void, OlnType, oln::typedef_::Alias1##_type >::ret, \
+ oln::typedef_::Alias2##_type >::ret
+
+
/// \def oln_type_of(OlnType, Alias)
///
/// Macro to retrieve an associated type \a Alias from the exact type of
/// an oln type \a OlnType whose category is not specified (version to be
/// used outside a template).
# define oln_type_of_(OlnType, Alias) \
- stc_type_of_(oln, void, OlnType, Alias)
+ stc_direct_type_of_(oln, void, OlnType, Alias)
+// FIXME: Remove direct_ above.
/// \def oln_direct_type_of(OlnType, Alias)
@@ -90,7 +99,8 @@
///
/// If the virtual type is not found, raise a static error.
# define oln_check_type_of(OlnType, Alias) \
- stc_check_type_of(oln, void, OlnType, Alias)
+ stc_check_direct_type_of(oln, void, OlnType, Alias)
+// FIXME: Remove direct_ above.
/// \def oln_check_type_of(OlnType, Alias)
///
@@ -100,7 +110,8 @@
///
/// If the virtual type is not found, raise a static error.
# define oln_check_type_of_(OlnType, Alias) \
- stc_check_type_of_(oln, void, OlnType, Alias)
+ stc_check_direct_type_of_(oln, void, OlnType, Alias)
+// FIXME: Remove direct_ above.
/// \def oln_check_direct_type_of(OlnType, Alias)
Index: oln/core/automatic/topology_having_subset.hh
===================================================================
--- oln/core/automatic/topology_having_subset.hh (revision 0)
+++ oln/core/automatic/topology_having_subset.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 OLN_CORE_AUTOMATIC_TOPOLOGY_HAVING_SUBSET_HH
+# define OLN_CORE_AUTOMATIC_TOPOLOGY_HAVING_SUBSET_HH
+
+# include <oln/core/automatic/impl.hh>
+# include <oln/morpher/tags.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ namespace abstract
+ {
+ template <typename E> class topology_having_subset;
+
+ } // end of namespace oln::abstract
+
+
+ namespace automatic
+ {
+
+ /// Implementation corresponding to the interface
+ /// oln::abstract::topology_having_subset for an identity morpher.
+
+ template <typename E>
+ class set_impl< abstract::topology_having_subset,
+ morpher::tag::identity,
+ E > :
+ public virtual stc::any__simple<E>
+ {
+ private:
+ typedef oln_type_of(E, subset) subset_t;
+
+ public:
+
+ const subset_t& impl_subset() const
+ {
+ return this->exact().delegate().subset();
+ }
+
+ };
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+#endif // ! OLN_CORE_AUTOMATIC_TOPOLOGY_HAVING_SUBSET_HH
Index: oln/core/topology_entry.hh
===================================================================
--- oln/core/topology_entry.hh (revision 606)
+++ oln/core/topology_entry.hh (working copy)
@@ -57,6 +57,7 @@
typedef mlc::undefined bbox_type;
typedef mlc::none neighborhood_type;
typedef mlc::undefined is_random_accessible_type;
+ typedef mlc::none subset_type;
};
template <typename E>
Index: oln/core/image_entry.hh
===================================================================
--- oln/core/image_entry.hh (revision 606)
+++ oln/core/image_entry.hh (working copy)
@@ -59,10 +59,6 @@
// 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.
@@ -96,6 +92,28 @@
};
+ // Fwd piter.
+ template <typename E>
+ struct single_vtype< image_entry<E>, typedef_::fwd_piter_type >
+ {
+ typedef mlc::undefined ret;
+ };
+
+ // Bkd piter.
+ template <typename E>
+ struct single_vtype< image_entry<E>, typedef_::bkd_piter_type >
+ {
+ typedef mlc::undefined ret;
+ };
+
+ // Fwd qiter.
+ template <typename E>
+ struct single_vtype< image_entry<E>, typedef_::fwd_qiter_type >
+ {
+ typedef mlc::undefined ret;
+ };
+
+
} // end of namespace oln
Index: oln/core/abstract/topology_hierarchies.hh
===================================================================
--- oln/core/abstract/topology_hierarchies.hh (revision 606)
+++ oln/core/abstract/topology_hierarchies.hh (working copy)
@@ -37,6 +37,7 @@
typedef hierarchy< abstract::topology, 1 > topology_hierarchy_wrt_accessibility;
typedef hierarchy< abstract::topology, 2 > topology_hierarchy_wrt_bbox;
typedef hierarchy< abstract::topology, 3 > topology_hierarchy_wrt_neighborhood;
+ typedef hierarchy< abstract::topology, 4 > topology_hierarchy_wrt_subset;
} // end of namespace oln
@@ -47,10 +48,13 @@
// Hierarchy 2: topology w.r.t. bounding box.
# include <oln/core/abstract/topology_having_bbox.hh>
-// Hierarchy 2: topology w.r.t. neighborhood.
+// Hierarchy 3: topology w.r.t. neighborhood.
# include <oln/core/abstract/topology_having_neighborhood.hh>
+// Hierarchy 4: topology w.r.t. neighborhood.
+# include <oln/core/abstract/topology_having_subset.hh>
+
#endif // ! OLN_CORE_ABSTRACT_TOPOLOGY_HIERARCHIES_HH
Index: oln/core/abstract/image/neighborhood/hierarchy.hh
===================================================================
--- oln/core/abstract/image/neighborhood/hierarchy.hh (revision 606)
+++ oln/core/abstract/image/neighborhood/hierarchy.hh (working copy)
@@ -65,9 +65,9 @@
public:
struct decl {
- // FIXME: Uncomment.
- // stc_virtual_typedef(fwd_niter);
- // stc_virtual_typedef(bkd_niter);
+ // stc_virtual_typedef(niter);
+ stc_virtual_typedef(fwd_niter);
+ stc_virtual_typedef(bkd_niter);
};
const neighborhood_t& neighborhood() const
Index: oln/core/abstract/topology_having_subset.hh
===================================================================
--- oln/core/abstract/topology_having_subset.hh (revision 0)
+++ oln/core/abstract/topology_having_subset.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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_ABSTRACT_TOPOLOGY_HAVING_SUBSET_HH
+# define OLN_CORE_ABSTRACT_TOPOLOGY_HAVING_SUBSET_HH
+
+# include <oln/core/abstract/topology.hh>
+# include <oln/core/automatic/topology_having_subset.hh>
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+ template <typename E>
+ class topology_having_subset
+ : public virtual topology<E>,
+ public automatic::get_impl<topology_having_subset, E>
+ {
+ typedef oln_type_of(E, subset) subset_t;
+
+ public:
+
+ // abstract
+ const subset_t& subset() const
+ {
+ return this->exact().impl_subset();
+ }
+
+ protected:
+
+ topology_having_subset()
+ {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+ template <typename E>
+ struct case_ < topology_hierarchy_wrt_subset, E, 1 >
+ : where_< mlc::neq_< oln_type_of(E, subset), mlc::none > >
+ {
+ typedef abstract::topology_having_subset<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_ABSTRACT_TOPOLOGY_HAVING_SUBSET_HH
Index: oln/core/2d/aliases.hh
===================================================================
--- oln/core/2d/aliases.hh (revision 606)
+++ oln/core/2d/aliases.hh (working copy)
@@ -40,8 +40,8 @@
template <typename D> class neighb_;
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_piter_bbox_;
+ template <typename P> class bkd_piter_bbox_;
class grid2d;
/// \}
@@ -55,8 +55,8 @@
typedef bbox_<point2d> bbox2d;
typedef topo_lbbox_<point2d> topo2d;
- typedef fwd_piter_bbox_<topo2d> fwd_piter2d;
- typedef bkd_piter_bbox_<topo2d> bkd_piter2d;
+ typedef fwd_piter_bbox_<point2d> fwd_piter2d;
+ typedef bkd_piter_bbox_<point2d> bkd_piter2d;
typedef point2d_<float> point2df;
typedef dpoint2d_<float> dpoint2df;
Index: oln/core/2d/neighb2d.hh
===================================================================
--- oln/core/2d/neighb2d.hh (revision 606)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -37,66 +37,74 @@
{
- neighb2d c4()
+ namespace internal
{
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1, 0));
- flower = false;
- }
- return the_;
- }
-
- neighb2d c8()
- {
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1,-1))
- .add(dpoint2d(1, 0))
- .add(dpoint2d(1, 1));
- flower = false;
- }
- return the_;
- }
-
+ neighb2d mk_c4()
+ {
+ static bool flower = true;
+ static neighb2d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint2d(0, 1))
+ .add(dpoint2d(1, 0));
+ flower = false;
+ }
+ return the_;
+ }
- neighb2d c2_row()
- {
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(0, 1));
- flower = false;
- }
- return the_;
- }
-
+ neighb2d mk_c8()
+ {
+ static bool flower = true;
+ static neighb2d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint2d(0, 1))
+ .add(dpoint2d(1,-1))
+ .add(dpoint2d(1, 0))
+ .add(dpoint2d(1, 1));
+ flower = false;
+ }
+ return the_;
+ }
- neighb2d c2_col()
- {
- static bool flower = true;
- static neighb2d the_;
- if (flower)
- {
- the_
- .add(dpoint2d(1, 0));
- flower = false;
- }
- return the_;
- }
+ neighb2d mk_c2_row()
+ {
+ static bool flower = true;
+ static neighb2d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint2d(0, 1));
+ flower = false;
+ }
+ return the_;
+ }
+ neighb2d mk_c2_col()
+ {
+ static bool flower = true;
+ static neighb2d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint2d(1, 0));
+ flower = false;
+ }
+ return the_;
+ }
+ } // end of namespace oln::internal
+
+
+ static const neighb2d c4 = internal::mk_c4();
+ static const neighb2d c8 = internal::mk_c8();
+ static const neighb2d c2r = internal::mk_c2_row();
+ static const neighb2d c2c = internal::mk_c2_col();
+
+
} // end of namespace oln
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 606)
+++ oln/core/2d/image2d.hh (working copy)
@@ -50,10 +50,7 @@
typedef grid2d grid_type;
typedef point2d point_type;
-
- typedef fwd_piter_bbox_<topo_type> fwd_piter_type;
- typedef bkd_piter_bbox_<topo_type> bkd_piter_type;
-
+
typedef T value_type;
typedef T lvalue_type;
typedef mlc::true_ is_mutable_type;
Index: oln/core/gen/piter_isubset.hh
===================================================================
--- oln/core/gen/piter_isubset.hh (revision 606)
+++ oln/core/gen/piter_isubset.hh (working copy)
@@ -68,17 +68,24 @@
typedef piter_isubset_<piter_t, isubset_t> self_t;
typedef abstract::iterator_on_points<self_t> super_t;
- typedef oln_type_of(self_t, point) topo_t;
- typedef oln_type_of(piter_t, point) point_t;
+ typedef oln_type_of(self_t, topo) topo_t;
+ typedef oln_type_of(self_t, point) point_t;
public:
template <typename T>
piter_isubset_(const abstract::topology<T>& topo)
: p_(topo),
- isubset_(topo.exact().isubset())
+ isubset_(topo.exact().subset())
{
}
+
+ template <typename P, typename T>
+ piter_isubset_(const P& p, const abstract::topology<T>& topo)
+ : p_(p, topo),
+ isubset_(topo.exact().subset())
+ {
+ }
void impl_start()
{
@@ -114,19 +121,12 @@
return p_.point_adr();
}
- const topo_t& topo() const
+ const topo_t topo() const
{
topo_t tmp(p_.topo(), isubset_);
return tmp;
}
- template <typename new_topo_t>
- struct change_topology_
- {
- typedef typename piter_t::template change_topology_<new_topo_t>::ret new_piter_t;
- typedef piter_isubset_<new_piter_t, isubset_t> ret;
- };
-
protected:
piter_t p_;
Index: oln/core/gen/topo_add_isubset.hh
===================================================================
--- oln/core/gen/topo_add_isubset.hh (revision 606)
+++ oln/core/gen/topo_add_isubset.hh (working copy)
@@ -53,7 +53,7 @@
template <typename topo, typename isubset>
struct vtypes< topo_add_isubset<topo, isubset> >
{
- typedef isubset isubset_type;
+ typedef isubset subset_type;
};
@@ -92,7 +92,7 @@
return topo_;
}
- const isubset_t& isubset() const
+ const isubset_t& impl_subset() const
{
return isubset_;
}
Index: oln/core/gen/topo_bbox.hh
===================================================================
--- oln/core/gen/topo_bbox.hh (revision 606)
+++ oln/core/gen/topo_bbox.hh (working copy)
@@ -89,6 +89,11 @@
return bb_;
}
+ bbox_t& impl_lbbox()
+ {
+ return bb_;
+ }
+
bool impl_has(const point& p) const
{
return bb_.has(p);
Index: oln/core/gen/fwd_piter_bbox.hh
===================================================================
--- oln/core/gen/fwd_piter_bbox.hh (revision 606)
+++ oln/core/gen/fwd_piter_bbox.hh (working copy)
@@ -30,6 +30,7 @@
# define OLN_CORE_GEN_FWD_PITER_BBOX_HH
# include <oln/core/abstract/topology.hh>
+# include <oln/core/abstract/point.hh>
# include <oln/core/internal/bbox_fwd_piter.hh>
@@ -38,74 +39,57 @@
// Forward declaration.
- template <typename topo> class fwd_piter_bbox_;
+ template <typename point_t> class fwd_piter_bbox_;
// Super type declaration.
- template <typename topo>
- struct set_super_type< fwd_piter_bbox_<topo> >
+ template <typename point_t>
+ struct set_super_type< fwd_piter_bbox_<point_t> >
{
- typedef fwd_piter_bbox_<topo> self_t;
+ typedef fwd_piter_bbox_<point_t> self_t;
typedef internal::bbox_fwd_piter<self_t> ret;
};
- /// Virtual types associated to oln::fwd_piter_bbox_<topo>.
- template <typename topo>
- struct vtypes< fwd_piter_bbox_<topo> >
+ /// Virtual types associated to oln::fwd_piter_bbox_<point_t>.
+ template <typename point_t>
+ struct vtypes< fwd_piter_bbox_<point_t> >
{
- typedef oln_type_of(topo, point) point_type;
- typedef oln_type_of(topo, grid) grid_type;
- typedef topo topo_type;
+ typedef point_t point_type;
+ typedef oln_type_of(point_t, grid) grid_type;
};
/// Abstract forward point iterator class.
- template <typename topo_t>
- class fwd_piter_bbox_ : public internal::bbox_fwd_piter< fwd_piter_bbox_<topo_t> >,
- private mlc::assert_< mlc_is_a(topo_t, abstract::topology) >
+ template <typename point_t>
+ class fwd_piter_bbox_ : public internal::bbox_fwd_piter< fwd_piter_bbox_<point_t> >,
+ private mlc::assert_< mlc_is_a(point_t, abstract::point) >
{
- typedef fwd_piter_bbox_<topo_t> self_t;
+ typedef fwd_piter_bbox_<point_t> self_t;
typedef internal::bbox_fwd_piter<self_t> super_t;
public:
template <typename T>
fwd_piter_bbox_(const abstract::topology<T>& topo)
- : super_t(topo.exact().bbox()),
- topo_(topo.exact())
+ : super_t(topo.exact().bbox())
{
}
-
- const topo_t& topo() const
- {
- return topo_;
- }
void print(std::ostream& ostr) const
{
- ostr << "{ p=" << super_t::p_
+ ostr << "{ p=" << this->p_
<< " }";
}
friend
- std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<topo_t>& t)
+ std::ostream& operator<<(std::ostream& ostr, const fwd_piter_bbox_<point_t>& t)
{
t.print(ostr);
return ostr;
}
- template <typename new_topo_t>
- struct change_topology_
- {
- typedef fwd_piter_bbox_<new_topo_t> ret;
- };
-
- protected:
-
- const topo_t topo_;
-
}; // end of class oln::fwd_piter_bbox_<point>
Index: oln/core/gen/fwd_niter_neighb.hh
===================================================================
--- oln/core/gen/fwd_niter_neighb.hh (revision 0)
+++ oln/core/gen/fwd_niter_neighb.hh (revision 0)
@@ -0,0 +1,165 @@
+// 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_GEN_FWD_NITER_NEIGHB_HH
+# define OLN_CORE_GEN_FWD_NITER_NEIGHB_HH
+
+# include <oln/core/abstract/topology.hh>
+# include <oln/core/abstract/iterator_on_points.hh>
+# include <oln/core/gen/neighb.hh>
+
+
+namespace oln
+{
+
+
+ // Forward declaration.
+ template <typename point_t> class fwd_niter_neighb_;
+
+
+ // Super type declaration.
+ template <typename point_t>
+ struct set_super_type< fwd_niter_neighb_<point_t> >
+ {
+ typedef fwd_niter_neighb_<point_t> self_t;
+ typedef abstract::iterator_on_points<self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::fwd_niter_neighb_<point_t>.
+ template <typename point_t>
+ struct vtypes< fwd_niter_neighb_<point_t> >
+ {
+ typedef point_t point_type;
+ typedef oln_type_of(point_t, grid) grid_type;
+ };
+
+
+
+ /// Abstract forward point iterator class.
+ template <typename point_t>
+ class fwd_niter_neighb_ : public abstract::iterator_on_points< fwd_niter_neighb_<point_t> >
+ {
+ typedef fwd_niter_neighb_<point_t> self_t;
+ typedef abstract::iterator_on_points<self_t> super_t;
+
+ typedef oln_type_of(point_t, dpoint) dpoint_t;
+
+ public:
+
+ template <typename P, typename T>
+ fwd_niter_neighb_(const abstract::iterator_on_points<P>& it,
+ const abstract::topology<T>& topo)
+ : p_ref_(it.point_adr()),
+ nbh_(topo.exact().neighborhood())
+ {
+ precondition(nbh_.card() > 0);
+ i_ = -1;
+ }
+
+// template <typename P, typename N>
+// fwd_niter_neighb_(const abstract::iterator_on_points<P>& it,
+// const abstract::neighborhood<N>& nbh)
+// : p_ref_(it.point_adr()),
+// nbh_(nbh.exact())
+// {
+// precondition(nbh_.card() > 0);
+// i_ = -1;
+// }
+
+// template <typename P, typename T>
+// fwd_niter_neighb_(const abstract::point<P>& p,
+// const abstract::topology<T>& topo)
+// : p_ref_(&(p.exact())),
+// nbh_(topo.exact().neighborhood())
+// {
+// precondition(nbh_.card() > 0);
+// i_ = -1;
+// }
+
+// template <typename P, typename N>
+// fwd_niter_neighb_(const abstract::point<P>& p,
+// const abstract::neighborhood<N>& nbh)
+// : p_ref_(&(p.exact())),
+// nbh_(nbh.exact())
+// {
+// precondition(nbh_.card() > 0);
+// i_ = -1;
+// }
+
+ void impl_start()
+ {
+ i_ = 0;
+ p_ = *p_ref_+ nbh_.dp(i_);
+ }
+
+ void impl_next()
+ {
+ ++i_;
+ if (i_ == int(nbh_.card()))
+ {
+ i_ = -1;
+ return;
+ }
+ p_ = *p_ref_ + nbh_.dp(i_);
+ }
+
+ void impl_invalidate()
+ {
+ i_ = -1;
+ }
+
+ bool impl_is_valid() const
+ {
+ return i_ != -1;
+ }
+
+ point_t impl_to_point() const
+ {
+ return p_;
+ }
+
+ const point_t* impl_point_adr() const
+ {
+ return &p_;
+ }
+
+ protected:
+
+ const point_t* p_ref_;
+ neighb_<dpoint_t> nbh_;
+ int i_;
+ point_t p_;
+
+ }; // end of class oln::fwd_niter_neighb_<point_t>
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_FWD_NITER_NEIGHB_HH
+
Index: oln/core/gen/fwd_qiter_win.hh
===================================================================
--- oln/core/gen/fwd_qiter_win.hh (revision 0)
+++ oln/core/gen/fwd_qiter_win.hh (revision 0)
@@ -0,0 +1,145 @@
+// 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_GEN_FWD_QITER_WIN_HH
+# define OLN_CORE_GEN_FWD_QITER_WIN_HH
+
+# include <oln/core/abstract/topology.hh>
+# include <oln/core/abstract/iterator_on_points.hh>
+# include <oln/core/gen/win.hh>
+
+
+namespace oln
+{
+
+
+ // Forward declaration.
+ template <typename point_t> class fwd_qiter_win_;
+
+
+ // Super type declaration.
+ template <typename point_t>
+ struct set_super_type< fwd_qiter_win_<point_t> >
+ {
+ typedef fwd_qiter_win_<point_t> self_t;
+ typedef abstract::iterator_on_points<self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::fwd_qiter_win_<point_t>.
+ template <typename point_t>
+ struct vtypes< fwd_qiter_win_<point_t> >
+ {
+ typedef point_t point_type;
+ typedef oln_type_of(point_t, grid) grid_type;
+ };
+
+
+
+ /// Abstract forward point iterator class.
+ template <typename point_t>
+ class fwd_qiter_win_ : public abstract::iterator_on_points< fwd_qiter_win_<point_t> >
+ {
+ typedef fwd_qiter_win_<point_t> self_t;
+ typedef abstract::iterator_on_points<self_t> super_t;
+
+ typedef oln_type_of(point_t, dpoint) dpoint_t;
+
+ public:
+
+ template <typename P, typename D>
+ fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
+ const window_<D>& win)
+ : p_ref_(it.point_adr()),
+ win_(win)
+ {
+ precondition(win_.card() > 0);
+ i_ = -1;
+ }
+
+ template <typename P, typename D>
+ fwd_qiter_win_(const abstract::point<P>& p,
+ const window_<D>& win)
+ : p_ref_(&(p.exact())),
+ win_(win)
+ {
+ precondition(win_.card() > 0);
+ i_ = -1;
+ }
+
+ void impl_start()
+ {
+ i_ = 0;
+ p_ = *p_ref_+ win_.dp(i_);
+ }
+
+ void impl_next()
+ {
+ ++i_;
+ if (i_ == int(win_.card()))
+ {
+ i_ = -1;
+ return;
+ }
+ p_ = *p_ref_ + win_.dp(i_);
+ }
+
+ void impl_invalidate()
+ {
+ i_ = -1;
+ }
+
+ bool impl_is_valid() const
+ {
+ return i_ != -1;
+ }
+
+ point_t impl_to_point() const
+ {
+ return p_;
+ }
+
+ const point_t* impl_point_adr() const
+ {
+ return &p_;
+ }
+
+ protected:
+
+ const point_t* p_ref_;
+ window_<dpoint_t> win_;
+ int i_;
+ point_t p_;
+
+ }; // end of class oln::fwd_qiter_win_<point_t>
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_FWD_QITER_WIN_HH
+
Index: oln/core/gen/window.hh
===================================================================
--- oln/core/gen/window.hh (revision 0)
+++ oln/core/gen/window.hh (revision 0)
@@ -0,0 +1,93 @@
+// 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_GEN_WINDOW_HH
+# define OLN_CORE_GEN_WINDOW_HH
+
+# include <set>
+# include <vector>
+
+
+namespace oln
+{
+
+ /// Abstract forward dpoint iterator class.
+ template <typename dpoint>
+ class window_ : private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
+ {
+ typedef window_<dpoint> self_t;
+
+ public:
+
+ window_()
+ {
+ }
+
+ self_t& add(const dpoint& dp)
+ {
+ s_.insert(dp);
+ update_();
+ return *this;
+ }
+
+ template <typename D>
+ self_t& add(const abstract::dpoint<D>& dp)
+ {
+ return this->add(dp.exact());
+ }
+
+ unsigned card() const
+ {
+ return v_.size();
+ }
+
+ dpoint dp(unsigned i) const
+ {
+ precondition(i < v_.size());
+ return v_[i];
+ }
+
+ protected:
+
+ std::set<dpoint> s_;
+ std::vector<dpoint> v_;
+
+ void update_()
+ {
+ v_.clear();
+ std::copy(s_.begin(), s_.end(),
+ std::back_inserter(v_));
+ }
+
+ }; // end of class oln::window_<dpoint>
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_WINDOW_HH
Index: oln/core/gen/bkd_piter_bbox.hh
===================================================================
--- oln/core/gen/bkd_piter_bbox.hh (revision 606)
+++ oln/core/gen/bkd_piter_bbox.hh (working copy)
@@ -30,6 +30,7 @@
# define OLN_CORE_GEN_BKD_PITER_BBOX_HH
# include <oln/core/abstract/topology.hh>
+# include <oln/core/abstract/point.hh>
# include <oln/core/internal/bbox_bkd_piter.hh>
@@ -38,75 +39,58 @@
// Forward declaration.
- template <typename topo> class bkd_piter_bbox_;
+ template <typename point_t> class bkd_piter_bbox_;
// Super type declaration.
- template <typename topo>
- struct set_super_type< bkd_piter_bbox_<topo> >
+ template <typename point_t>
+ struct set_super_type< bkd_piter_bbox_<point_t> >
{
- typedef bkd_piter_bbox_<topo> self_t;
+ typedef bkd_piter_bbox_<point_t> self_t;
typedef internal::bbox_bkd_piter<self_t> ret;
};
- /// Virtual types associated to oln::bkd_piter_bbox_<topo>.
- template <typename topo>
- struct vtypes< bkd_piter_bbox_<topo> >
+ /// Virtual types associated to oln::bkd_piter_bbox_<point_t>.
+ template <typename point_t>
+ struct vtypes< bkd_piter_bbox_<point_t> >
{
- typedef oln_type_of(topo, point) point_type;
- typedef oln_type_of(topo, grid) grid_type;
- typedef topo topo_type;
+ typedef point_t point_type;
+ typedef oln_type_of(point_t, grid) grid_type;
};
/// Abstract forward point iterator class.
- template <typename topo_t>
- class bkd_piter_bbox_ : public internal::bbox_bkd_piter< bkd_piter_bbox_<topo_t> >,
- private mlc::assert_< mlc_is_a(topo_t, abstract::topology) >
+ template <typename point_t>
+ class bkd_piter_bbox_ : public internal::bbox_bkd_piter< bkd_piter_bbox_<point_t> >,
+ private mlc::assert_< mlc_is_a(point_t, abstract::point) >
{
- typedef bkd_piter_bbox_<topo_t> self_t;
+ typedef bkd_piter_bbox_<point_t> self_t;
typedef internal::bbox_bkd_piter<self_t> super_t;
public:
template <typename T>
bkd_piter_bbox_(const abstract::topology<T>& topo)
- : super_t(topo.exact().bbox()),
- topo_(topo.exact())
+ : super_t(topo.exact().bbox())
{
}
- const topo_t& topo() const
- {
- return topo_;
- }
-
void print(std::ostream& ostr) const
{
- ostr << "{ p=" << super_t::p_
+ ostr << "{ p=" << this->p_
<< " }";
}
friend
- std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<topo_t>& t)
+ std::ostream& operator<<(std::ostream& ostr, const bkd_piter_bbox_<point_t>& t)
{
t.print(ostr);
return ostr;
}
- template <typename new_topo_t>
- struct change_topology_
- {
- typedef bkd_piter_bbox_<new_topo_t> ret;
- };
-
- protected:
-
- const topo_t topo_;
-
- }; // end of class oln::bkd_piter_bbox_<point>
+ }; // end of class oln::bkd_piter_bbox_<point_t>
} // end of namespace oln
Index: oln/basics2d.hh
===================================================================
--- oln/basics2d.hh (revision 606)
+++ oln/basics2d.hh (working copy)
@@ -47,10 +47,10 @@
namespace oln { template class topo_lbbox_<point2d>; }
# include <oln/core/gen/fwd_piter_bbox.hh>
-namespace oln { template class fwd_piter_bbox_<topo2d>; }
+namespace oln { template class fwd_piter_bbox_<point2d>; }
# include <oln/core/gen/bkd_piter_bbox.hh>
-namespace oln { template class bkd_piter_bbox_<topo2d>; }
+namespace oln { template class bkd_piter_bbox_<point2d>; }
# include <oln/core/gen/neighb.hh>
namespace oln { template class neighb_<dpoint2d>; }
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 606)
+++ oln/Makefile.am (working copy)
@@ -82,6 +82,7 @@
core/abstract/topology_being_random_accessible.hh \
core/abstract/topology_having_bbox.hh \
core/abstract/topology_having_neighborhood.hh \
+ core/abstract/topology_having_subset.hh \
core/abstract/topology_hierarchies.hh \
\
core/automatic/image.hh \
@@ -93,17 +94,23 @@
core/automatic/topology_being_random_accessible.hh \
core/automatic/topology_having_bbox.hh \
core/automatic/topology_having_neighborhood.hh \
+ core/automatic/topology_having_subset.hh \
\
+ core/fwd_piter.hh \
+ \
core/gen/bbox.hh \
core/gen/bbox_bkd_piter.hh \
core/gen/bbox_fwd_piter.hh \
core/gen/bkd_piter_bbox.hh \
+ core/gen/fwd_niter_neighb.hh \
core/gen/fwd_piter_bbox.hh \
+ core/gen/fwd_qiter_win.hh \
core/gen/mapimage.hh \
core/gen/neighb.hh \
core/gen/topo_add_nbh.hh \
core/gen/topo_bbox.hh \
core/gen/topo_lbbox.hh \
+ core/gen/window.hh \
\
core/internal/bbox_bkd_piter.hh \
core/internal/bbox_fwd_piter.hh \
Index: oln/morpher/add_isubset.hh
===================================================================
--- oln/morpher/add_isubset.hh (revision 606)
+++ oln/morpher/add_isubset.hh (working copy)
@@ -58,26 +58,49 @@
// Topology type.
typedef topo_add_isubset< oln_type_of(Image, topo), Isubset > topo_type;
- // Piter types.
- typedef piter_isubset_<oln_type_of(Image, fwd_piter), Isubset> fwd_piter_type;
- typedef piter_isubset_<oln_type_of(Image, bkd_piter), Isubset> bkd_piter_type;
-
// Isubset type.
typedef Isubset subset_type;
};
+// template <typename Image, typename Isubset>
+// struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::fwd_niter_type >
+// {
+// private:
+// typedef oln_type_of(Image, fwd_niter) basic_fwd_niter_type;
+// typedef topo_add_isubset< oln_type_of(Image, topo), Isubset > new_topo_type;
+// typedef typename basic_fwd_niter_type::template change_topology_<new_topo_type>::ret intra_fwd_niter_type;
+// public:
+// typedef piter_isubset_<intra_fwd_niter_type, Isubset> ret;
+// };
+
+
+// template <typename Image, typename Isubset>
+// struct single_vtype< morpher::add_isubset<Image, Isubset>, typedef_::bkd_niter_type >
+// {
+// private:
+// typedef oln_type_of(Image, bkd_niter) basic_bkd_niter_type;
+// typedef topo_add_isubset< oln_type_of(Image, topo), Isubset > new_topo_type;
+// typedef typename basic_bkd_niter_type::template change_topology_<new_topo_type>::ret intra_bkd_niter_type;
+// public:
+// typedef piter_isubset_<intra_bkd_niter_type, Isubset> ret;
+// };
+
+
namespace morpher
{
/// Isubset addition morpher.
template <typename Image, typename Isubset>
- class add_isubset : public stc_get_supers(mlc_comma_1(add_isubset<Image, Isubset>))
+ class add_isubset : public morpher::internal::image_extension< Image,
+ add_isubset<Image, Isubset> >
+ // FIXME: Uncomment. stc_get_supers(mlc_comma_1(add_isubset<Image, Isubset>))
{
private:
typedef add_isubset<Image, Isubset> self_t;
typedef stc_get_nth_super(self_t, 1) super_t;
- typedef oln_type_of(self_t, topo) topo_t;
+ typedef oln_direct_type_of(self_t, topo) topo_t;
+ // FIXME: use of oln_direct_type_of here!!! otherwise we get some compilation trouble...
public:
Index: oln/morpher/internal/image_extension.hh
===================================================================
--- oln/morpher/internal/image_extension.hh (revision 606)
+++ oln/morpher/internal/image_extension.hh (working copy)
@@ -78,6 +78,12 @@
{
public:
+// template <typename I>
+// image_extension(const abstract::image<I>& image)
+// {
+// mlc::abort_<I>::check();
+// }
+
// FIXME: Handle the constness.
image_extension(const Image& image) :
image_(image)
@@ -90,7 +96,7 @@
}
protected:
- const Image& image_;
+ Image image_;
};
} // end of namespace oln::morpher::internal
Index: oln/morpher/add_neighborhood.hh
===================================================================
--- oln/morpher/add_neighborhood.hh (revision 606)
+++ oln/morpher/add_neighborhood.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/morpher/internal/image_extension.hh>
# include <oln/core/gen/topo_add_nbh.hh>
+# include <oln/core/gen/fwd_niter_neighb.hh>
namespace oln
@@ -54,18 +55,9 @@
template <typename Image, typename Neighb>
struct vtypes< morpher::add_neighborhood<Image, Neighb> >
{
- private:
-
- typedef oln_type_of(Image, fwd_piter) basic_fwd_piter_type;
- typedef oln_type_of(Image, bkd_piter) basic_bkd_piter_type;
-
- public:
// Topology type.
typedef topo_add_nbh< oln_type_of(Image, topo), Neighb > topo_type;
- typedef typename basic_fwd_piter_type::template change_topology_<topo_type>::ret fwd_piter_type;
- typedef typename basic_bkd_piter_type::template change_topology_<topo_type>::ret bkd_piter_type;
-
// Neighborhood type.
typedef Neighb neighborhood_type;
};
@@ -75,7 +67,9 @@
{
/// Neighborhood addition morpher.
template <typename Image, typename Neighb>
- class add_neighborhood : public stc_get_supers(mlc_comma_1(add_neighborhood<Image, Neighb>))
+ class add_neighborhood : public morpher::internal::image_extension< Image,
+ add_neighborhood<Image, Neighb> >
+ // FIXME: Uncomment. stc_get_supers(mlc_comma_1(add_neighborhood<Image, Neighb>))
{
private:
@@ -87,6 +81,12 @@
// FIXME: Handle the constness.
+// template <typename I, typename N>
+// add_neighborhood(const abstract::image<I>& image, const N& nbh)
+// : super_t(image)
+// {
+// }
+
add_neighborhood(const Image& image, const Neighb& nbh) :
super_t(image),
topo_(image.topo(), nbh)
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Oops (I did it again).
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix the distribution.
* oln/Makefile.am (nobase_oln_HEADERS): Add core/1d/aliases.hh,
core/1d/array1d.hh, core/1d/dpoint1d.hh, core/1d/image1d.hh,
core/1d/neighb1d.hh, core/1d/point1d.hh, core/3d/aliases.hh,
core/3d/array3d.hh, core/3d/dpoint3d.hh, core/3d/image3d.hh,
core/3d/neighb3d.hh, core/3d/point3d.hh,
core/internal/tracked_ptr.hh, basics1d.hh, basics3d.hh.
Makefile.am | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
Index: oln/Makefile.am
--- oln/Makefile.am (revision 605)
+++ oln/Makefile.am (working copy)
@@ -3,7 +3,13 @@
olndir = $(includedir)/oln
nobase_oln_HEADERS = \
\
+ core/1d/aliases.hh \
+ core/1d/array1d.hh \
+ core/1d/dpoint1d.hh \
core/1d/grid1d.hh \
+ core/1d/image1d.hh \
+ core/1d/neighb1d.hh \
+ core/1d/point1d.hh \
\
core/2d/aliases.hh \
core/2d/array2d.hh \
@@ -13,7 +19,13 @@
core/2d/neighb2d.hh \
core/2d/point2d.hh \
\
+ core/3d/aliases.hh \
+ core/3d/array3d.hh \
+ core/3d/dpoint3d.hh \
core/3d/grid3d.hh \
+ core/3d/image3d.hh \
+ core/3d/neighb3d.hh \
+ core/3d/point3d.hh \
\
core/abstract/image/accessibility/hierarchy.hh \
\
@@ -98,6 +110,7 @@
core/internal/dpoint_nd.hh \
core/internal/point_nd.hh \
core/internal/topology_morpher.hh \
+ core/internal/tracked_ptr.hh \
\
core/case.hh \
core/image_entry.hh \
@@ -120,4 +133,6 @@
morpher/identity.hh \
morpher/tags.hh \
\
- basics2d.hh
+ basics1d.hh \
+ basics2d.hh \
+ basics3d.hh
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
I'm currently working on a ``slice'' morpher; this is why I added 1-d
and 3-d images.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add oln::image3d and associated types.
* oln/core/3d/image3d.hh, oln/core/3d/array3d.hh,
* oln/core/3d/point3d.hh, oln/core/3d/dpoint3d.hh,
* oln/core/3d/neighb3d.hh, oln/core/3d/aliases.hh,
* oln/basics3d.hh: New.
* oln/core/abstract/point_set_being_connected.hh
(oln::abstract::point_set_being_3d_connected): New class.
(oln::case_<point_set_hierarchy_wrt_connectivity, E, 3>): New
case.
* tests/image3d.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add image3d.
(image3d_SOURCES): New.
oln/basics3d.hh | 62 +++++++
oln/core/3d/aliases.hh | 69 ++++++++
oln/core/3d/array3d.hh | 157 +++++++++++++++++++
oln/core/3d/dpoint3d.hh | 104 ++++++++++++
oln/core/3d/image3d.hh | 139 +++++++++++++++++
oln/core/3d/neighb3d.hh | 204 +++++++++++++++++++++++++
oln/core/3d/point3d.hh | 114 +++++++++++++
oln/core/abstract/point_set_being_connected.hh | 41 +++++
tests/Makefile.am | 2
tests/image3d.cc | 65 +++++++
10 files changed, 957 insertions(+)
Index: oln/core/3d/image3d.hh
--- oln/core/3d/image3d.hh (revision 0)
+++ oln/core/3d/image3d.hh (revision 0)
@@ -0,0 +1,139 @@
+// Copyright (C) 2001, 2002, 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_3D_IMAGE3D_HH
+# define OLN_CORE_3D_IMAGE3D_HH
+
+# include <oln/core/image_entry.hh>
+# include <oln/core/3d/array3d.hh>
+# include <oln/core/internal/tracked_ptr.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ template <typename T> class image3d;
+
+
+ /// Virtual types associated to oln::image3d<T>.
+ template <typename T>
+ struct vtypes< image3d<T> >
+ {
+ // FIXME: or `typedef topo3d topo_type;' ?
+ typedef topo_lbbox_<point3d> topo_type;
+ typedef grid3d grid_type;
+
+ typedef point3d point_type;
+
+ typedef fwd_piter_bbox_<topo_type> fwd_piter_type;
+ typedef bkd_piter_bbox_<topo_type> bkd_piter_type;
+
+ typedef T value_type;
+ typedef T lvalue_type;
+ typedef mlc::true_ is_mutable_type;
+
+ typedef image3d<T> real_type;
+ };
+
+
+ /// Super type declaration.
+ template <typename T>
+ struct set_super_type< image3d<T> >
+ {
+ typedef image3d<T> self_t;
+ typedef image_entry<self_t> ret;
+ };
+
+
+ /// General 3D image class.
+ template <typename T>
+ class image3d : public image_entry< image3d<T> >
+ {
+ typedef image3d<T> self_t;
+ typedef array3d<T> array_t;
+
+ public:
+
+ /// Ctor using sizes.
+ image3d(unsigned nslices, unsigned nrows, unsigned ncols,
+ unsigned border = 2)
+ : topo_(bbox3d(point3d(0, 0, 0 ),
+ point3d(nslices - 1, nrows - 1, ncols - 1)),
+ border),
+ data_(new array_t(0 - border,
+ 0 - border,
+ 0 - border,
+ nslices - 1 + border,
+ nrows - 1 + border,
+ ncols - 1 + border))
+ {
+ }
+
+ /// Ctor using an existing topology.
+ image3d(const topo3d& topo)
+ : topo_(topo),
+ data_(new array_t(topo.bbox().pmin().slice(),
+ topo.bbox().pmin().row(),
+ topo.bbox().pmin().col(),
+ topo.bbox().pmax().slice(),
+ topo.bbox().pmax().row(),
+ topo.bbox().pmax().col()))
+ {
+ }
+
+ const topo3d& impl_topo() const
+ {
+ return topo_;
+ }
+
+ T impl_op_read(const point3d& p) const
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.slice(), p.row(), p.col());
+ }
+
+ T& impl_op_readwrite(const point3d& p)
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.slice(), p.row(), p.col());
+ }
+
+ private:
+
+ topo3d topo_;
+ internal::tracked_ptr<array_t> data_;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_IMAGE3D_HH
Index: oln/core/3d/array3d.hh
--- oln/core/3d/array3d.hh (revision 0)
+++ oln/core/3d/array3d.hh (revision 0)
@@ -0,0 +1,157 @@
+// Copyright (C) 2001, 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 OLN_CORE_3D_ARRAY3D_HH
+# define OLN_CORE_3D_ARRAY3D_HH
+
+# include <cstdlib>
+# include <mlc/contract.hh>
+
+
+namespace oln
+{
+
+ /// General 3D array class.
+ template <typename value_t, typename coord_t = int>
+ class array3d
+ {
+ public:
+
+ /// Ctor.
+ array3d(coord_t imin, coord_t jmin, coord_t kmin,
+ coord_t imax, coord_t jmax, coord_t kmax) :
+ imin_(imin), jmin_(jmin), kmin_(kmin),
+ imax_(imax), jmax_(jmax), kmax_(kmax)
+ {
+ precondition(imax >= imin and jmax >= jmin and kmax >= kmin);
+ ilen_ = imax - imin + 1;
+ jlen_ = jmax - jmin + 1;
+ klen_ = kmax - kmin + 1;
+ allocate_();
+ }
+
+ /// Ctor.
+ array3d(coord_t ilen, coord_t jlen, coord_t klen) :
+ imin_(0), jmin_(0), kmin_(0),
+ ilen_(ilen), jlen_(jlen), klen_(klen)
+ {
+ precondition(ilen > 0 and jlen > 0 and klen > 0);
+ imax_ = imin_ + ilen_;
+ jmax_ = jmin_ + ilen_;
+ kmax_ = kmin_ + klen_;
+ allocate_();
+ }
+
+ /// Dtor.
+ ~array3d()
+ {
+ deallocate_();
+ }
+
+ value_t operator()(coord_t i, coord_t j, coord_t k) const
+ {
+ precondition(has(i, j, k));
+ return array_1st_dim_[i][j][k];
+ }
+
+ value_t& operator()(coord_t i, coord_t j, coord_t k)
+ {
+ precondition(has(i, j, k));
+ return array_1st_dim_[i][j][k];
+ }
+
+ bool has(coord_t i, coord_t j, coord_t k) const
+ {
+ return
+ i >= imin_ and i <= imax_ and
+ j >= jmin_ and j <= jmax_ and
+ k >= kmin_ and k <= kmax_;
+ }
+
+ size_t memsize() const
+ {
+ return
+ // buffer_
+ size_t(ilen_) * size_t(jlen_) * size_t(klen_) * sizeof(value_t)
+ +
+ // array_2nd_dim_
+ size_t(ilen_) * size_t(jlen_) * sizeof(value_t*)
+ +
+ // array_1st_dim_
+ size_t(ilen_) * sizeof(value_t*);
+ }
+
+ protected:
+
+ coord_t imin_, jmin_, kmin_, imax_, jmax_, kmax_;
+ coord_t ilen_, jlen_, klen_;
+ value_t* buffer_;
+ value_t** array_2nd_dim_;
+ value_t*** array_1st_dim_;
+
+ private:
+
+ void allocate_()
+ {
+ buffer_ = new value_t[size_t(ilen_) * size_t(jlen_) * size_t(klen_)];
+ array_2nd_dim_ = new value_t*[size_t(ilen_) * size_t(jlen_)];
+ array_1st_dim_ = new value_t**[size_t(ilen_)];
+ value_t* buf = buffer_ - kmin_;
+ for (coord_t i = 0; i < ilen_; ++i)
+ {
+ value_t** nth_array_2nd_dim = array_2nd_dim_ + i * jlen_;
+ array_1st_dim_[i] = nth_array_2nd_dim - jmin_;
+ for (coord_t j = 0; j < jlen_; ++j)
+ {
+ nth_array_2nd_dim[j] = buf;
+ buf += klen_;
+ }
+ }
+ array_1st_dim_ -= imin_;
+ }
+
+ void deallocate_()
+ {
+ precondition(buffer_ != 0 and
+ array_2nd_dim_ != 0 and
+ array_1st_dim_ != 0);
+ delete[] buffer_;
+ buffer_ = 0; // safety
+ delete[] array_2nd_dim_;
+ array_2nd_dim_ = 0; // safety
+ array_1st_dim_ += imin_;
+ delete[] array_1st_dim_;
+ array_1st_dim_ = 0; // safety
+ }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_ARRAY3D_HH
Index: oln/core/3d/point3d.hh
--- oln/core/3d/point3d.hh (revision 0)
+++ oln/core/3d/point3d.hh (revision 0)
@@ -0,0 +1,114 @@
+// 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 OLN_CORE_3D_POINT3D_HH
+# define OLN_CORE_3D_POINT3D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/internal/point_nd.hh>
+
+
+namespace oln
+{
+
+ /* FIXME: Is this the right place for these functions (on types)?
+ In particular, the function on dpoint3d should be near the
+ definition of dpoint3d, not point3d's. */
+ /// Specializations of functions point and dpoint :
+ /// \f$(n, coord) \rightarrow type\f$ for \f$n = 3\f$.
+ /// \{
+ template <typename C> struct point_ <3, C> { typedef point3d_<C> ret; };
+ template <typename C> struct dpoint_ <3, C> { typedef dpoint3d_<C> ret; };
+ /// \}
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< point3d_<C> >
+ {
+ typedef internal::point_nd< point3d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::point3d_<C>.
+ template <typename C>
+ struct vtypes< point3d_<C> >
+ {
+ typedef grid3d grid_type;
+ typedef dpoint3d dpoint_type;
+ typedef C coord_type;
+ typedef mlc::uint_<3> dim_type;
+ };
+
+
+ /// General 3D point class.
+ template <typename C>
+ class point3d_ : public stc_get_supers(point3d_<C>)
+ {
+ typedef point3d_<C> self_t;
+ typedef stc_get_super(point3d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ point3d_()
+ {
+ }
+
+ /// Ctor.
+ point3d_(coord_t slice, coord_t row, coord_t col)
+ : super_t (xtd::mk_vec(slice, row, col))
+ {
+ }
+
+ /// Ctor.
+ point3d_(const xtd::vec<3,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ coord_t slice() const { return v_[0]; }
+ coord_t& slice() { return v_[0]; }
+
+ coord_t row() const { return v_[1]; }
+ coord_t& row() { return v_[1]; }
+
+ coord_t col() const { return v_[2]; }
+ coord_t& col() { return v_[2]; }
+ };
+
+
+} // end of namespace oln
+
+# include <oln/core/3d/dpoint3d.hh>
+
+
+#endif // ! OLN_CORE_3D_POINT3D_HH
Index: oln/core/3d/dpoint3d.hh
--- oln/core/3d/dpoint3d.hh (revision 0)
+++ oln/core/3d/dpoint3d.hh (revision 0)
@@ -0,0 +1,104 @@
+// 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 OLN_CORE_3D_DPOINT3D_HH
+# define OLN_CORE_3D_DPOINT3D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/3d/point3d.hh>
+# include <oln/core/internal/dpoint_nd.hh>
+
+
+namespace oln
+{
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< dpoint3d_<C> >
+ {
+ typedef internal::dpoint_nd< dpoint3d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::dpoint3d_<C>.
+ template <typename C>
+ struct vtypes< dpoint3d_<C> >
+ {
+ typedef grid3d grid_type;
+ typedef point3d point_type;
+ typedef C coord_type;
+ typedef mlc::uint_<3> dim_type;
+ };
+
+
+ /// General 3D dpoint class.
+ template <typename C>
+ class dpoint3d_
+ : public stc_get_supers(dpoint3d_<C>)
+ {
+ typedef dpoint3d_<C> self_t;
+ typedef stc_get_super(dpoint3d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ dpoint3d_()
+ {
+ }
+
+ /// Ctor.
+ dpoint3d_(const xtd::vec<3,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ /// Ctor.
+ dpoint3d_(coord_t slice, coord_t row, coord_t col)
+ : super_t(xtd::mk_vec(slice, row, col))
+ {
+ }
+
+ coord_t slice() const { return v_[0]; }
+ coord_t& slice() { return v_[0]; }
+
+ coord_t row() const { return v_[1]; }
+ coord_t& row() { return v_[1]; }
+
+ coord_t col() const { return v_[2]; }
+ coord_t& col() { return v_[2]; }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_DPOINT3D_HH
Index: oln/core/3d/neighb3d.hh
--- oln/core/3d/neighb3d.hh (revision 0)
+++ oln/core/3d/neighb3d.hh (revision 0)
@@ -0,0 +1,204 @@
+// 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 OLN_CORE_3D_NEIGHB3D_HH
+# define OLN_CORE_3D_NEIGHB3D_HH
+
+# include <oln/core/gen/neighb.hh>
+# include <oln/core/3d/aliases.hh>
+
+
+namespace oln
+{
+
+
+ neighb3d c6()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(1, 0, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c18()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, -1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(0, 1, 1))
+ .add(dpoint3d(1, -1, 0))
+ .add(dpoint3d(1, 0, -1))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 0, 1))
+ .add(dpoint3d(1, 1, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c26()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, -1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(0, 1, 1))
+ .add(dpoint3d(1, -1, -1))
+ .add(dpoint3d(1, -1, 0))
+ .add(dpoint3d(1, -1, 1))
+ .add(dpoint3d(1, 0, -1))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 0, 1))
+ .add(dpoint3d(1, 1, -1))
+ .add(dpoint3d(1, 1, 0))
+ .add(dpoint3d(1, 1, 1));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c4_slice()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c8_slice()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(0, 1, -1))
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(0, 1, 1));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c4_row()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(1, 0, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c8_row()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 0, 1))
+ .add(dpoint3d(1, 0, -1))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 0, 1));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c4_col()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(1, 0, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+ neighb3d c8_col()
+ {
+ static bool flower = true;
+ static neighb3d the_;
+ if (flower)
+ {
+ the_
+ .add(dpoint3d(0, 1, 0))
+ .add(dpoint3d(1, -1, 0))
+ .add(dpoint3d(1, 0, 0))
+ .add(dpoint3d(1, 1, 0));
+ flower = false;
+ }
+ return the_;
+ }
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLN_CORE_3D_NEIGHB3D_HH
Index: oln/core/3d/aliases.hh
--- oln/core/3d/aliases.hh (revision 0)
+++ oln/core/3d/aliases.hh (revision 0)
@@ -0,0 +1,69 @@
+// 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_3D_ALIASES_HH
+# define OLN_CORE_3D_ALIASES_HH
+
+
+namespace oln
+{
+
+ /// \{
+ /// Forward declarations.
+ template <typename C> class point3d_;
+ template <typename C> class dpoint3d_;
+ template <typename D> class neighb_;
+ 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_;
+ class grid3d;
+ /// \}
+
+
+ /// \{
+ /// Alliases.
+ typedef point3d_<int> point3d;
+ typedef dpoint3d_<int> dpoint3d;
+
+ typedef neighb_<dpoint3d> neighb3d;
+
+ typedef bbox_<point3d> bbox3d;
+ typedef topo_lbbox_<point3d> topo3d;
+ typedef fwd_piter_bbox_<topo3d> fwd_piter3d;
+ typedef bkd_piter_bbox_<topo3d> bkd_piter3d;
+
+ typedef point3d_<float> point3df;
+ typedef dpoint3d_<float> dpoint3df;
+ /// \}
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_3D_ALIASES_HH
Index: oln/basics3d.hh
--- oln/basics3d.hh (revision 0)
+++ oln/basics3d.hh (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (C) 2001, 2002, 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_BASICS3D_HH
+# define OLN_BASICS3D_HH
+
+
+# include <oln/core/3d/aliases.hh>
+
+# include <oln/core/3d/grid3d.hh>
+
+# include <oln/core/3d/point3d.hh>
+namespace oln { template class point3d_<int>; }
+
+# include <oln/core/3d/dpoint3d.hh>
+namespace oln { template class dpoint3d_<int>; }
+
+# include <oln/core/gen/bbox.hh>
+namespace oln { template class bbox_<point3d>; }
+
+# include <oln/core/gen/topo_lbbox.hh>
+namespace oln { template class topo_lbbox_<point3d>; }
+
+# include <oln/core/gen/fwd_piter_bbox.hh>
+namespace oln { template class fwd_piter_bbox_<topo3d>; }
+
+# include <oln/core/gen/bkd_piter_bbox.hh>
+namespace oln { template class bkd_piter_bbox_<topo3d>; }
+
+# include <oln/core/gen/neighb.hh>
+namespace oln { template class neighb_<dpoint3d>; }
+# include <oln/core/3d/neighb3d.hh>
+
+# include <oln/core/3d/image3d.hh>
+
+
+#endif // ! OLN_BASICS3D_HH
Index: oln/core/abstract/point_set_being_connected.hh
--- oln/core/abstract/point_set_being_connected.hh (revision 604)
+++ oln/core/abstract/point_set_being_connected.hh (working copy)
@@ -79,6 +79,35 @@
{}
};
+ template <typename E>
+ class point_set_being_3d_connected : public virtual abstract::point_set<E>
+ {
+ public:
+
+ unsigned nslices() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ unsigned nrows() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(1);
+ }
+
+ unsigned ncols() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(2);
+ }
+
+ protected:
+
+ point_set_being_3d_connected()
+ {}
+ };
+
} // end of namespace oln::abstract
@@ -86,6 +115,7 @@
// Forward declarations.
class grid1d;
class grid2d;
+ class grid3d;
template <typename E>
@@ -110,6 +140,17 @@
typedef abstract::point_set_being_2d_connected<E> ret;
};
+ template <typename E>
+ struct case_ < point_set_hierarchy_wrt_connectivity, E, 3 >
+ : where_< mlc::and_list_<
+ mlc::neq_< oln_type_of(E, bbox), mlc::none >,
+ mlc::eq_< oln_type_of(E, is_connected), mlc::true_ >,
+ mlc::eq_< oln_type_of(E, grid), grid3d >
+ > >
+ {
+ typedef abstract::point_set_being_3d_connected<E> ret;
+ };
+
} // end of namespace oln
Index: tests/Makefile.am
--- tests/Makefile.am (revision 604)
+++ tests/Makefile.am (working copy)
@@ -22,6 +22,7 @@
image_entry \
image1d \
image2d \
+ image3d \
npoints \
\
identity_morpher \
@@ -37,6 +38,7 @@
image_entry_SOURCES = image_entry.cc
image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
+image3d_SOURCES = image3d.cc
npoints_SOURCES = npoints.cc
# Morphers.
Index: tests/image3d.cc
--- tests/image3d.cc (revision 0)
+++ tests/image3d.cc (revision 0)
@@ -0,0 +1,65 @@
+// 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 oln::image3d.
+
+#include <cassert>
+// FIXME: We should not include oln/basics3d.hh, but
+// oln/core/3d/image3d.hh (and oln/core/3d/neigh3d.hh ?).
+#include <oln/basics3d.hh>
+#include <oln/level/fill.hh>
+
+int
+main()
+{
+ // Fill a 3-d image using its iterator.
+ oln::image3d<char> ima1(3, 3, 3);
+ oln_type_of_(oln::image3d<char>, piter) p1(ima1.topo());
+ for_all(p1)
+ ima1(p1) = 1;
+
+ // Fill a 3-d image using a classic loop.
+ oln::image3d<int> ima2(ima1.topo());
+ for (unsigned i = 0; i < 3; ++i)
+ for (unsigned j = 0; j < 3; ++j)
+ for (unsigned k = 0; k < 3; ++k)
+ ima2(oln::point3d(i, j, k)) = 2;
+
+ // Fill a 3-d image using the routine oln::level::fill.
+ oln::image3d<long> ima3(ima1.topo());
+ oln::level::fill(ima3, 3);
+
+
+ // Add the three images.
+ oln::image3d<long> sum(ima1.topo());
+ oln_type_of_(oln::image3d<long>, piter) p(sum.topo());
+ for_all(p)
+ sum(p) = ima1(p) + ima2(p) + ima3(p);
+ // And check the sum.
+ for_all(p)
+ assert(sum(p) == 6);
+}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add oln::image1d and associated types.
* oln/core/1d/image1d.hh, oln/core/1d/array1d.hh,
* oln/core/1d/point1d.hh, oln/core/1d/dpoint1d.hh,
* oln/core/1d/neighb1d.hh, oln/core/1d/aliases.hh,
* oln/basics1d.hh: New.
* oln/core/abstract/point_set_being_connected.hh
(oln::abstract::point_set_being_1d_connected): New class.
(oln::case_<point_set_hierarchy_wrt_connectivity, E, 1>): Handle
the 1-dimension case, and move the 2-dimension case...
(oln::case_<point_set_hierarchy_wrt_connectivity, E, 2>): ...here
(new).
* tests/image1d.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add image1d.
(image1d_SOURCES): New.
oln/basics1d.hh | 62 ++++++++++++
oln/core/1d/aliases.hh | 69 +++++++++++++
oln/core/1d/array1d.hh | 117 +++++++++++++++++++++++
oln/core/1d/dpoint1d.hh | 98 +++++++++++++++++++
oln/core/1d/image1d.hh | 127 +++++++++++++++++++++++++
oln/core/1d/neighb1d.hh | 54 ++++++++++
oln/core/1d/point1d.hh | 108 +++++++++++++++++++++
oln/core/abstract/point_set_being_connected.hh | 39 +++++++
tests/Makefile.am | 2
tests/image1d.cc | 63 ++++++++++++
10 files changed, 737 insertions(+), 2 deletions(-)
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 0)
+++ oln/core/1d/image1d.hh (revision 0)
@@ -0,0 +1,127 @@
+// Copyright (C) 2001, 2002, 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_IMAGE1D_HH
+# define OLN_CORE_1D_IMAGE1D_HH
+
+# include <oln/core/image_entry.hh>
+# include <oln/core/1d/array1d.hh>
+# include <oln/core/internal/tracked_ptr.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ template <typename T> class image1d;
+
+
+ /// Virtual types associated to oln::image1d<T>.
+ template <typename T>
+ struct vtypes< image1d<T> >
+ {
+ typedef topo_lbbox_<point1d> topo_type;
+ typedef grid1d grid_type;
+
+ typedef point1d point_type;
+
+ typedef fwd_piter_bbox_<topo_type> fwd_piter_type;
+ typedef bkd_piter_bbox_<topo_type> bkd_piter_type;
+
+ typedef T value_type;
+ typedef T lvalue_type;
+ typedef mlc::true_ is_mutable_type;
+
+ typedef image1d<T> real_type;
+ };
+
+
+ /// Super type declaration.
+ template <typename T>
+ struct set_super_type< image1d<T> >
+ {
+ typedef image1d<T> self_t;
+ typedef image_entry<self_t> ret;
+ };
+
+
+ /// General 1D image class.
+ template <typename T>
+ class image1d : public image_entry< image1d<T> >
+ {
+ typedef image1d<T> self_t;
+ typedef array1d<T> array_t;
+
+ public:
+
+ /// Ctor using sizes.
+ image1d(unsigned nindices, unsigned border = 2)
+ : topo_(bbox1d(point1d(0), point1d(nindices - 1)), border),
+ data_(new array_t(0 - border,
+ nindices - 1 + border))
+ {
+ }
+
+ /// Ctor using an existing topology.
+ image1d(const topo1d& topo)
+ : topo_(topo),
+ data_(new array_t(topo.bbox().pmin().index(),
+ topo.bbox().pmax().index()))
+ {
+ }
+
+ const topo1d& impl_topo() const
+ {
+ return topo_;
+ }
+
+ T impl_op_read(const point1d& p) const
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.index());
+ }
+
+ T& impl_op_readwrite(const point1d& p)
+ {
+ precondition(data_ != 0);
+ precondition(topo_.has_large(p));
+ return data_->operator()(p.index());
+ }
+
+ private:
+
+ topo1d topo_;
+ internal::tracked_ptr<array_t> data_;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_IMAGE1D_HH
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 0)
+++ oln/core/1d/array1d.hh (revision 0)
@@ -0,0 +1,117 @@
+// Copyright (C) 2001, 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 OLN_CORE_1D_ARRAY1D_HH
+# define OLN_CORE_1D_ARRAY1D_HH
+
+# include <cstdlib>
+# include <mlc/contract.hh>
+
+
+namespace oln
+{
+
+ /// General 1D array class.
+ template <typename value_t, typename coord_t = int>
+ class array1d
+ {
+ public:
+
+ /// Ctor.
+ array1d(coord_t min, coord_t max) :
+ min_(min), max_(max)
+ {
+ precondition(max >= min);
+ len_ = max - min + 1;
+ allocate_();
+ }
+
+ /// Ctor.
+ array1d(coord_t len) :
+ min_(0), len_(len)
+ {
+ precondition(len > 0);
+ max_ = min_ + len_;
+ allocate_();
+ }
+
+ /// Dtor.
+ ~array1d()
+ {
+ deallocate_();
+ }
+
+ value_t operator()(coord_t i) const
+ {
+ precondition(has(i));
+ return buffer_[i - min_];
+ }
+
+ value_t& operator()(coord_t i)
+ {
+ precondition(has(i));
+ return buffer_[i - min_];
+ }
+
+ bool has(coord_t i) const
+ {
+ return
+ i >= min_ and i <= max_;
+ }
+
+ size_t memsize() const
+ {
+ return size_t(len_) * sizeof(value_t);
+ }
+
+ protected:
+
+ coord_t min_, max_;
+ coord_t len_;
+ value_t* buffer_;
+
+ private:
+
+ void allocate_()
+ {
+ buffer_ = new value_t[size_t(len_)];
+ }
+
+ void deallocate_()
+ {
+ precondition(buffer_ != 0);
+ delete[] buffer_;
+ buffer_ = 0; // safety
+ }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_ARRAY1D_HH
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 0)
+++ oln/core/1d/point1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// 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 OLN_CORE_1D_POINT1D_HH
+# define OLN_CORE_1D_POINT1D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/internal/point_nd.hh>
+
+
+namespace oln
+{
+
+ /* FIXME: Is this the right place for these functions (on types)?
+ In particular, the function on dpoint1d should be near the
+ definition of dpoint1d, not point1d's. */
+ /// Specializations of functions point and dpoint :
+ /// \f$(n, coord) \rightarrow type\f$ for \f$n = 1\f$.
+ /// \{
+ template <typename C> struct point_ <1, C> { typedef point1d_<C> ret; };
+ template <typename C> struct dpoint_ <1, C> { typedef dpoint1d_<C> ret; };
+ /// \}
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< point1d_<C> >
+ {
+ typedef internal::point_nd< point1d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::point1d_<C>.
+ template <typename C>
+ struct vtypes< point1d_<C> >
+ {
+ typedef grid1d grid_type;
+ typedef dpoint1d dpoint_type;
+ typedef C coord_type;
+ typedef mlc::uint_<1> dim_type;
+ };
+
+
+ /// General 1D point class.
+ template <typename C>
+ class point1d_ : public stc_get_supers(point1d_<C>)
+ {
+ typedef point1d_<C> self_t;
+ typedef stc_get_super(point1d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ point1d_()
+ {
+ }
+
+ /// Ctor.
+ point1d_(coord_t index)
+ : super_t (xtd::mk_vec(index))
+ {
+ }
+
+ /// Ctor.
+ point1d_(const xtd::vec<1,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ coord_t index() const { return v_[0]; }
+ coord_t& index() { return v_[0]; }
+ };
+
+
+} // end of namespace oln
+
+# include <oln/core/1d/dpoint1d.hh>
+
+
+#endif // ! OLN_CORE_1D_POINT1D_HH
Index: oln/core/1d/dpoint1d.hh
--- oln/core/1d/dpoint1d.hh (revision 0)
+++ oln/core/1d/dpoint1d.hh (revision 0)
@@ -0,0 +1,98 @@
+// 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 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>
+
+
+namespace oln
+{
+
+
+ /// Super type.
+ template<typename C>
+ struct set_super_type< dpoint1d_<C> >
+ {
+ typedef internal::dpoint_nd< dpoint1d_<C> > ret;
+ };
+
+
+ /// Virtual types associated to oln::dpoint1d_<C>.
+ template <typename C>
+ struct vtypes< dpoint1d_<C> >
+ {
+ typedef grid1d grid_type;
+ typedef point1d point_type;
+ typedef C coord_type;
+ typedef mlc::uint_<1> dim_type;
+ };
+
+
+ /// General 1D dpoint class.
+ template <typename C>
+ class dpoint1d_
+ : public stc_get_supers(dpoint1d_<C>)
+ {
+ typedef dpoint1d_<C> self_t;
+ typedef stc_get_super(dpoint1d_<C>) super_t;
+ typedef oln_type_of(self_t, coord) coord_t;
+
+ using super_t::v_;
+
+ public:
+
+ /// Ctor.
+ dpoint1d_()
+ {
+ }
+
+ /// Ctor.
+ dpoint1d_(const xtd::vec<1,coord_t>& v)
+ : super_t(v)
+ {
+ }
+
+ /// Ctor.
+ dpoint1d_(coord_t index)
+ : super_t(xtd::mk_vec(index))
+ {
+ }
+
+ coord_t index() const { return v_[0]; }
+ coord_t& index() { return v_[0]; }
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_DPOINT1D_HH
Index: oln/core/1d/neighb1d.hh
--- oln/core/1d/neighb1d.hh (revision 0)
+++ oln/core/1d/neighb1d.hh (revision 0)
@@ -0,0 +1,54 @@
+// 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 OLN_CORE_1D_NEIGHB1D_HH
+# define OLN_CORE_1D_NEIGHB1D_HH
+
+# include <oln/core/gen/neighb.hh>
+# include <oln/core/1d/aliases.hh>
+
+
+namespace oln
+{
+
+ neighb1d c2()
+ {
+ static bool flower = true;
+ static neighb1d the_;
+ if (flower)
+ {
+ the_.add(dpoint1d(1));
+ flower = false;
+ }
+ return the_;
+ }
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_NEIGHB1D_HH
Index: oln/core/1d/aliases.hh
--- oln/core/1d/aliases.hh (revision 0)
+++ oln/core/1d/aliases.hh (revision 0)
@@ -0,0 +1,69 @@
+// 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 <typename C> class point1d_;
+ template <typename C> class dpoint1d_;
+ template <typename D> class neighb_;
+ 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_;
+ class grid1d;
+ /// \}
+
+
+ /// \{
+ /// Alliases.
+ typedef point1d_<int> point1d;
+ typedef dpoint1d_<int> dpoint1d;
+
+ typedef neighb_<dpoint1d> neighb1d;
+
+ typedef bbox_<point1d> bbox1d;
+ typedef topo_lbbox_<point1d> topo1d;
+ typedef fwd_piter_bbox_<topo1d> fwd_piter1d;
+ typedef bkd_piter_bbox_<topo1d> bkd_piter1d;
+
+ typedef point1d_<float> point1df;
+ typedef dpoint1d_<float> dpoint1df;
+ /// \}
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_ALIASES_HH
Index: oln/basics1d.hh
--- oln/basics1d.hh (revision 0)
+++ oln/basics1d.hh (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (C) 2001, 2002, 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_BASICS1D_HH
+# define OLN_BASICS1D_HH
+
+
+# include <oln/core/1d/aliases.hh>
+
+# include <oln/core/1d/grid1d.hh>
+
+# include <oln/core/1d/point1d.hh>
+namespace oln { template class point1d_<int>; }
+
+# include <oln/core/1d/dpoint1d.hh>
+namespace oln { template class dpoint1d_<int>; }
+
+# include <oln/core/gen/bbox.hh>
+namespace oln { template class bbox_<point1d>; }
+
+# include <oln/core/gen/topo_lbbox.hh>
+namespace oln { template class topo_lbbox_<point1d>; }
+
+# include <oln/core/gen/fwd_piter_bbox.hh>
+namespace oln { template class fwd_piter_bbox_<topo1d>; }
+
+# include <oln/core/gen/bkd_piter_bbox.hh>
+namespace oln { template class bkd_piter_bbox_<topo1d>; }
+
+# include <oln/core/gen/neighb.hh>
+namespace oln { template class neighb_<dpoint1d>; }
+# include <oln/core/1d/neighb1d.hh>
+
+# include <oln/core/1d/image1d.hh>
+
+
+#endif // ! OLN_BASICS1D_HH
Index: oln/core/abstract/point_set_being_connected.hh
--- oln/core/abstract/point_set_being_connected.hh (revision 603)
+++ oln/core/abstract/point_set_being_connected.hh (working copy)
@@ -39,6 +39,24 @@
template <typename E>
+ class point_set_being_1d_connected : public virtual abstract::point_set<E>
+ {
+ public:
+
+ unsigned nindices() const
+ {
+ precondition(this->is_valid());
+ return this->exact().len(0);
+ }
+
+ protected:
+
+ point_set_being_1d_connected()
+ {}
+ };
+
+
+ template <typename E>
class point_set_being_2d_connected : public virtual abstract::point_set<E>
{
public:
@@ -65,12 +83,29 @@
} // end of namespace oln::abstract
+ // Forward declarations.
+ class grid1d;
+ class grid2d;
+
template <typename E>
struct case_ < point_set_hierarchy_wrt_connectivity, E, 1 >
- : where_< mlc::and_list_< mlc::neq_< oln_type_of(E, bbox), mlc::none >,
+ : where_< mlc::and_list_<
+ mlc::neq_< oln_type_of(E, bbox), mlc::none >,
+ mlc::eq_< oln_type_of(E, is_connected), mlc::true_ >,
+ mlc::eq_< oln_type_of(E, grid), grid1d >
+ > >
+ {
+ typedef abstract::point_set_being_1d_connected<E> ret;
+ };
+
+ template <typename E>
+ struct case_ < point_set_hierarchy_wrt_connectivity, E, 2 >
+ : where_< mlc::and_list_<
+ mlc::neq_< oln_type_of(E, bbox), mlc::none >,
mlc::eq_< oln_type_of(E, is_connected), mlc::true_ >,
- mlc::eq_< oln_type_of(E, grid), grid2d > > >
+ mlc::eq_< oln_type_of(E, grid), grid2d >
+ > >
{
typedef abstract::point_set_being_2d_connected<E> ret;
};
Index: tests/image1d.cc
--- tests/image1d.cc (revision 0)
+++ tests/image1d.cc (revision 0)
@@ -0,0 +1,63 @@
+// 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 oln::image1d.
+
+#include <cassert>
+// FIXME: We should not include oln/basics1d.hh, but
+// oln/core/1d/image1d.hh (and oln/core/1d/neigh1d.hh ?).
+#include <oln/basics1d.hh>
+#include <oln/level/fill.hh>
+
+int
+main()
+{
+ // Fill a 1-d image using its iterator.
+ oln::image1d<char> ima1(3);
+ oln_type_of_(oln::image1d<char>, piter) p1(ima1.topo());
+ for_all(p1)
+ ima1(p1) = 1;
+
+ // Fill a 1-d image using a classic loop.
+ oln::image1d<int> ima2(ima1.topo());
+ for (unsigned i = 0; i < 3; ++i)
+ ima2(oln::point1d(i)) = 2;
+
+ // Fill a 1-d image using the routine oln::level::fill.
+ oln::image1d<long> ima3(ima1.topo());
+ oln::level::fill(ima3, 3);
+
+
+ // Add the three images.
+ oln::image1d<long> sum(ima1.topo());
+ oln_type_of_(oln::image1d<long>, piter) p(sum.topo());
+ for_all(p)
+ sum(p) = ima1(p) + ima2(p) + ima3(p);
+ // And check the sum.
+ for_all(p)
+ assert(sum(p) == 6);
+}
Index: tests/Makefile.am
--- tests/Makefile.am (revision 603)
+++ tests/Makefile.am (working copy)
@@ -20,6 +20,7 @@
point2d \
grid \
image_entry \
+ image1d \
image2d \
npoints \
\
@@ -34,6 +35,7 @@
point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
+image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
npoints_SOURCES = npoints.cc
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Clean up morphers.
* oln/morpher/identity.hh
(oln::vtypes< morpher::identity<Image> >): Remove (was useless).
(oln/morpher/tags.hh): Move header inclusion...
* oln/morpher/internal/image_extension.hh: ...here
* oln/morpher/add_neighborhood.hh, oln/morpher/add_isubset.hh
(oln/morpher/tags.hh): No longer include it.
* oln/morpher/tags.hh (oln::morpher::tag::add_neighborhood):
Remove (was useless).
(oln::morpher::tag::identity): Adjust documentation.
add_isubset.hh | 1 -
add_neighborhood.hh | 1 -
identity.hh | 11 -----------
internal/image_extension.hh | 1 +
tags.hh | 4 +---
5 files changed, 2 insertions(+), 16 deletions(-)
Index: oln/morpher/identity.hh
--- oln/morpher/identity.hh (revision 602)
+++ oln/morpher/identity.hh (working copy)
@@ -29,7 +29,6 @@
# define OLN_MORPHER_IDENTITY
# include <oln/morpher/internal/image_extension.hh>
-# include <oln/morpher/tags.hh>
namespace oln
@@ -52,16 +51,6 @@
};
- /// New virtual types associated with oln::morpher::identity.
- /// \{
- template <typename Image>
- struct vtypes< morpher::identity<Image> >
- {
- typedef oln::morpher::tag::identity morpher_type;
- };
- /// \}
-
-
namespace morpher
{
/// Identity morpher.
Index: oln/morpher/internal/image_extension.hh
--- oln/morpher/internal/image_extension.hh (revision 602)
+++ oln/morpher/internal/image_extension.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_MORPHER_INTERNAL_IMAGE_EXTENSION
# include <oln/core/image_entry.hh>
+# include <oln/morpher/tags.hh>
namespace oln
Index: oln/morpher/add_neighborhood.hh
--- oln/morpher/add_neighborhood.hh (revision 602)
+++ oln/morpher/add_neighborhood.hh (working copy)
@@ -29,7 +29,6 @@
# define OLN_MORPHER_ADD_NEIGHBORHOOD
# include <oln/morpher/internal/image_extension.hh>
-# include <oln/morpher/tags.hh>
# include <oln/core/gen/topo_add_nbh.hh>
Index: oln/morpher/add_isubset.hh
--- oln/morpher/add_isubset.hh (revision 602)
+++ oln/morpher/add_isubset.hh (working copy)
@@ -29,7 +29,6 @@
# define OLN_MORPHER_ADD_ISUBSET
# include <oln/morpher/internal/image_extension.hh>
-# include <oln/morpher/tags.hh>
# include <oln/core/gen/topo_add_isubset.hh>
# include <oln/core/gen/piter_isubset.hh>
Index: oln/morpher/tags.hh
--- oln/morpher/tags.hh (revision 602)
+++ oln/morpher/tags.hh (working copy)
@@ -35,10 +35,8 @@
{
namespace tag
{
- /// Tag associated to oln::morpher::identity.
+ /// Tag associated to oln::morpher::image_extension.
struct identity;
- /// Tag associated to oln::morpher::add_neighborhood.
- struct add_neighborhood;
} // end of namespace oln::morpher::tag
1
0
03 Oct '06
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Take borders into account in data allocation of image2d.
* oln/core/2d/image2d.hh (image2d(unsigned, unsigned, unsigned)):
Allocate space for the border in the array.
* oln/core/2d/point2d.hh, oln/core/typedefs.hh: Add FIXMEs.
* oln/core/2d/neighb2d.hh, oln/core/2d/dpoint2d.hh,
* oln/core/internal/point_nd.hh: Aesthetic changes.
2d/dpoint2d.hh | 2 --
2d/image2d.hh | 3 ++-
2d/neighb2d.hh | 3 ++-
2d/point2d.hh | 4 +++-
internal/point_nd.hh | 3 ++-
typedefs.hh | 1 +
6 files changed, 10 insertions(+), 6 deletions(-)
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 601)
+++ oln/core/2d/image2d.hh (working copy)
@@ -85,7 +85,8 @@
: topo_(bbox2d(point2d(0, 0),
point2d(nrows-1, ncols-1)),
border),
- data_(new array_t(0, 0, nrows-1, ncols-1))
+ data_(new array_t(0 - border, 0 - border,
+ nrows - 1 + border, ncols - 1 + border))
{
}
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 601)
+++ oln/core/2d/point2d.hh (working copy)
@@ -36,7 +36,9 @@
namespace oln
{
-
+ /* FIXME: Is this the right place for these functions (on types)?
+ In particular, the function on dpoint2d should be near the
+ definition of dpoint2d, not point2d's. */
/// Specializations of functions point and dpoint :
/// \f$(n, coord) \rightarrow type\f$ for \f$n = 2\f$.
/// \{
Index: oln/core/typedefs.hh
--- oln/core/typedefs.hh (revision 601)
+++ oln/core/typedefs.hh (working copy)
@@ -172,6 +172,7 @@
| category::grid. |
`-----------------*/
+ // FIXME: Merge with dim_type?
mlc_decl_typedef(dimvalue_type);
mlc_decl_typedef(coord_type);
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 601)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and Development Laboratory
+// 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
Index: oln/core/2d/dpoint2d.hh
--- oln/core/2d/dpoint2d.hh (revision 601)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -95,8 +95,6 @@
};
-
-
} // end of namespace oln
Index: oln/core/internal/point_nd.hh
--- oln/core/internal/point_nd.hh (revision 601)
+++ oln/core/internal/point_nd.hh (working copy)
@@ -41,7 +41,8 @@
{
- /// Function "point_ : (n, coord) -> point type".
+ /// Function \f$point : (n, coord) \rightarrow point type\f$.
+
template <unsigned n, typename C>
struct point_
{
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add simple tests for point2d and dpoint2d.
* tests/dpoint2d.cc, tests/point2d.cc: New tests.
* tests/image_entry.cc: Fix comments.
* tests/Makefile.am (check_PROGRAMS): Add dpoint2d and point2d.
(dpoint2d_SOURCES, point2d_SOURCES): New.
Makefile.am | 4 ++++
dpoint2d.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++
image_entry.cc | 6 ++----
point2d.cc | 43 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+), 4 deletions(-)
Index: tests/point2d.cc
--- tests/point2d.cc (revision 0)
+++ tests/point2d.cc (revision 0)
@@ -0,0 +1,43 @@
+// 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.
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+// FIXME: Don't include oln/basics2d.hh, which is too big.
+// (Fix.)
+#include <oln/basics2d.hh>
+
+
+int
+main()
+{
+ typedef oln::point2d_<int> point2d;
+ typedef oln:: stc_get_supers(point2d) point2d_super_type;
+ mlc::assert_<
+ mlc_eq( point2d_super_type, oln::internal::point_nd< point2d > )
+ >::check();
+}
Index: tests/image_entry.cc
--- tests/image_entry.cc (revision 600)
+++ tests/image_entry.cc (working copy)
@@ -25,15 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// Test oln::abstract::image_entry.
+/// Test oln::image_entry.
-// FIXME: Check also with a (possibly fake) ntg::int_u<1, B> type, to
-// stress image_typeness.hh. This might be done in another test, of
-// course.
#include <oln/basics2d.hh>
#include <oln/core/image_entry.hh>
+
namespace my
{
// Forward declaration.
Index: tests/dpoint2d.cc
--- tests/dpoint2d.cc (revision 0)
+++ tests/dpoint2d.cc (revision 0)
@@ -0,0 +1,47 @@
+// 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 oln::image_entry.
+
+#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
+// // FIXME: Fix oln/basics2d.hh!
+// #include <oln/core/2d/point2d.hh>
+// namespace oln { template class point2d_<int>; }
+// #include <oln/core/2d/dpoint2d.hh>
+#include <oln/basics2d.hh>
+
+
+int
+main()
+{
+ typedef oln::dpoint2d_<int> dpoint2d;
+ typedef oln:: stc_get_supers(dpoint2d) dpoint2d_super_type;
+ mlc::assert_<
+ mlc_eq( dpoint2d_super_type, oln::internal::dpoint_nd< dpoint2d > )
+ >::check();
+}
Index: tests/Makefile.am
--- tests/Makefile.am (revision 600)
+++ tests/Makefile.am (working copy)
@@ -16,6 +16,8 @@
check_PROGRAMS = \
+ dpoint2d \
+ point2d \
grid \
image_entry \
image2d \
@@ -28,6 +30,8 @@
fill
# Images and auxiliary structures.
+dpoint2d_SOURCES = dpoint2d.cc
+point2d_SOURCES = point2d.cc
grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
image2d_SOURCES = image2d.cc
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Separate tracked_ptr from array2d.
* oln/core/2d/array2d.hh (oln::tracked_ptr): Move...
* oln/core/internal/tracked_ptr.hh: ...here (new file).
* oln/core/2d/image2d.hh (oln::image2d::data_): Adjust type.
(oln::image2d(const topo2d&)): New ctor.
* tests/image2d.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add image2d.
(image2d_SOURCES): New.
oln/core/2d/array2d.hh | 169 ------------------------------
oln/core/2d/image2d.hh | 16 ++
oln/core/internal/tracked_ptr.hh | 213 +++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 2
tests/image2d.cc | 64 +++++++++++
5 files changed, 293 insertions(+), 171 deletions(-)
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 599)
+++ oln/core/2d/array2d.hh (working copy)
@@ -30,181 +30,12 @@
# define OLN_CORE_2D_ARRAY2D_HH
# include <cstdlib>
-# include <set>
# include <mlc/contract.hh>
namespace oln
{
- template <typename T>
- struct tracked_ptr
- {
- typedef tracked_ptr<T> self_t;
- typedef std::set<self_t*> holders_t;
-
- T* ptr_;
- holders_t* holders_;
-
- /// Coercion towards Boolean (for arithmetical tests).
- operator bool() const
- {
- invariant_();
- return ptr_ != 0;
- }
-
- /// Negation (for arithmetical tests).
- bool operator not() const
- {
- invariant_();
- return not bool(*this);
- }
-
- /*! \brief Mimics the behavior of op-> for a pointer in the const case.
- **
- ** \invariant Pointer proxy exists.
- */
- const T*const operator->() const
- {
- invariant_();
- precondition(ptr_ != 0);
- return ptr_;
- }
-
- /*! \brief Mimics the behavior of op-> for a pointer in the mutable case.
- **
- ** \invariant Pointer proxy exists.
- */
- T*const operator->()
- {
- invariant_();
- precondition(ptr_ != 0);
- return ptr_;
- }
-
- /// Ctor.
- tracked_ptr() :
- ptr_(0),
- holders_(0)
- {
- invariant_();
- }
-
- /// Ctor.
- tracked_ptr(T* ptr) :
- ptr_(ptr)
- {
- if (ptr == 0)
- holders_ = 0;
- else
- {
- holders_ = new holders_t;
- holders_->insert(this);
- }
- invariant_();
- }
-
- /// Cpy ctor.
- tracked_ptr(const self_t& rhs) :
- ptr_(rhs.ptr_),
- holders_(rhs.holders_)
- {
- rhs.invariant_();
- if (ptr_ != 0)
- holders_->insert(this);
- invariant_();
- }
-
- /// Assignment.
- self_t& operator=(const self_t& rhs)
- {
- invariant_();
- rhs.invariant_();
- if (&rhs == this or rhs.ptr_ == ptr_)
- // no-op
- return *this;
- clean_();
- ptr_ = rhs.ptr_;
- holders_ = rhs.holders_;
- holders_->insert(this);
- return *this;
- }
-
- /// Assignment.
- self_t& operator=(T* ptr)
- {
- invariant_();
- if (ptr == ptr_)
- // no-op
- return *this;
- clean_();
- ptr_ = ptr;
- if (ptr == 0)
- holders_ = 0;
- else
- {
- holders_ = new holders_t;
- holders_->insert(this);
- }
- return *this;
- }
-
- /// Dtor.
- ~tracked_ptr()
- {
- clean_();
- }
-
- void invariant_() const
- {
- invariant((ptr_ and holders_) or (not ptr_ and not holders_));
- if (ptr_ == 0)
- return;
- invariant(holders_->size() > 0);
- self_t* this_ = const_cast<self_t*>(this);
- invariant(holders_->find(this_) != holders_->end());
- typename holders_t::const_iterator i;
- for (i = holders_->begin(); i != holders_->end(); ++i)
- invariant((*i)->ptr_ == ptr_);
- }
-
- void clean_()
- {
- invariant_();
- if (ptr_ == 0)
- // no-op
- return;
- if (holders_->size() == 1)
- {
- delete ptr_;
- delete holders_;
- }
- else
- holders_->erase(this);
- ptr_ = 0;
- holders_ = 0;
- invariant_();
- }
-
- friend std::ostream& operator<<(std::ostream& ostr, const self_t& tp)
- {
- ostr << "tracked_ptr @ " << (&tp)
- << " { ptr = " << tp.ptr_
- << " / holders = ";
- if (tp.holders_ == 0)
- ostr << "0";
- else
- {
- typename holders_t::const_iterator i;
- for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i)
- ostr << (*i) << ' ';
- }
- ostr << " }";
- return ostr;
- }
- };
-
-
/// General 2D array class.
template <typename value_t, typename coord_t = int>
class array2d
Index: oln/core/internal/tracked_ptr.hh
--- oln/core/internal/tracked_ptr.hh (revision 0)
+++ oln/core/internal/tracked_ptr.hh (revision 0)
@@ -0,0 +1,213 @@
+// 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_INTERNAL_TRACKED_PTR_HH
+# define OLN_CORE_INTERNAL_TRACKED_PTR_HH
+
+# include <set>
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ template <typename T>
+ struct tracked_ptr
+ {
+ typedef tracked_ptr<T> self_t;
+ typedef std::set<self_t*> holders_t;
+
+ T* ptr_;
+ holders_t* holders_;
+
+ /// Coercion towards Boolean (for arithmetical tests).
+ operator bool() const
+ {
+ invariant_();
+ return ptr_ != 0;
+ }
+
+ /// Negation (for arithmetical tests).
+ bool operator not() const
+ {
+ invariant_();
+ return not bool(*this);
+ }
+
+ /*! \brief Mimics the behavior of op-> for a pointer in the const case.
+ **
+ ** \invariant Pointer proxy exists.
+ */
+ const T*const operator->() const
+ {
+ invariant_();
+ precondition(ptr_ != 0);
+ return ptr_;
+ }
+
+ /*! \brief Mimics the behavior of op-> for a pointer in the mutable case.
+ **
+ ** \invariant Pointer proxy exists.
+ */
+ T*const operator->()
+ {
+ invariant_();
+ precondition(ptr_ != 0);
+ return ptr_;
+ }
+
+ /// Ctor.
+ tracked_ptr() :
+ ptr_(0),
+ holders_(0)
+ {
+ invariant_();
+ }
+
+ /// Ctor.
+ tracked_ptr(T* ptr) :
+ ptr_(ptr)
+ {
+ if (ptr == 0)
+ holders_ = 0;
+ else
+ {
+ holders_ = new holders_t;
+ holders_->insert(this);
+ }
+ invariant_();
+ }
+
+ /// Cpy ctor.
+ tracked_ptr(const self_t& rhs) :
+ ptr_(rhs.ptr_),
+ holders_(rhs.holders_)
+ {
+ rhs.invariant_();
+ if (ptr_ != 0)
+ holders_->insert(this);
+ invariant_();
+ }
+
+ /// Assignment.
+ self_t& operator=(const self_t& rhs)
+ {
+ invariant_();
+ rhs.invariant_();
+ if (&rhs == this or rhs.ptr_ == ptr_)
+ // no-op
+ return *this;
+ clean_();
+ ptr_ = rhs.ptr_;
+ holders_ = rhs.holders_;
+ holders_->insert(this);
+ return *this;
+ }
+
+ /// Assignment.
+ self_t& operator=(T* ptr)
+ {
+ invariant_();
+ if (ptr == ptr_)
+ // no-op
+ return *this;
+ clean_();
+ ptr_ = ptr;
+ if (ptr == 0)
+ holders_ = 0;
+ else
+ {
+ holders_ = new holders_t;
+ holders_->insert(this);
+ }
+ return *this;
+ }
+
+ /// Dtor.
+ ~tracked_ptr()
+ {
+ clean_();
+ }
+
+ void invariant_() const
+ {
+ invariant((ptr_ and holders_) or (not ptr_ and not holders_));
+ if (ptr_ == 0)
+ return;
+ invariant(holders_->size() > 0);
+ self_t* this_ = const_cast<self_t*>(this);
+ invariant(holders_->find(this_) != holders_->end());
+ typename holders_t::const_iterator i;
+ for (i = holders_->begin(); i != holders_->end(); ++i)
+ invariant((*i)->ptr_ == ptr_);
+ }
+
+ void clean_()
+ {
+ invariant_();
+ if (ptr_ == 0)
+ // no-op
+ return;
+ if (holders_->size() == 1)
+ {
+ delete ptr_;
+ delete holders_;
+ }
+ else
+ holders_->erase(this);
+ ptr_ = 0;
+ holders_ = 0;
+ invariant_();
+ }
+
+ friend std::ostream& operator<<(std::ostream& ostr, const self_t& tp)
+ {
+ ostr << "tracked_ptr @ " << (&tp)
+ << " { ptr = " << tp.ptr_
+ << " / holders = ";
+ if (tp.holders_ == 0)
+ ostr << "0";
+ else
+ {
+ typename holders_t::const_iterator i;
+ for (i = tp.holders_->begin(); i != tp.holders_->end(); ++i)
+ ostr << (*i) << ' ';
+ }
+ ostr << " }";
+ return ostr;
+ }
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_TRACKED_PTR_HH
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 599)
+++ oln/core/2d/image2d.hh (working copy)
@@ -31,6 +31,7 @@
# include <oln/core/image_entry.hh>
# include <oln/core/2d/array2d.hh>
+# include <oln/core/internal/tracked_ptr.hh>
namespace oln
@@ -44,6 +45,7 @@
template <typename T>
struct vtypes< image2d<T> >
{
+ // FIXME: or `typedef topo2d topo_type;' ?
typedef topo_lbbox_<point2d> topo_type;
typedef grid2d grid_type;
@@ -78,7 +80,7 @@
public:
- /// Ctor.
+ /// Ctor using sizes.
image2d(unsigned nrows, unsigned ncols, unsigned border = 2)
: topo_(bbox2d(point2d(0, 0),
point2d(nrows-1, ncols-1)),
@@ -87,6 +89,16 @@
{
}
+ /// Ctor using an existing topology.
+ image2d(const topo2d& topo)
+ : topo_(topo),
+ data_(new array_t(topo.bbox().pmin().row(),
+ topo.bbox().pmin().col(),
+ topo.bbox().pmax().row(),
+ topo.bbox().pmax().col()))
+ {
+ }
+
const topo2d& impl_topo() const
{
return topo_;
@@ -109,7 +121,7 @@
private:
topo2d topo_;
- tracked_ptr<array_t> data_;
+ internal::tracked_ptr<array_t> data_;
};
Index: tests/image2d.cc
--- tests/image2d.cc (revision 0)
+++ tests/image2d.cc (revision 0)
@@ -0,0 +1,64 @@
+// 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 oln::image2d.
+
+#include <cassert>
+// FIXME: We should not include oln/basics2d.hh, but
+// oln/core/2d/image2d.hh (and oln/core/2d/neigh2d.hh ?).
+#include <oln/basics2d.hh>
+#include <oln/level/fill.hh>
+
+int
+main()
+{
+ // Fill a 2-d image using its iterator.
+ oln::image2d<char> ima1(3, 3);
+ oln_type_of_(oln::image2d<char>, piter) p1(ima1.topo());
+ for_all(p1)
+ ima1(p1) = 1;
+
+ // Fill a 2-d image using a classic loop.
+ oln::image2d<int> ima2(ima1.topo());
+ for (unsigned i = 0; i < 3; ++i)
+ for (unsigned j = 0; j < 3; ++j)
+ ima2(oln::point2d(i, j)) = 2;
+
+ // Fill a 2-d image using the routine oln::level::fill.
+ oln::image2d<long> ima3(ima1.topo());
+ oln::level::fill(ima3, 3);
+
+
+ // Add the three images.
+ oln::image2d<long> sum(ima1.topo());
+ oln_type_of_(oln::image2d<long>, piter) p(sum.topo());
+ for_all(p)
+ sum(p) = ima1(p) + ima2(p) + ima3(p);
+ // And check the sum.
+ for_all(p)
+ assert(sum(p) == 6);
+}
Index: tests/Makefile.am
--- tests/Makefile.am (revision 599)
+++ tests/Makefile.am (working copy)
@@ -18,6 +18,7 @@
check_PROGRAMS = \
grid \
image_entry \
+ image2d \
npoints \
\
identity_morpher \
@@ -29,6 +30,7 @@
# Images and auxiliary structures.
grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
+image2d_SOURCES = image2d.cc
npoints_SOURCES = npoints.cc
# Morphers.
1
0
Oops.
Index: ChangeLog
===================================================================
--- ChangeLog (revision 598)
+++ ChangeLog (revision 599)
@@ -13,11 +13,6 @@
(oln::dpoint2d_): Use stc_get_supers to set the base class.
(oln::dpoint2d_::super_t): Use stc_get_super to define it.
-2006-10-02 Roland Levillain <roland(a)lrde.epita.fr>
-
- * oln/core/2d/array2d.hh (oln::tracked_ptr): Move...
- * oln/core/internal/tracked_ptr.hh: ...here (new file).
-
2006-10-02 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add isubset image morpher and subsequent tools.
1
0