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

2006-10-09 Thierry GERAUD <theo@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.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@608 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 1f303fb1
2006-10-09 Thierry GERAUD <theo@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.
2006-10-05 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Decouple iterators from image topology; update neighborhood tools
......
......@@ -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>
......
......@@ -44,6 +44,43 @@ namespace oln
/// Ctor.
array2d(coord_t imin, coord_t jmin,
coord_t imax, coord_t jmax);
/// Ctor.
array2d(coord_t ilen, coord_t jlen);
/// Dtor.
~array2d();
value_t operator()(coord_t i, coord_t j) const;
value_t& operator()(coord_t i, coord_t j);
bool has(coord_t i, coord_t j) const;
size_t memsize() const;
protected:
coord_t imin_, jmin_, imax_, jmax_;
coord_t ilen_, jlen_;
value_t* buffer_;
value_t** array_;
private:
void allocate_();
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),
......@@ -56,8 +93,9 @@ namespace oln
allocate_();
}
template <typename value_t, typename coord_t>
/// Ctor.
array2d(coord_t ilen, coord_t jlen) :
array2d<value_t, coord_t>::array2d(coord_t ilen, coord_t jlen) :
imin_(0),
jmin_(0),
ilen_(ilen),
......@@ -69,32 +107,37 @@ namespace oln
allocate_();
}
template <typename value_t, typename coord_t>
/// Dtor.
~array2d()
array2d<value_t, coord_t>::~array2d()
{
deallocate_();
}
value_t operator()(coord_t i, coord_t j) const
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];
}
value_t& operator()(coord_t i, coord_t 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];
}
bool has(coord_t i, coord_t j) const
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_;
}
size_t memsize() const
template <typename value_t, typename coord_t>
size_t array2d<value_t, coord_t>::memsize() const
{
return
// buffer_
......@@ -104,16 +147,8 @@ namespace oln
size_t(ilen_) * sizeof(value_t*);
}
protected:
coord_t imin_, jmin_, imax_, jmax_;
coord_t ilen_, jlen_;
value_t* buffer_;
value_t** array_;
private:
void allocate_()
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_)];
......@@ -126,7 +161,8 @@ namespace oln
array_ -= imin_;
}
void deallocate_()
template <typename value_t, typename coord_t>
void array2d<value_t, coord_t>::deallocate_()
{
precondition(buffer_ != 0 and array_ != 0);
delete[] buffer_;
......@@ -135,7 +171,8 @@ namespace oln
delete[] array_;
array_ = 0; // safety
}
};
# endif
} // end of namespace oln
......
......@@ -64,36 +64,62 @@ namespace oln
{
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,C>& v);
/// Ctor.
dpoint2d_(C row, C col);
C row() const;
C& row();
C col() const;
C& col();
};
# ifndef OLN_INCLUDE_ONLY
template <typename C>
dpoint2d_<C>::dpoint2d_()
{
}
/// Ctor.
dpoint2d_(const xtd::vec<2,coord_t>& v)
template <typename C>
dpoint2d_<C>::dpoint2d_(const xtd::vec<2,C>& v)
: super_t(v)
{
}
/// Ctor.
dpoint2d_(coord_t row, coord_t col)
template <typename C>
dpoint2d_<C>::dpoint2d_(C row, C col)
: super_t(xtd::mk_vec(row, col))
{
}
coord_t row() const { return v_[0]; }
coord_t& row() { return v_[0]; }
template <typename C>
C dpoint2d_<C>::row() const { return v_[0]; }
coord_t col() const { return v_[1]; }
coord_t& col() { return v_[1]; }
};
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
......
......@@ -78,7 +78,30 @@ namespace oln
public:
/// Ctor using sizes.
image2d(unsigned nrows, unsigned ncols, unsigned border = 2)
image2d(unsigned nrows, unsigned ncols, unsigned border = 2);
/// Ctor using an existing topology.
image2d(const topo2d& topo);
const topo2d& impl_topo() const;
T impl_op_read(const point2d& p) const;
T& impl_op_readwrite(const point2d& p);
private:
topo2d topo_;
internal::tracked_ptr<array_t> data_;
};
# 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),
......@@ -88,7 +111,8 @@ namespace oln
}
/// Ctor using an existing topology.
image2d(const topo2d& topo)
template <typename T>
image2d<T>::image2d(const topo2d& topo)
: topo_(topo),
data_(new array_t(topo.bbox().pmin().row(),
topo.bbox().pmin().col(),
......@@ -97,31 +121,29 @@ namespace oln
{
}
const topo2d& impl_topo() const
template <typename T>
const topo2d& image2d<T>::impl_topo() const
{
return topo_;
}
T impl_op_read(const point2d& p) const
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());
}
T& impl_op_readwrite(const point2d& p)
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());
}
private:
topo2d topo_;
internal::tracked_ptr<array_t> data_;
};
# endif
} // end of namespace oln
......
......@@ -40,69 +40,69 @@ namespace oln
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)
{
neighb2d the_;
the_
.add(dpoint2d(0, 1))
.add(dpoint2d(1, 0));
flower = false;
}
return the_;
}
neighb2d mk_c8()
{
static bool flower = true;
static neighb2d the_;
if (flower)
{
neighb2d the_;
the_
.add(dpoint2d(0, 1))
.add(dpoint2d(1,-1))
.add(dpoint2d(1, 0))
.add(dpoint2d(1, 1));
flower = false;
}
return the_;
}
neighb2d mk_c2_row()
{
static bool flower = true;
static neighb2d the_;
if (flower)
{
neighb2d the_;
the_
.add(dpoint2d(0, 1));
flower = false;
}
return the_;
}
neighb2d mk_c2_col()
{
static bool flower = true;
static neighb2d the_;
if (flower)
{
neighb2d the_;
the_
.add(dpoint2d(1, 0));
flower = false;
}
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
......
......@@ -72,36 +72,71 @@ namespace oln
{
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_(C row, C col);
/// Ctor.
point2d_(const xtd::vec<2,C>& v);
///Dtor.
~point2d_()
{
}
/// Ctor.
point2d_(coord_t row, coord_t col)
C row() const;
C& row();
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))
{
}
/// Ctor.
point2d_(const xtd::vec<2,coord_t>& v)
template <typename C>
point2d_<C>::point2d_(const xtd::vec<2,C>& v)
: super_t(v)
{
}
coord_t row() const { return v_[0]; }
coord_t& row() { return v_[0]; }
// template <typename C>
// point2d_<C>::~point2d_()
// {
// }
coord_t col() const { return v_[1]; }
coord_t& col() { return v_[1]; }
};
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
......
......@@ -45,30 +45,54 @@ namespace oln
{
public:
void print(std::ostream& ostr) const
void print(std::ostream& ostr) const;
const E& impl_bbox() const;
~bbox()
{
}
protected:
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);
}
friend
template <typename E>
std::ostream& operator<<(std::ostream& ostr, const abstract::bbox<E>& bb)
{
bb.print(ostr);
return ostr;
}
const E& impl_bbox() const
template <typename E>
const E& bbox<E>::impl_bbox() const
{
return this->exact();
}