Commit 826ea0ea authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Introducing mini-olena (milena).

	* milena: New.
	* milena/test: New.
	* milena/test/main.cc: New.
	* milena/convert: New.
	* milena/morpho: New.
	* milena/debug: New.
	* milena/debug/println.hh: New.
	* milena/level: New.
	* milena/level/fill.hh: New.
	* milena/core: New.
	* milena/core/dpoint2d.hh: New.
	* milena/core/window2d.cc: New.
	* milena/core/macros.hh: New.
	* milena/core/dpoints_qiter.hh: New.
	* milena/core/window2d_qiter.cc: New.
	* milena/core/box.hh: New.
	* milena/core/point.hh: New.
	* milena/core/rectangle2d.hh: New.
	* milena/core/box_piter.hh: New.
	* milena/core/dpoint.hh: New.
	* milena/core/concept: New.
	* milena/core/concept/image.hh: New.
	* milena/core/concept/genpoint.hh: New.
	* milena/core/concept/piter.hh: New.
	* milena/core/concept/point_set.hh: New.
	* milena/core/concept/psite.hh: New.
	* milena/core/concept/object.hh: New.
	* milena/core/concept/window.hh: New.
	* milena/core/concept/box.hh: New.
	* milena/core/concept/iterator.hh: New.
	* milena/core/concept/point.hh: New.
	* milena/core/concept/dpoint.hh: New.
	* milena/core/window2d.hh: New.
	* milena/core/ops.hh: New.
	* milena/core/exact.hh: New.
	* milena/core/window.hh: New.
	* milena/core/image2d.hh: New.
	* milena/core/vec.hh: New.
	* milena/core/internal: New.
	* milena/core/internal/coord_impl.hh: New.
	* milena/core/internal/image_adaptor.hh: New.
	* milena/core/internal/image_base.hh: New.
	* milena/core/internal/set_of.hh: New.
	* milena/core/box2d.hh: New.
	* milena/core/point2d.hh: New.
	* milena/core/safe_image.hh: New.
	* milena/mlc: New.
	* milena/mlc/equal.hh: New.
	* milena/mlc/same_point.hh: New.
	* milena/value: New.
	* milena/README: New.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@983 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 66f89282
