Matthieu Garrigues <garrigues(a)lrde.epita.fr> writes:
URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-26 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add iterator for branches.
* mln/util/branch_iter.hh: To iterate on branch.
This file seems new. If this is the case, please state it, and write
``New.'' or ``New file.''. ChangeLogs explain *what* are the changes,
and optionaly why *afterwards*.
See also
http://www.gnu.org/prep/standards/standards.html#Change-Logs
for more information.
``There's no need to describe the full purpose of the changes or how
they work together. If you think that a change calls for
explanation, you're probably right. Please do explain it-—but please
put the explanation in comments in the code, where people will see
it whenever they see the code. For example, “New function” is
enough for the change log when you add a function, because there
should be a comment before the function definition to explain what
it does.''
* mln/util/tree.hh: Add branch class, fix tree.
* mln/util/tree_to_image.hh: Fix.
This comment is irrelevant: the sole changes introduced in this file
are purely of aesthetic order!
* mln/value/concept/built_in.hh: Add a forward
declaration.
* sandbox/garrigues/fllt.hh: Update.
``Update'' is a description no more useful than ``Fix''.
* tests/branch_iter.cc: Test for branch_iter.
If this test is new, please say it in this entry.
Index: trunk/milena/tests/branch_iter.cc
===================================================================
[...]
+/*!
+ * \file tests/branch_iter.cc
+ *
+ * \brief test of mln::util::branch_iter
There's no need to indent here -- however, I think you are free to
indent if you want.
[...]
+
g->add_child(4211)->add_child(51)->add_child(52)->add_child(53)->add_child(54)->add_child(55);
Too long! (But I already commented this on a previous message.)
[...]
+ for_all(p)
+ {
+ std::cout << "parcour : " << util::node<int>(p).elt()
<< std::endl;
+ }
You can get rid of the braces here.
Index: trunk/milena/mln/value/concept/built_in.hh
===================================================================
--- trunk/milena/mln/value/concept/built_in.hh (revision 1392)
+++ trunk/milena/mln/value/concept/built_in.hh (revision 1393)
@@ -42,6 +42,7 @@
namespace value
{
+ template <typename B> struct Built_In;
Why capitals?
[...]
Index: trunk/milena/mln/util/tree_to_image.hh
===================================================================
--- trunk/milena/mln/util/tree_to_image.hh (revision 1392)
+++ trunk/milena/mln/util/tree_to_image.hh (revision 1393)
@@ -65,9 +65,8 @@
mln_piter(set_p<point2d>) p(node->elt_.points);
for_all(p)
- {
output(p) = node->elt_.value;
- }
+
typename std::vector< util::node<T>* >::const_iterator it =
node->child_.begin();
Line too long.
[...]
Index: trunk/milena/mln/util/tree.hh
===================================================================
--- trunk/milena/mln/util/tree.hh (revision 1392)
+++ trunk/milena/mln/util/tree.hh (revision 1393)
@@ -45,15 +45,34 @@
namespace util
{
+ /// Fwd declarations.
+ template <typename T> class node;
+ template <typename T> class tree;
+ template <typename T> class branch;
+
template <typename T>
- struct node
+ class node
{
+ public:
+
+ /// \{ Constructors
node();
- node(T& elt);
+ node(T elt);
+ /// \}
This is wrong. Grouping works like this in Doxygen:
/// Constructors
/// \{
node();
node(T& elt);
node(T elt);
/// \}
+ /// \{ Acccess to the element.
+ T& elt();
+ const T& elt() const;
+ /// \}
Likewise here.
+
+ /// Access to the children
In English, sentences usually end with a period (`.'), even if they
have no verb.
+ const std::vector< node<T>* >&
children() const;
+ std::vector< node<T>* >& children();
- T& content();
- const T& content() const;
- node<T>* add_child(T& elt);
+ /// Access to the parent node.
+ const node<T>* parent() const;
+
+ node<T>* add_child(T elt);
void set_parent(node<T>* parent);
node<T>* get_parent();
void print_rec(int n) const;
@@ -61,14 +80,17 @@
int search_rec(node<T>** res, T& elt);
node<T>* search(T& elt);
+ private:
+ //FIXME tree<T>& tree_;
Missing space and colon:
// FIXME: tree<T>& tree_;
[...]
@@ -77,9 +99,26 @@
void add_tree_up (T& elt);
void add_tree_down (T& elt);
+ private:
node<T>* root_;
};
+
+ template <typename T>
+ class branch
+ {
+ public:
+ branch(tree<T>& tree, node<T>& apex);
Are the const's missing on purpose?
[...]
Index: trunk/milena/mln/util/branch_iter.hh
===================================================================
[...]
+ template <typename T>
+ void
+ branch_iter<T>::start()
+ {
+ s_.push(iter_pair(branch_.apex().children().begin(),
+ branch_.apex().children().end()));
+ n_ = &branch_.apex();
+
+ //n_ = *(s_.top().first);
+ //s_.top().first++;
+ }
Dead code.
+ template <typename T>
+ void
+ branch_iter<T>::next()
+ {
+ if (s_.size() == 0)
+ invalidate();
+ else
+ {
+ if (s_.top().first == s_.top().second)
+ //if (*(s_.top().first) == 0)
Dead code.
[...]
Index: trunk/milena/sandbox/garrigues/fllt.hh
===================================================================
--- trunk/milena/sandbox/garrigues/fllt.hh (revision 1392)
+++ trunk/milena/sandbox/garrigues/fllt.hh (revision 1393)
[...]
@@ -281,7 +281,7 @@
// and which are the holes. Keep one pixel of each holes.
// WARNING : We trust labeling::level to label the exterior border with 1.
- current_region->content().holes.insert(a_point_of(tmp | pw::value(tmp) ==
pw::cst(n)));
+ current_region->elt().holes.insert(a_point_of(tmp | pw::value(tmp) ==
pw::cst(n)));
// FIXME : [optimisation] Remove from N border of holes???.
// Recompute gn <- min u(x) x belongs to A
@@ -469,7 +469,7 @@
// debug::println(regions);
- //debug::println(ima | regions(make:defined reference to
`mln::fllt::lower<mln::value::int_u<8u>
>::inc':point2d(-4,-1))->content().points);
+ //debug::println(ima | regions(make:defined reference to
`mln::fllt::lower<mln::value::int_u<8u>
>::inc':point2d(-4,-1))->elt().points);
Dead code + long lines.
[...]
@@ -530,10 +530,38 @@
static const neighb2d& reg_nbh() { return c8(); }
};
+
+// template <>
+// void find_shape_of_holes(fllt_node(P, V)* lower,
+// fllt_node(P, V)* upper)
+// {
+// }
Dead code.
[...]
+ // In order to merge the trees, we only have
to find for each shape S
+ // with a hole H in it whether one of its children has a hole H´
+ // containing H. If it is the case, we do nothing. Otherwise, we
+ // put the shape of the hole H (and all its descendants) as child of
+ // the shape .
s/child/children/
No space before a period.