https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix ambiguity in border property.
* mln/trait/image/props.hh (some): New in 'border'.
* mln/border/get.hh: Fix ambiguity.
* tests/core_clone.cc: Update.
* tests/box2d.cc: Augment.
* tests/border_get.cc: Augment.
* TODO: Clean.
* mln/trait/images.hh (image_): Handle const case.
* mln/core/box.hh: New ctors with lens.
* mln/metal/is_a.hh (is_a): New spe for const.
* mln/convert/to_tiles.hh: Rename vec as v_ima.
TODO | 42 +++++++++++++++++-------------------------
mln/border/get.hh | 6 +++---
mln/convert/to_tiles.hh | 22 +++++++++++-----------
mln/core/box.hh | 36 ++++++++++++++++++++++++++++++++++++
mln/metal/is_a.hh | 4 ++++
mln/trait/image/props.hh | 7 ++++---
mln/trait/images.hh | 9 ++++++++-
tests/border_get.cc | 26 ++++++++++++--------------
tests/box2d.cc | 3 +++
tests/core_clone.cc | 2 +-
10 files changed, 99 insertions(+), 58 deletions(-)
Index: tests/core_clone.cc
--- tests/core_clone.cc (revision 1312)
+++ tests/core_clone.cc (working copy)
@@ -48,7 +48,7 @@
{
box2d b = make::box2d(2,2);
- std::cout << border::get( clone(ima | b) ) << std::endl;
+ std::cout << border::find( clone(ima | b) ) << std::endl;
debug::println(ima | b);
debug::println(clone(ima | b));
Index: tests/box2d.cc
--- tests/box2d.cc (revision 1312)
+++ tests/box2d.cc (working copy)
@@ -40,4 +40,7 @@
box2d b = make::box2d(2, 3);
mln_assertion(b.nrows() = 2);
+
+ box2d b_(2, 3);
+ mln_assertion(b = b_);
}
Index: tests/border_get.cc
--- tests/border_get.cc (revision 1312)
+++ tests/border_get.cc (working copy)
@@ -39,9 +39,9 @@
#include <mln/literal/origin.hh>
-struct my_box2d : mln::Function_p2b< my_box2d >
+struct f_box2d_t : mln::Function_p2b< f_box2d_t >
{
- my_box2d(const mln::box2d& b)
+ f_box2d_t(const mln::box2d& b)
: b_(b)
{
}
@@ -61,24 +61,22 @@
typedef image2d<int> I;
box2d b(literal::origin, point2d(1,1));
+ f_box2d_t f_b(b);
+
I ima(3,3, 51);
-// mln_assertion(border::get(ima) = 51);
-// mln_assertion( ima.has(point2d(2,2)) = true );
+ mln_assertion(border::get(ima) = 51);
+ mln_assertion( ima.has(point2d(2,2)) = true );
-// sub_image<I, box2d> sub(ima, b);
-// mln_assertion( sub.has (point2d(2,2)) = false &&
-// sub.owns_(point2d(2,2)) = false );
-// mln_assertion(border::get(sub) = 0);
+ sub_image<I, box2d> sub(ima, b);
+ mln_assertion( sub.has (point2d(2,2)) = false &&
+ sub.owns_(point2d(2,2)) = false );
+ mln_assertion(border::get(sub) = 0);
- my_box2d f_b(b);
- image_if<I, my_box2d> imaif(ima, f_b);
+ image_if<I, f_box2d_t> imaif(ima, f_b);
mln_assertion( imaif.has (point2d(2,2)) = false &&
imaif.owns_(point2d(2,2)) = true );
mln_assertion(border::get(imaif) = 51);
-
-// std::cout << std::endl
-// << "image_if< image2d >: ";
-// mln::trait::image::print< image_if<I, fun::p2b::chess_t> >(std::cout);
+ mln_assertion(border::get( (ima | b) | f_b ) = 0);
}
Index: TODO
--- TODO (revision 1312)
+++ TODO (working copy)
@@ -1,47 +1,39 @@
-*- outline -*-
+* memo
-* mathieu
+reprise de /work2/theo_temp/SVG_TEGUCIGALPA/prestations/swt/src
-** accu
-*** héritage
-toutes les classes d'accu dérivent de base_ ; Cf. accu/median.hh
-virer l'op de convertion dans median_alt.hh
-ajouter le test de présence de l'op de convertion dans Accumulator
-m-a-j de la doc
-est-ce les tests tournent ?
-*** value -> argument
-m-a-j
-tests ?
+* URGENT
+categories for Function_*
+fun * Built_In
+fun * Scalar
-* guillaume
-** chamfer
+* this week
-Cf. vieilles versions
-algo avec front
+** Guillaume
+...
-* simon
+** Matthieu
-** lines
+...
-ajouter win::line<Mesh, dir>
-hline2d et vline2d deviennent des aliases
-retoucher les routines avec {h,v}line en argument
+** Simon
+h_mat
+...
+** Theo
-* theo
+value::other (for use in labeling)
+...
-hiérarchie de concepts sous Value
-maj trait solver
-virer is_fast -> changer le meta-plug
-virer core/trait
Index: mln/trait/image/props.hh
--- mln/trait/image/props.hh (revision 1312)
+++ mln/trait/image/props.hh (working copy)
@@ -67,7 +67,7 @@
// typedef undef support; // irregular, aligned < regular
// // global
- // typedef undef border; // none, stored, computed
+ // typedef undef border; // none, { stored, computed } < some
// typedef undef data; // raw < linear < stored, computed
// typedef undef io; // read_only < read, write_only < write,
read_write < both read'n write
// typedef undef speed; // slow, fast, or fastest
@@ -166,8 +166,9 @@
{
struct any {};
struct none : any { std::string name() const { return "border::none"; }
};
- struct stored : any { std::string name() const { return "border::stored"; }
};
- struct computed : any { std::string name() const { return "border::computed";
} };
+ struct some : any { std::string name() const { return "border::some"; }
};
+ struct stored : some { std::string name() const { return "border::stored"; }
};
+ struct computed : some { std::string name() const { return "border::computed";
} };
};
struct io
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 1312)
+++ mln/trait/images.hh (working copy)
@@ -124,7 +124,7 @@
typedef undef support; // irregular, aligned < regular
// global
- typedef undef border; // none, stored, computed
+ typedef undef border; // none, { stored, computed } < some
typedef undef data; // raw < linear < stored, computed
typedef undef io; // read_only < read, write_only < write, read_write
< both read'n write
typedef undef speed; // slow, fast, or fastest
@@ -137,6 +137,13 @@
};
+ template <typename I>
+ struct image_<const I> : image_<I>
+ {
+ // FIXME: TODO: io cannot contain "write"...
+ };
+
+
template <typename T, typename I>
struct default_image_ : undefined_image_<I>
{
Index: mln/core/box.hh
--- mln/core/box.hh (revision 1312)
+++ mln/core/box.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/core/concept/box.hh>
# include <mln/core/internal/box_impl.hh>
# include <mln/core/point.hh>
+# include <mln/literal/origin.hh>
namespace mln
@@ -54,6 +55,9 @@
struct box_ : public Box< box_<P> >,
public internal::box_impl_< P::dim, mln_coord(P), box_<P> >
{
+ /// Dimension.
+ enum { dim = P::dim };
+
/// Mesh associated type.
typedef mln_mesh(P) mesh;
@@ -90,6 +94,13 @@
/// Constructor of a box going from \p pmin to \p pmax.
box_(const point& pmin, const point& pmax);
+ /// \{ Constructors with different numbers of arguments
+ /// (sizes) w.r.t. the dimension.
+ explicit box_(mln_coord(P) ninds);
+ box_(mln_coord(P) nrows, mln_coord(P) ncols);
+ box_(mln_coord(P) nslis, mln_coord(P) nrows, mln_coord(P) ncols);
+ /// \}
+
/*! \brief Test if \p p belongs to the box.
*
* \param[in] p A point site.
@@ -154,6 +165,31 @@
: pmin_(pmin),
pmax_(pmax)
{
+
+ }
+
+ template <typename P>
+ box_<P>::box_(mln_coord(P) ninds)
+ {
+ metal::bool_<(dim = 1)>::check();
+ pmin_ = literal::origin;
+ pmax_ = P(ninds - 1);
+ }
+
+ template <typename P>
+ box_<P>::box_(mln_coord(P) nrows, mln_coord(P) ncols)
+ {
+ metal::bool_<(dim = 2)>::check();
+ pmin_ = literal::origin;
+ pmax_ = P(nrows - 1, ncols - 1);
+ }
+
+ template <typename P>
+ box_<P>::box_(mln_coord(P) nslis, mln_coord(P) nrows, mln_coord(P) ncols)
+ {
+ metal::bool_<(dim = 3)>::check();
+ pmin_ = literal::origin;
+ pmax_ = P(nslis - 1, nrows - 1, ncols - 1);
}
template <typename P>
Index: mln/metal/is_a.hh
--- mln/metal/is_a.hh (revision 1312)
+++ mln/metal/is_a.hh (working copy)
@@ -81,6 +81,10 @@
sizeof( internal::yes_ ) )>
{};
+ template <typename T, template <class> class U>
+ struct is_a< const T, U > : is_a< T, U >::eval
+ {};
+
} // end of namespace mln::metal
Index: mln/border/get.hh
--- mln/border/get.hh (revision 1312)
+++ mln/border/get.hh (working copy)
@@ -57,14 +57,14 @@
{
template <typename I>
- unsigned get_(trait::image::border::any, trait::image::category::primary,
+ unsigned get_(trait::image::border::some, trait::image::category::primary,
const I& ima)
{
return ima.border();
}
template <typename I>
- unsigned get_(trait::image::border::any, trait::image::category::morpher,
+ unsigned get_(trait::image::border::some, trait::image::category::morpher,
const I& ima)
{
return border::get( *ima.delegatee_() );
@@ -73,7 +73,7 @@
template <typename I>
unsigned get_(trait::image::border::none, trait::image::category::any,
- const I& ima)
+ const I&)
{
return 0;
}
Index: mln/convert/to_tiles.hh
--- mln/convert/to_tiles.hh (revision 1312)
+++ mln/convert/to_tiles.hh (working copy)
@@ -47,22 +47,22 @@
/// FIXME : Run only for image2d
/// Convert a vector of image2d into a tiled image with ratio.
template <typename I>
- I to_tiles (std::vector<I>& vec, float ratio);
+ I to_tiles(std::vector<I>& v_ima, float ratio);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
I
- to_tiles (std::vector<I>& vec, float ratio)
+ to_tiles(std::vector<I>& v_ima, float ratio)
{
- /// Test if vec is not empty.
- mln_precondition(!vec.empty ());
+ // Test if v_ima is not empty.
+ mln_precondition(! v_ima.empty());
- unsigned size = vec.size ();
- unsigned nrows = geom::nrows(vec[0]);
- unsigned ncols = geom::ncols(vec[0]);
+ unsigned size = v_ima.size();
+ unsigned nrows = geom::nrows(v_ima[0]);
+ unsigned ncols = geom::ncols(v_ima[0]);
- /// Compute output size.
+ // Compute output size.
int size_c = (int) ceil(sqrt(size * ratio));
int size_r = (int) ceil(sqrt(size / ratio));
@@ -71,14 +71,14 @@
for (unsigned i = 0; i < size; ++i)
{
/// Check if current image has good dimension.
- mln_precondition(geom::nrows(vec[i]) = nrows);
- mln_precondition(geom::ncols(vec[i]) = ncols);
+ mln_precondition(geom::nrows(v_ima[i]) = nrows);
+ mln_precondition(geom::ncols(v_ima[i]) = ncols);
/// Compute the delta point of translation.
dpoint2d dp = make::dpoint2d(i / size_c * nrows, i % size_c * ncols);
/// Convert current image in translate image with its delta point.
- translate_image<I> tr_ima (vec[i], dp);
+ translate_image<I> tr_ima(v_ima[i], dp);
/// Paste translated image into output.
level::paste (tr_ima, output);