2007-06-28 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Introducing mini-olena (milena).
* milena: New.
* milena/test: New.
* milena/test/main.cc: New.
* milena/convert: New.
* milena/morpho: New.
* milena/debug: New.
* milena/debug/println.hh: New.
* milena/level: New.
* milena/level/fill.hh: New.
* milena/core: New.
* milena/core/dpoint2d.hh: New.
* milena/core/window2d.cc: New.
* milena/core/macros.hh: New.
* milena/core/dpoints_qiter.hh: New.
* milena/core/window2d_qiter.cc: New.
* milena/core/box.hh: New.
* milena/core/point.hh: New.
* milena/core/rectangle2d.hh: New.
* milena/core/box_piter.hh: New.
* milena/core/dpoint.hh: New.
* milena/core/concept: New.
* milena/core/concept/image.hh: New.
* milena/core/concept/genpoint.hh: New.
* milena/core/concept/piter.hh: New.
* milena/core/concept/point_set.hh: New.
* milena/core/concept/psite.hh: New.
* milena/core/concept/object.hh: New.
* milena/core/concept/window.hh: New.
* milena/core/concept/box.hh: New.
* milena/core/concept/iterator.hh: New.
* milena/core/concept/point.hh: New.
* milena/core/concept/dpoint.hh: New.
* milena/core/window2d.hh: New.
* milena/core/ops.hh: New.
* milena/core/exact.hh: New.
* milena/core/window.hh: New.
* milena/core/image2d.hh: New.
* milena/core/vec.hh: New.
* milena/core/internal: New.
* milena/core/internal/coord_impl.hh: New.
* milena/core/internal/image_adaptor.hh: New.
* milena/core/internal/image_base.hh: New.
* milena/core/internal/set_of.hh: New.
* milena/core/box2d.hh: New.
* milena/core/point2d.hh: New.
* milena/core/safe_image.hh: New.
* milena/mlc: New.
* milena/mlc/equal.hh: New.
* milena/mlc/same_point.hh: New.
* milena/value: New.
* milena/README: New.
2007-02-02 Roland Levillain <roland@lrde.epita.fr>
Configure new Makefiles of static/samples.
......
Object
|
| GenPoint
| |
+ -- Psite
| |
| + -- Point
|
+ -- Iterator
| |
| | GenPoint
| | |
| + -- Piter
#ifndef MLN_CORE_BOX_HH
# define MLN_CORE_BOX_HH
# include <core/concept/box.hh>
# include <core/point.hh>
namespace mln
{
// fwd decl
template <typename P> struct box_fwd_piter_;
template <typename P> struct box_bkd_piter_;
template <typename P>
struct box_ : public Box< box_<P> >
{
typedef P psite;
typedef P point;
typedef box_fwd_piter_<P> fwd_piter;
typedef box_bkd_piter_<P> bkd_piter;
typedef fwd_piter piter;
P pmin() const { return pmin_; }
P& pmin() { return pmin_; }
P pmax() const { return pmax_; }
P& pmax() { return pmax_; }
box_()
{
}
box_(const point& pmin, const point& pmax)
: pmin_(pmin),
pmax_(pmax)
{
}
bool has(const P& p) const
{
for (unsigned i = 0; i < P::dim; ++i)
if (p[i] < pmin_[i] or p[i] > pmax_[i])
return false;
return true;
}
protected:
P pmin_, pmax_;
};
template <typename P>
std::ostream& operator<<(std::ostream& ostr, const box_<P>& b)
{
return ostr << "[" << b.pmin() << ".." << b.pmax() << ']';
}
} // end of namespace mln
# include <core/box_piter.hh>
#endif // ! MLN_CORE_BOX_HH
#ifndef MLN_CORE_BOX2D_HH
# define MLN_CORE_BOX2D_HH
# include <core/box.hh>
# include <core/point2d.hh>
namespace mln
{
typedef box_<point2d> box2d;
box2d mk_box2d(unsigned nrows, unsigned ncols)
{
box2d tmp(mk_point2d(0, 0),
mk_point2d(nrows - 1, ncols - 1));
return tmp;
}
box2d mk_box2d(int min_row, int max_row,
int min_col, int max_col)
{
box2d tmp(mk_point2d(min_row, min_col),
mk_point2d(max_row, max_col));
return tmp;
}
} // end of namespace mln
#endif // ! MLN_CORE_BOX2D_HH
#ifndef MLN_CORE_BOX_PITER_HH
# define MLN_CORE_BOX_PITER_HH
# include <core/concept/piter.hh>
# include <core/concept/box.hh>
namespace mln
{
template <typename P>
class box_fwd_piter_ : public Piter< box_fwd_piter_<P> >
{
public:
enum { dim = P::dim };
typedef P psite;
typedef P point;
typedef oln_coord(P) coord;
typedef oln_dpoint(P) dpoint;
box_fwd_piter_(const box_<P>& b)
: b_(b)
{
nop_ = b_.pmax();
++nop_[0];
invalidate();
}
operator P() const
{
return p_;
}
const P* pointer() const
{
return & p_;
}
coord operator[](unsigned i) const
{
assert(i < dim);
return p_[i];
}
bool is_valid() const
{
return p_ != nop_;
}
void invalidate()
{
p_ = nop_;
}
void start()
{
p_ = b_.pmin();
}
void next_()
{
for (int i = dim - 1; i >= 0; --i)
if (p_[i] == b_.pmax()[i])
p_[i] = b_.pmin()[i];
else
{
++p_[i];
break;
}
if (p_ == b_.pmin())
p_ = nop_;
}
private:
const box_<P>& b_;
P p_, nop_;
};
template <typename P>
class box_bkd_piter_ : public Piter< box_bkd_piter_<P> >
{
public:
enum { dim = P::dim };
typedef P psite;
typedef P point;
typedef oln_coord(P) coord;
box_bkd_piter_(const box_<P>& b)
: b_(b)
{
nop_ = b_.pmin();
--nop_[0];
invalidate();
}
operator P() const
{
return p_;
}
const P* pointer() const
{
return & p_;
}
coord operator[](unsigned i) const
{
assert(i < dim);
return p_[i];
}
bool is_valid() const
{
return p_ != nop_;
}
void invalidate()
{
p_ = nop_;
}
void start()
{
p_ = b_.pmax();
}
void next_()
{
for (int i = dim - 1; i >= 0; --i)
if (p_[i] == b_.pmin()[i])
p_[i] = b_.pmax()[i];
else
{
--p_[i];
break;
}
if (p_ == b_.pmax())
p_ = nop_;
}
private:
const box_<P>& b_;
P p_, nop_;
};
} // end of namespace mln
#endif // ! MLN_CORE_BOX_PITER_HH
#ifndef MLN_CORE_CONCEPT_BOX_HH
# define MLN_CORE_CONCEPT_BOX_HH
# include <core/concept/point_set.hh>
namespace mln
{
template <typename E>
struct Box : public Point_Set<E>
{
/*
const point& pmin() const;
const point& pmax() const;
*/
const E& bbox() const; // final
protected:
Box();
};
# ifndef MLN_INCLUDE_ONLY
template <typename E>
const E& Box<E>::bbox() const
{
return exact(*this);
}
template <typename E>
Box<E>::Box()
{
typedef oln_point(E) point;
point (E::*m1)() const = & E::pmin;
m1 = 0;
point (E::*m2)() const = & E::pmax;
m2 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
#endif // ! MLN_CORE_CONCEPT_BOX_HH
#ifndef MLN_CORE_CONCEPT_DPOINT_HH
# define MLN_CORE_CONCEPT_DPOINT_HH
# include <core/concept/object.hh>
namespace mln
{
template <typename E>
struct Dpoint : public Object<E>
{
/*
typedef point;
typedef coord;
enum { dim };
coord operator[](unsigned i) const;
*/
protected:
Dpoint();
};
template <typename D>
D operator-(const Dpoint<D>& dp);
template <typename Dl, typename Dr>
bool operator==(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs);
template <typename Dl, typename Dr>
bool operator<(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs);
template <typename D>
std::ostream& operator<<(std::ostream& ostr, const Dpoint<D>& dp);
# ifndef MLN_INCLUDE_ONLY
template <typename E>
Dpoint<E>::Dpoint()
{
typedef oln_point(E) point;
typedef oln_coord(E) coord;
enum { dim = E::dim };
coord (E::*m)(unsigned i) const = & E::operator[];
m = 0;
}
template <typename D>
D operator-(const Dpoint<D>& dp)
{
D tmp;
for (unsigned i = 0; i < D::dim; ++i)
tmp[i] = - exact(dp)[i];
return tmp;
}
template <typename Dl, typename Dr>
bool operator==(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs)
{
for (unsigned i = 0; i < Dl::dim; ++i)
if (exact(lhs)[i] != exact(rhs)[i])
return false;
return true;
}
template <typename Dl, typename Dr>
bool operator<(const Dpoint<Dl>& lhs, const Dpoint<Dr>& rhs)
{
for (unsigned i = 0; i < Dl::dim; ++i)
{
if (exact(lhs)[i] == exact(rhs)[i])
continue;
return exact(lhs)[i] < exact(rhs)[i];
}
return false;
}
template <typename D>
std::ostream& operator<<(std::ostream& ostr, const Dpoint<D>& dp)
{
ostr << '(';
for (unsigned i = 0; i < D::dim; ++i)
{
ostr << exact(dp)[i]
<< (i == D::dim - 1 ? ')' : ',');
}
return ostr;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
#endif // ! MLN_CORE_CONCEPT_DPOINT_HH
#ifndef MLN_CORE_CONCEPT_GENPOINT_HH
# define MLN_CORE_CONCEPT_GENPOINT_HH
# include <core/concept/object.hh>
# include <core/macros.hh>
# include <mlc/equal.hh>
# include <mlc/same_point.hh>
namespace mln
{
template <typename E>
struct GenPoint // stand-alone class!
{
/*
typedef point;
typedef dpoint;
typedef coord;
typedef topo; // FIXME
either Point
or operator point() const;
const point* pointer() const;
coord operator[](unsigned i) const;
*/
protected:
GenPoint();
};
template <typename Pl, typename Pr>
bool operator==(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs);
template <typename Pl, typename Pr>
bool operator<(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs);
template <typename Pl, typename Pr>
oln_dpoint(Pl)
operator-(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs);
template <typename P>
oln_point(P)
operator+(const GenPoint<P>& lhs, const oln_dpoint(P)& rhs);
template <typename P>
std::ostream& operator<<(std::ostream& ostr, const GenPoint<P>& p);
# ifndef MLN_INCLUDE_ONLY
template <typename E>
GenPoint<E>::GenPoint()
{
typedef oln_point(E) point;
typedef oln_dpoint(E) dpoint;
typedef oln_coord(E) coord;
const point* (E::*m1)() const = & E::pointer;
m1 = 0;
coord (E::*m2)(unsigned i) const = & E::operator[];
m2 = 0;
}
template <typename Pl, typename Pr>
bool operator==(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs)
{
const Pl& lhs_ = force_exact<Pl>(lhs);
const Pr& rhs_ = force_exact<Pr>(rhs);
mlc::same_point<Pl, Pr>::check();
for (unsigned i = 0; i < Pl::dim; ++i)
if (lhs_[i] != rhs_[i])
return false;
return true;
}
template <typename Pl, typename Pr>
bool operator<(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs)
{
mlc::same_point<Pl, Pr>::check();
const Pl& lhs_ = force_exact<Pl>(lhs);
const Pr& rhs_ = force_exact<Pr>(rhs);
for (unsigned i = 0; i < Pl::dim; ++i)
{
if (lhs_[i] == rhs_[i])
continue;
return lhs_[i] < rhs_[i];
}
return false;
}
template <typename Pl, typename Pr>
oln_dpoint(Pl)
operator-(const GenPoint<Pl>& lhs, const GenPoint<Pr>& rhs)
{
const Pl& lhs_ = force_exact<Pl>(lhs);
const Pr& rhs_ = force_exact<Pr>(rhs);
oln_dpoint(Pl) tmp;
for (unsigned i = 0; i < Pl::dim; ++i)
tmp[i] = lhs_[i] - rhs_[i];
return tmp;
}
template <typename P>
oln_point(P)
operator+(const GenPoint<P>& lhs, const oln_dpoint(P)& rhs)
{
const P& lhs_ = force_exact<P>(lhs);
oln_point(P) tmp;
for (unsigned i = 0; i < P::dim; ++i)
tmp[i] = lhs_[i] + rhs[i];
return tmp;
}
template <typename P>
std::ostream& operator<<(std::ostream& ostr, const GenPoint<P>& p)
{
const P& p_ = force_exact<P>(p);
ostr << '(';
for (unsigned i = 0; i < P::dim; ++i)
{
ostr << p_[i]
<< (i == P::dim - 1 ? ')' : ',');
}
return ostr;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
#endif // ! MLN_CORE_CONCEPT_GENPOINT_HH
#ifndef MLN_CORE_CONCEPT_IMAGE_HH
# define MLN_CORE_CONCEPT_IMAGE_HH
# include <core/concept/point_set.hh>