https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add ''theoretical bounding box'' for point set types.
* TODO: Augment.
* oln/core/concept/point_set.hh (theoretical_bbox): New.
(impl_theoretical_bbox): New.
(infty): New in Box.
* oln/core/gen/pset_compare.hh (op_subset_): Fix.
* oln/core/gen/infty_pset.hh (b_): Remove.
(infty_pset, impl_bbox): Update.
(operator<<): New.
* oln/core/gen/torus_pset.hh (impl_theoretical_bbox): New.
(operator<<): Separate decl and def.
* oln/core/gen/op.hh: Cosmetic change.
* oln/core/internal/op_image_through_fv2v.hh
(value, rvalue, lvalue): Fix.
* oln/core/internal/dpoint_base.hh (impl_op_mod_equal_): Fix.
* oln/core/internal/category_of.hh: New commentary.
TODO | 2 +
oln/core/concept/point_set.hh | 35 +++++++++++++++++++++++++++++
oln/core/gen/infty_pset.hh | 23 ++++++++++---------
oln/core/gen/op.hh | 5 +++-
oln/core/gen/pset_compare.hh | 21 +++++++++++------
oln/core/gen/torus_pset.hh | 22 ++++++++++++++----
oln/core/internal/category_of.hh | 2 -
oln/core/internal/dpoint_base.hh | 4 +++
oln/core/internal/op_image_through_fv2v.hh | 12 +++++----
9 files changed, 98 insertions(+), 28 deletions(-)
Index: TODO
--- TODO (revision 941)
+++ TODO (working copy)
@@ -2,6 +2,8 @@
* Rough list
+fast iterators
+
value types (including gray level types, label types, (bool, T) type,
color types, etc.)
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 941)
+++ oln/core/concept/point_set.hh (working copy)
@@ -57,6 +57,9 @@
bool has(const point& p) const;
const box& bbox() const;
+ const box& theoretical_bbox() const;
+ const box& impl_theoretical_bbox() const; // FIXME: default?
+
protected:
Point_Set();
@@ -78,6 +81,8 @@
const point& pmax() const;
point& pmax();
+ static const Exact& infty();
+
protected:
Box();
@@ -114,6 +119,21 @@
return exact(this)->impl_bbox();
}
+
+ template <typename Exact>
+ const typename Point_Set<Exact>::box&
+ Point_Set<Exact>::theoretical_bbox() const
+ {
+ return exact(this)->impl_theoretical_bbox();
+ }
+
+ template <typename Exact>
+ const typename Point_Set<Exact>::box&
+ Point_Set<Exact>::impl_theoretical_bbox() const
+ {
+ return this->bbox();
+ }
+
template <typename Exact>
Point_Set<Exact>::Point_Set()
{
@@ -164,6 +184,21 @@
return exact(this)->impl_pmax();
}
+ template <typename Exact>
+ const Exact&
+ Box<Exact>::infty()
+ {
+ static bool flower = false;
+ static Exact the_;
+ if (not flower)
+ {
+ flower = true;
+ the_.pmin().set_all( std::numeric_limits< oln_coord(point) >::min() );
+ the_.pmax().set_all( std::numeric_limits< oln_coord(point) >::max() );
+ }
+ return the_;
+ }
+
template <typename Ps>
std::ostream& operator<<(std::ostream& ostr, const
Point_Set<Ps>& pts)
{
Index: oln/core/gen/pset_compare.hh
--- oln/core/gen/pset_compare.hh (revision 941)
+++ oln/core/gen/pset_compare.hh (working copy)
@@ -128,22 +128,29 @@
bool op_subset_(const Point_Set<L>& lhs, const Point_Set<R>&
rhs)
{
// first quick test
- if (lhs.npoints() > rhs.npoints())
+ if (lhs.npoints() > rhs.npoints()) // FIXME: May be erroneous for types like
plist...
return false;
// second quick test
- if (not intersects(lhs.bbox(), rhs.bbox()))
+ if (not intersects(lhs.theoretical_bbox(), rhs.theoretical_bbox()))
return false;
// all points of lhs are IN rhs?
- oln_piter(R) p_rhs(rhs);
- p_rhs.start();
oln_piter(L) p_lhs(lhs);
for_all(p_lhs)
{
- while (p_rhs.is_valid() and p_rhs.to_point() != p_lhs.to_point())
- p_rhs.next();
- if (not p_rhs.is_valid())
+ if (not rhs.has(p_lhs))
return false;
}
+ // the following code was erroneous w.r.t. given types of psets:
+ // oln_piter(R) p_rhs(rhs);
+ // p_rhs.start();
+ // oln_piter(L) p_lhs(lhs);
+ // for_all(p_lhs)
+ // {
+ // while (p_rhs.is_valid() and p_rhs.to_point() != p_lhs.to_point())
+ // p_rhs.next();
+ // if (not p_rhs.is_valid())
+ // return false;
+ // }
return true;
}
Index: oln/core/gen/infty_pset.hh
--- oln/core/gen/infty_pset.hh (revision 941)
+++ oln/core/gen/infty_pset.hh (working copy)
@@ -29,6 +29,8 @@
# define OLN_CORE_GEN_INFTY_PSET_HH
# include <limits>
+# include <ostream>
+
# include <oln/core/concept/grid.hh>
# include <oln/core/internal/f_grid_to_box.hh>
# include <oln/core/internal/point_set_base.hh>
@@ -79,26 +81,21 @@
infty_pset();
unsigned impl_npoints() const;
- bool impl_has(const point& p) const;
+ bool impl_has(const point&) const;
const box& impl_bbox() const;
- protected:
- box b_;
-
}; // end of class oln::infty_pset<G>.
+ template <typename G>
+ std::ostream& operator<<(std::ostream& ostr, const
infty_pset<G>& ps);
+
# ifndef OLN_INCLUDE_ONLY
template <typename G>
infty_pset<G>::infty_pset()
{
- typedef oln_coord(point) C;
- point minus_infty, plus_infty;
- minus_infty.set_all( std::numeric_limits<C>::min() );
- plus_infty. set_all( std::numeric_limits<C>::max() );
- this->b_ = init(from(minus_infty), to(plus_infty));
}
template <typename G>
@@ -119,7 +116,13 @@
const typename infty_pset<G>::box&
infty_pset<G>::impl_bbox() const
{
- return this->b_;
+ return box::infty();
+ }
+
+ template <typename G>
+ std::ostream& operator<<(std::ostream& ostr, const
infty_pset<G>&)
+ {
+ return ostr << "infty pset";
}
#endif // ! OLN_INCLUDE_ONLY
Index: oln/core/gen/torus_pset.hh
--- oln/core/gen/torus_pset.hh (revision 941)
+++ oln/core/gen/torus_pset.hh (working copy)
@@ -28,6 +28,8 @@
#ifndef OLN_CORE_GEN_TORUS_PSET_HH
# define OLN_CORE_GEN_TORUS_PSET_HH
+# include <ostream>
+
# include <oln/core/internal/pset_adaptor.hh>
# include <oln/core/concept/dpoint.hh>
@@ -77,6 +79,8 @@
point relocate(const point& p) const;
bool impl_has(const point& p) const;
+ const box& impl_theoretical_bbox() const;
+
private:
point pmin_;
dpoint size_;
@@ -85,10 +89,7 @@
template <typename Ps>
- std::ostream& operator<<(std::ostream& ostr, const
torus_pset<Ps>& ps)
- {
- return ostr << "torus " << ps.adapted_();
- }
+ std::ostream& operator<<(std::ostream& ostr, const
torus_pset<Ps>& ps);
# ifndef OLN_INCLUDE_ONLY
@@ -133,6 +134,19 @@
return this->ps_.has(relocate(p));
}
+ template <typename Ps>
+ const typename current::box&
+ current::impl_theoretical_bbox() const
+ {
+ return box::infty();
+ }
+
+ template <typename Ps>
+ std::ostream& operator<<(std::ostream& ostr, const
torus_pset<Ps>& ps)
+ {
+ return ostr << "torus " << ps.adapted_();
+ }
+
# endif // ! OLN_INCLUDE_ONLY
# undef super
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 941)
+++ oln/core/gen/op.hh (working copy)
@@ -91,6 +91,9 @@
+// FIXME: Split into different files so that the client can explicitly include
+// what is really needed...
+
# define oln_decl_op_extended_by(Lconcept, Rconcept) oln_decl_op_( extended_by,
Lconcept, +, Rconcept)
# define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_( such_as,
Lconcept, |, Rconcept)
# define oln_decl_op_restricted_to(Lconcept, Rconcept) oln_decl_op_( restricted_to,
Lconcept, |, Rconcept)
@@ -179,7 +182,7 @@
postcondition(op_ok);
}
-# endif
+# endif // ! OLN_INCLUDE_ONLY
# undef super
Index: oln/core/internal/op_image_through_fv2v.hh
--- oln/core/internal/op_image_through_fv2v.hh (revision 941)
+++ oln/core/internal/op_image_through_fv2v.hh (working copy)
@@ -64,14 +64,16 @@
typedef I delegatee;
typedef internal::pair<I,F> data;
- typedef oln_result(F) rvalue;
- typedef mlc_basic(rvalue) value;
+ typedef oln_result(F) F_result__;
+
+ typedef mlc_basic(F_result__) value;
+ typedef value rvalue;
typedef typename mlc::if_< mlc::and_list_< mlc_is_not_const(I),
stc_is_found_type(I, lvalue),
- mlc_is_reference(oln_result(F)),
- mlc_is_not_const(oln_result(F)) >,
- stc_find_type(I, lvalue),
+ mlc_is_reference(F_result__),
+ mlc_is_not_const(F_result__) >,
+ F_result__,
stc::not_delegated >::ret lvalue;
typedef op_<oln_plain(I), through, F> plain;
Index: oln/core/internal/dpoint_base.hh
--- oln/core/internal/dpoint_base.hh (revision 941)
+++ oln/core/internal/dpoint_base.hh (working copy)
@@ -155,7 +155,11 @@
Exact& dpoint_base_<Exact>::impl_op_mod_equal_(const Exact& rhs)
{
for (unsigned i = 0; i < n; ++i)
+ {
v_[i] %= rhs.v_[i];
+ if (v_[i] < 0)
+ v_[i] += rhs.v_[i];
+ }
return exact(*this);
}
Index: oln/core/internal/category_of.hh
--- oln/core/internal/category_of.hh (revision 941)
+++ oln/core/internal/category_of.hh (working copy)
@@ -55,7 +55,7 @@
};
template <>
- struct set_category_of_< bool >
+ struct set_category_of_< bool > // FIXME: Move into oln/core/value/*.
{
typedef stc::is< Boolean > ret;
};