URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-25 Guillaume Duhamel <guillaume.duhamel(a)lrde.epita.fr>
Add draw mesh in sandbox.
* draw_mesh.hh: New.
* graph.hh,
* main.cc,
* mesh_p.hh,
* mesh_psite.hh: Update.
---
draw_mesh.hh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
graph.hh | 2 +-
main.cc | 17 ++++++++++++++---
mesh_p.hh | 23 +++++++----------------
mesh_psite.hh | 4 ----
5 files changed, 70 insertions(+), 24 deletions(-)
Index: trunk/milena/sandbox/duhamel/mesh_psite.hh
===================================================================
--- trunk/milena/sandbox/duhamel/mesh_psite.hh (revision 1176)
+++ trunk/milena/sandbox/duhamel/mesh_psite.hh (revision 1177)
@@ -5,9 +5,6 @@
namespace mln
{
-
- namespace util
- {
template<typename P>
class Mesh_psite
{
@@ -19,6 +16,5 @@
unsigned i;
Mesh_p<P>* m_ptr;
};
- } // end of util
} // end of mln
#endif // MLN_MESH_PSITE_HH
Index: trunk/milena/sandbox/duhamel/graph.hh
===================================================================
--- trunk/milena/sandbox/duhamel/graph.hh (revision 1176)
+++ trunk/milena/sandbox/duhamel/graph.hh (revision 1177)
@@ -83,7 +83,7 @@
void coherence () const;
void print_debug () const;
- private:
+ public:
unsigned nb_node_;
unsigned nb_link_;
std::vector<struct s_node<N>*> nodes_;
Index: trunk/milena/sandbox/duhamel/draw_mesh.hh
===================================================================
--- trunk/milena/sandbox/duhamel/draw_mesh.hh (revision 0)
+++ trunk/milena/sandbox/duhamel/draw_mesh.hh (revision 1177)
@@ -0,0 +1,48 @@
+#ifndef MLN_DRAW_MESH_HH
+# define MLN_DRAW_MESH_HH
+
+# include <mln/pw/image.hh>
+#include <mln/core/image2d_b.hh>
+# include <mln/core/point2d.hh>
+//# include <mln/pw/cst.hh>
+# include <mln/level/fill.hh>
+//# include <mln/metal/is_a.hh>
+# include "mesh_p.hh"
+
+namespace mln
+{
+ namespace draw
+ {
+ template <typename I>
+ void
+ bresenham(Image<I>& ima,
+ point2d p1,
+ point2d p2,
+ mln_value(I) link_v)
+ {
+
+ }
+
+ template <typename I, typename P>
+ void
+ mesh(Image<I>& ima, const Mesh_p<P>& m,
+ mln_value(I) node_v,
+ mln_value(I) link_v)
+ {
+ level::fill(ima, 0);
+
+ for (unsigned i = 0; i < m.gr_.nb_link_; ++i)
+ bresenham (exact(ima),
+ m.loc_[m.gr_.links_[i]->node1],
+ m.loc_[m.gr_.links_[i]->node2],
+ link_v);
+
+ for (unsigned i = 0; i < m.gr_.nb_node_; ++i)
+ exact(ima)(m.loc_[i]) = node_v;
+ }
+
+ } // end of draw
+
+} // end of mln
+
+#endif // MLN_MESH_PSITE_HH
Index: trunk/milena/sandbox/duhamel/main.cc
===================================================================
--- trunk/milena/sandbox/duhamel/main.cc (revision 1176)
+++ trunk/milena/sandbox/duhamel/main.cc (revision 1177)
@@ -1,6 +1,10 @@
+#include <mln/core/image2d_b.hh>
+#include <mln/core/point2d.hh>
+#include <mln/debug/println.hh>
#include "graph.hh"
#include "mesh_p.hh"
#include "mesh_psite.hh"
+#include "draw_mesh.hh"
using namespace mln;
@@ -21,10 +25,17 @@
g.add_edge (0, 3);
g.coherence ();
- g.print_debug ();
-
- // image2d_b<int> out (2, 2, 1);
+ // g.print_debug ();
+ std::vector<point2d> v;
+ v.push_back (make::point2d (1,2));
+ v.push_back (make::point2d (14,6));
+ v.push_back (make::point2d (1,15));
+ v.push_back (make::point2d (16,19));
+ image2d_b<int> ima (20, 20, 1);
+ Mesh_p<point2d> m(g, v);
+ draw::mesh (ima, m, 42, 1);
+ debug::println (ima);
}
Index: trunk/milena/sandbox/duhamel/mesh_p.hh
===================================================================
--- trunk/milena/sandbox/duhamel/mesh_p.hh (revision 1176)
+++ trunk/milena/sandbox/duhamel/mesh_p.hh (revision 1177)
@@ -6,34 +6,25 @@
namespace mln
{
- namespace util
- {
-
template<typename P>
class Mesh_p
{
public:
- Mesh_p ()
- {
- }
- Mesh_p (Graph<void>& gr)
- : gr_ (gr)
+ Mesh_p () {}
+
+ Mesh_p (util::Graph<void>& gr,
+ std::vector<P>& loc)
+ : gr_ (gr),
+ loc_ (loc)
{
}
~Mesh_p () {}
- std::vector<P>& loc_get ()
- {
- return loc_;
- }
-
- private:
- Graph<void> gr_;
+ util::Graph<void> gr_;
std::vector<P> loc_;
// Mesh_psite<P> psite;
};
- } // end of util
} // end of mln
#endif // MLN_MESH_P_HH