Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
October 2008
- 14 participants
- 373 discussions
* mln/topo/internal/complex_relative_iterator_base.hh
(topo::internal::complex_relative_iterator_base)
(topo::internal::forward_complex_relative_iterator_base)
(topo::internal::backward_complex_relative_iterator_base):
Add a template parameter C, for the type of the center face, which
might be different from F, the type of the iterated faces.
(topo::internal::complex_relative_iterator_base::center_type):
New typedef.
Use it as type of...
(topo::internal::complex_relative_iterator_base::c_):
...this member.
(topo::internal::complex_relative_iterator_base::center_at):
Adjust.
* mln/topo/internal/complex_iterator_base.hh:
Adjust documentation.
* mln/topo/adj_lower_face_iter.hh,
* mln/topo/adj_higher_face_iter.hh,
* mln/topo/adj_lower_dim_connected_n_face_iter.hh,
* mln/topo/adj_higher_dim_connected_n_face_iter.hh,
* mln/topo/center_only_iter.hh,
* mln/topo/internal/complex_relative_iterator_sequence:
Adjust.
Pass algebraic_face<D> as parameter F to super class, and face<D>
as as parameter C.
* mln/topo/adj_m_face_iter.hh: Likewise.
(adj_m_face_iterator<D>::update_adj_faces__): Have the
algorithm take the sign (orientation) of the face into account.
* mln/topo/adj_lower_higher_face_iter.hh: Remove a useless header
inclusion.
---
milena/ChangeLog | 34 +++++
.../topo/adj_higher_dim_connected_n_face_iter.hh | 18 ++-
milena/mln/topo/adj_higher_face_iter.hh | 6 +-
.../topo/adj_lower_dim_connected_n_face_iter.hh | 14 ++-
milena/mln/topo/adj_lower_face_iter.hh | 6 +-
milena/mln/topo/adj_lower_higher_face_iter.hh | 2 -
milena/mln/topo/adj_m_face_iter.hh | 49 +++++--
milena/mln/topo/center_only_iter.hh | 4 +-
milena/mln/topo/internal/complex_iterator_base.hh | 2 +-
.../internal/complex_relative_iterator_base.hh | 150 ++++++++++----------
.../internal/complex_relative_iterator_sequence.hh | 6 +-
11 files changed, 187 insertions(+), 104 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e7adf55..e32143d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,39 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Convert iterators on complexes to algebraic faces.
+
+ * mln/topo/internal/complex_relative_iterator_base.hh
+ (topo::internal::complex_relative_iterator_base)
+ (topo::internal::forward_complex_relative_iterator_base)
+ (topo::internal::backward_complex_relative_iterator_base):
+ Add a template parameter C, for the type of the center face, which
+ might be different from F, the type of the iterated faces.
+ (topo::internal::complex_relative_iterator_base::center_type):
+ New typedef.
+ Use it as type of...
+ (topo::internal::complex_relative_iterator_base::c_):
+ ...this member.
+ (topo::internal::complex_relative_iterator_base::center_at):
+ Adjust.
+ * mln/topo/internal/complex_iterator_base.hh:
+ Adjust documentation.
+ * mln/topo/adj_lower_face_iter.hh,
+ * mln/topo/adj_higher_face_iter.hh,
+ * mln/topo/adj_lower_dim_connected_n_face_iter.hh,
+ * mln/topo/adj_higher_dim_connected_n_face_iter.hh,
+ * mln/topo/center_only_iter.hh,
+ * mln/topo/internal/complex_relative_iterator_sequence:
+ Adjust.
+ Pass algebraic_face<D> as parameter F to super class, and face<D>
+ as as parameter C.
+ * mln/topo/adj_m_face_iter.hh: Likewise.
+ (adj_m_face_iterator<D>::update_adj_faces__): Have the
+ algorithm take the sign (orientation) of the face into account.
+ * mln/topo/adj_lower_higher_face_iter.hh: Remove a useless header
+ inclusion.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Convert mln::topo::complex to algebraic faces.
* mln/topo/complex.hh
diff --git a/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh b/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
index be619cb..921575e 100644
--- a/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
+++ b/milena/mln/topo/adj_higher_dim_connected_n_face_iter.hh
@@ -37,7 +37,7 @@
# include <set>
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -65,12 +65,14 @@ namespace mln
template <unsigned D>
class adj_higher_dim_connected_n_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_dim_connected_n_face_fwd_iter<D> >,
- private internal::adj_higher_dim_connected_n_face_iterator<D>
+ private internal::adj_higher_dim_connected_n_face_iterator<D>
{
private:
typedef adj_higher_dim_connected_n_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -100,12 +102,14 @@ namespace mln
template <unsigned D>
class adj_higher_dim_connected_n_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_dim_connected_n_face_bkd_iter<D> >,
- private internal::adj_higher_dim_connected_n_face_iterator<D>
+ private internal::adj_higher_dim_connected_n_face_iterator<D>
{
private:
typedef adj_higher_dim_connected_n_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -138,7 +142,7 @@ namespace mln
/// The actual implementation of the computation of the set of
/// faces adjacent to the reference face.
void update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces);
+ std::vector< algebraic_face<D> >& adj_faces);
};
} // end of namespace mln::topo::internal
@@ -225,7 +229,7 @@ namespace mln
inline
void
adj_higher_dim_connected_n_face_iterator<D>::update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces)
+ std::vector< algebraic_face<D> >& adj_faces)
{
// Reset the result container.
adj_faces.clear();
@@ -235,8 +239,8 @@ namespace mln
added to the pool of adjacent faces. We use an std::set
because the lookup is cheaper (O(log(n)) vs O(n) for a
vector, where n is the size of the containers. */
- std::set< face<D> > faces_set;
- typedef std::vector< face<D> > faces_t;
+ std::set< algebraic_face<D> > faces_set;
+ typedef std::vector< algebraic_face<D> > faces_t;
// The set of (n+1)-faces adjacent to CENTER.
faces_t shared_higher_faces = center.higher_dim_adj_faces();
diff --git a/milena/mln/topo/adj_higher_face_iter.hh b/milena/mln/topo/adj_higher_face_iter.hh
index cfea904..e51d678 100644
--- a/milena/mln/topo/adj_higher_face_iter.hh
+++ b/milena/mln/topo/adj_higher_face_iter.hh
@@ -33,7 +33,7 @@
/// adjacent (n+1)-faces of a (reference) n-face in a complex.
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -57,10 +57,12 @@ namespace mln
template <unsigned D>
class adj_higher_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_face_fwd_iter<D> >
{
typedef adj_higher_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -87,10 +89,12 @@ namespace mln
template <unsigned D>
class adj_higher_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_higher_face_bkd_iter<D> >
{
typedef adj_higher_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
diff --git a/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh b/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
index 181d439..9d35482 100644
--- a/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
+++ b/milena/mln/topo/adj_lower_dim_connected_n_face_iter.hh
@@ -37,7 +37,7 @@
# include <set>
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -65,12 +65,14 @@ namespace mln
template <unsigned D>
class adj_lower_dim_connected_n_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_dim_connected_n_face_fwd_iter<D> >,
private internal::adj_lower_dim_connected_n_face_iterator<D>
{
private:
typedef adj_lower_dim_connected_n_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -100,12 +102,14 @@ namespace mln
template <unsigned D>
class adj_lower_dim_connected_n_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_dim_connected_n_face_bkd_iter<D> >,
private internal::adj_lower_dim_connected_n_face_iterator<D>
{
private:
typedef adj_lower_dim_connected_n_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -138,7 +142,7 @@ namespace mln
/// The actual implementation of the computation of the set of
/// faces adjacent to the reference face.
void update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces);
+ std::vector< algebraic_face<D> >& adj_faces);
};
} // end of namespace mln::topo::internal
@@ -225,7 +229,7 @@ namespace mln
inline
void
adj_lower_dim_connected_n_face_iterator<D>::update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces)
+ std::vector< algebraic_face<D> >& adj_faces)
{
// Reset the result container.
adj_faces.clear();
@@ -235,8 +239,8 @@ namespace mln
added to the pool of adjacent faces. We use an std::set
because the lookup is cheaper (O(log(n)) vs O(n) for a
vector, where n is the size of the containers. */
- std::set< face<D> > faces_set;
- typedef std::vector< face<D> > faces_t;
+ std::set< algebraic_face<D> > faces_set;
+ typedef std::vector< algebraic_face<D> > faces_t;
// The set of (n-1)-faces adjacent to CENTER.
faces_t shared_lower_faces = center.lower_dim_adj_faces();
diff --git a/milena/mln/topo/adj_lower_face_iter.hh b/milena/mln/topo/adj_lower_face_iter.hh
index e8f5f3f..88cc8f2 100644
--- a/milena/mln/topo/adj_lower_face_iter.hh
+++ b/milena/mln/topo/adj_lower_face_iter.hh
@@ -33,7 +33,7 @@
/// adjacent (n-1)-faces of a (reference) n-face in a complex.
# include <mln/topo/internal/complex_relative_iterator_base.hh>
-# include <mln/topo/face.hh>
+# include <mln/topo/algebraic_face.hh>
namespace mln
@@ -57,11 +57,13 @@ namespace mln
template <unsigned D>
class adj_lower_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_face_fwd_iter<D> >
{
private:
typedef adj_lower_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -88,11 +90,13 @@ namespace mln
template <unsigned D>
class adj_lower_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_lower_face_bkd_iter<D> >
{
private:
typedef adj_lower_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
diff --git a/milena/mln/topo/adj_lower_higher_face_iter.hh b/milena/mln/topo/adj_lower_higher_face_iter.hh
index e28b64a..dcd11c2 100644
--- a/milena/mln/topo/adj_lower_higher_face_iter.hh
+++ b/milena/mln/topo/adj_lower_higher_face_iter.hh
@@ -37,8 +37,6 @@
# include <mln/topo/adj_lower_face_iter.hh>
# include <mln/topo/adj_higher_face_iter.hh>
-# include <mln/topo/face.hh>
-
namespace mln
{
diff --git a/milena/mln/topo/adj_m_face_iter.hh b/milena/mln/topo/adj_m_face_iter.hh
index f54a341..d9ed9e5 100644
--- a/milena/mln/topo/adj_m_face_iter.hh
+++ b/milena/mln/topo/adj_m_face_iter.hh
@@ -70,12 +70,14 @@ namespace mln
template <unsigned D>
class adj_m_face_fwd_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_m_face_fwd_iter<D> >,
public internal::adj_m_face_iterator<D>
{
private:
typedef adj_m_face_fwd_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
typedef internal::adj_m_face_iterator<D> impl_;
@@ -115,12 +117,14 @@ namespace mln
template <unsigned D>
class adj_m_face_bkd_iter
: public internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
adj_m_face_bkd_iter<D> >,
public internal::adj_m_face_iterator<D>
{
private:
typedef adj_m_face_bkd_iter<D> self_;
typedef internal::backward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
typedef internal::adj_m_face_iterator<D> impl_;
@@ -168,7 +172,7 @@ namespace mln
/// The actual implementation of the computation of the set of
/// faces adjacent to the reference face.
void update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces);
+ std::vector< algebraic_face<D> >& adj_faces);
/// The dimension of the iterated faces.
unsigned m_;
@@ -278,22 +282,23 @@ namespace mln
inline
void
adj_m_face_iterator<D>::update_adj_faces__(const face<D>& center,
- std::vector< face<D> >& adj_faces)
+ std::vector< algebraic_face<D> >& adj_faces)
{
adj_faces.clear();
if (center.n() == m_)
return;
- typedef std::vector < topo::face<D> > faces_t;
- typedef std::set < topo::face<D> > faces_set_t;
+ typedef std::vector < topo::algebraic_face<D> > faces_t;
+ typedef std::set < topo::algebraic_face<D> > faces_set_t;
/* FIXME: p_faces is redundant; we could use adj_faces
directly. */
/* The adjacent p-faces being built; initialized with CENTER,
and filled with q-faces at each step, until q reaches
m_. */
- faces_t p_faces(1, center);
+ faces_t p_faces(1,
+ make_algebraic_face(center, true));
// The set of faces being built.
/* FIXME: This pattern is recurring in Milena---using an
std::set (or any fast associative container) to improve
@@ -314,14 +319,34 @@ namespace mln
faces_t q_faces = g->n() < m_ ?
g->higher_dim_adj_faces() :
g->lower_dim_adj_faces();
- // Don't insert a face twice.
- for (typename faces_t::const_iterator h = q_faces.begin();
+ /* Traverse the higher- or lower-dimension adjacent
+ faces of G in the natural order if G's sign is
+ positive, or in the reverse order if G's sign is
+ negative. */
+ /* FIXME: Factor; the code if the two branches is the
+ same, except for the iteration order. */
+ if (g->sign())
+ {
+ for (typename faces_t::const_iterator h = q_faces.begin();
h != q_faces.end(); ++h)
- if (work_faces_set.find(*h) == work_faces_set.end())
- {
- work_faces.push_back(*h);
- work_faces_set.insert(*h);
- }
+ // Don't insert a face twice.
+ if (work_faces_set.find(*h) == work_faces_set.end())
+ {
+ work_faces.push_back(*h);
+ work_faces_set.insert(*h);
+ }
+ }
+ else
+ {
+ for (typename faces_t::const_reverse_iterator h =
+ q_faces.rbegin(); h != q_faces.rend(); ++h)
+ // Don't insert a face twice.
+ if (work_faces_set.find(*h) == work_faces_set.end())
+ {
+ work_faces.push_back(*h);
+ work_faces_set.insert(*h);
+ }
+ }
}
work_faces.swap(p_faces);
work_faces.clear();
diff --git a/milena/mln/topo/center_only_iter.hh b/milena/mln/topo/center_only_iter.hh
index d55ffca..c2d2a6e 100644
--- a/milena/mln/topo/center_only_iter.hh
+++ b/milena/mln/topo/center_only_iter.hh
@@ -74,11 +74,13 @@ namespace mln
template <unsigned D>
class center_only_iter
: public internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
center_only_iter<D> >
{
private:
typedef center_only_iter<D> self_;
typedef internal::forward_complex_relative_iterator_base< face<D>,
+ algebraic_face<D>,
self_ > super_;
public:
@@ -122,7 +124,7 @@ namespace mln
{
mln_precondition(this->c_);
this->adj_faces_.clear();
- this->adj_faces_.push_back(*this->c_);
+ this->adj_faces_.push_back(make_algebraic_face(*this->c_, true));
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/topo/internal/complex_iterator_base.hh b/milena/mln/topo/internal/complex_iterator_base.hh
index 015ad7d..ceb86f3 100644
--- a/milena/mln/topo/internal/complex_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_iterator_base.hh
@@ -50,7 +50,7 @@
|
,--------------+--------------.
| |
- complex_set_iterator_base<F, E> complex_relative_iterator_base<F, E>
+ complex_set_iterator_base<F, E> complex_relative_iterator_base<C, F, E>
\endverbatim
*/
diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh
index 630f0f0..4925952 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_base.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh
@@ -36,14 +36,14 @@
\verbatim
- complex_relative_iterator_base<F, E>
+ complex_relative_iterator_base<C, F, E>
^
|
,--------------+--------------.
| |
- forward_complex_relative_iterator_base<F, E> |
+ forward_complex_relative_iterator_base<C, F, E> |
|
- backward_complex_relative_iterator_base<F, E>
+ backward_complex_relative_iterator_base<C, F, E>
\endverbatim
*/
@@ -68,20 +68,24 @@ namespace mln
namespace internal
{
- /*-------------------------------------------------------.
- | topo::internal::complex_relative_iterator_base<F, E>. |
- `-------------------------------------------------------*/
+ /*----------------------------------------------------------.
+ | topo::internal::complex_relative_iterator_base<C, F, E>. |
+ `----------------------------------------------------------*/
/// \brief Factoring class for relative iterators on mln::complex.
///
+ /// \arg \p C The type of the center face handle.
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
- template <typename F, typename E>
- class complex_relative_iterator_base : public complex_iterator_base<F, E>
+ template <typename C, typename F, typename E>
+ class complex_relative_iterator_base :
+ public complex_iterator_base<F, E>
{
- typedef complex_relative_iterator_base<F, E> self_;
+ typedef complex_relative_iterator_base<C, F, E> self_;
public:
+ /// The type of the center face.
+ typedef C center_type;
/// The type of the iterated faces.
typedef F face_type;
@@ -95,7 +99,7 @@ namespace mln
/// Manipulation.
/// \{
/// Change the center face.
- void center_at(const F& c);
+ void center_at(const center_type& c);
/// Start an iteration.
void start();
@@ -106,7 +110,7 @@ namespace mln
protected:
/// A pointer to the center face around which this iterator
/// moves.
- const face_type* c_;
+ const center_type* c_;
// The type of the set of vicinity sites (adjacent face handles).
typedef std::vector<face_type> adj_faces_t;
@@ -116,21 +120,22 @@ namespace mln
- /*---------------------------------------------------------------.
- | topo::internal::forward_complex_relative_iterator_base<F, E>. |
- `---------------------------------------------------------------*/
+ /*------------------------------------------------------------------.
+ | topo::internal::forward_complex_relative_iterator_base<C, F, E>. |
+ `------------------------------------------------------------------*/
/// \brief Factoring class for forward relative iterators on
/// mln::complex.
///
+ /// \arg \p C The type of the center face handle.
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
class forward_complex_relative_iterator_base
- : public complex_relative_iterator_base<F, E>
+ : public complex_relative_iterator_base<C, F, E>
{
- typedef forward_complex_relative_iterator_base<F, E> self_;
- typedef complex_relative_iterator_base<F, E> super_;
+ typedef forward_complex_relative_iterator_base<C, F, E> self_;
+ typedef complex_relative_iterator_base<C, F, E> super_;
public:
typedef F face_type;
@@ -166,21 +171,22 @@ namespace mln
};
- /*----------------------------------------------------------------.
- | topo::internal::backward_complex_relative_iterator_base<F, E>. |
- `----------------------------------------------------------------*/
+ /*-------------------------------------------------------------------.
+ | topo::internal::backward_complex_relative_iterator_base<C, F, E>. |
+ `-------------------------------------------------------------------*/
/// \brief Factoring class for backward relative iterators on
/// mln::complex.
///
+ /// \arg \p C The type of the center face handle.
/// \arg \p F The type of the face handle.
/// \arg \p E The type exact type of the iterator.
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
class backward_complex_relative_iterator_base
- : public complex_relative_iterator_base<F, E>
+ : public complex_relative_iterator_base<C, F, E>
{
- typedef backward_complex_relative_iterator_base<F, E> self_;
- typedef complex_relative_iterator_base<F, E> super_;
+ typedef backward_complex_relative_iterator_base<C, F, E> self_;
+ typedef complex_relative_iterator_base<C, F, E> super_;
public:
typedef F face_type;
@@ -219,13 +225,13 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- /*-------------------------------------------------------.
- | topo::internal::complex_relative_iterator_base<F, E>. |
- `-------------------------------------------------------*/
+ /*----------------------------------------------------------.
+ | topo::internal::complex_relative_iterator_base<C, F, E>. |
+ `----------------------------------------------------------*/
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
- complex_relative_iterator_base<F, E>::complex_relative_iterator_base()
+ complex_relative_iterator_base<C, F, E>::complex_relative_iterator_base()
: c_(0)
{
// Check for required methods in E.
@@ -235,10 +241,10 @@ namespace mln
exact(this)->invalidate();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
template <typename Fref>
inline
- complex_relative_iterator_base<F, E>::complex_relative_iterator_base(const Fref& f_ref)
+ complex_relative_iterator_base<C, F, E>::complex_relative_iterator_base(const Fref& f_ref)
{
// Check for required methods in E.
void (E::*m)() = & E::update_adj_faces_;
@@ -247,29 +253,29 @@ namespace mln
center_at(f_ref);
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- complex_relative_iterator_base<F, E>::center_at(const F& c)
+ complex_relative_iterator_base<C, F, E>::center_at(const C& c)
{
c_ = &c;
exact(this)->invalidate();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- complex_relative_iterator_base<F, E>::start()
+ complex_relative_iterator_base<C, F, E>::start()
{
exact(this)->do_start_();
if (exact(this)->is_valid())
exact(this)->update_f_();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- complex_relative_iterator_base<F, E>::next_()
+ complex_relative_iterator_base<C, F, E>::next_()
{
exact(this)->do_next_();
if (exact(this)->is_valid())
@@ -278,122 +284,122 @@ namespace mln
- /*---------------------------------------------------------------.
- | topo::internal::forward_complex_relative_iterator_base<F, E>. |
- `---------------------------------------------------------------*/
+ /*------------------------------------------------------------------.
+ | topo::internal::forward_complex_relative_iterator_base<C, F, E>. |
+ `------------------------------------------------------------------*/
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
- forward_complex_relative_iterator_base<F, E>::forward_complex_relative_iterator_base()
+ forward_complex_relative_iterator_base<C, F, E>::forward_complex_relative_iterator_base()
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
template <typename Fref>
inline
- forward_complex_relative_iterator_base<F, E>::forward_complex_relative_iterator_base(const Fref& f_ref)
+ forward_complex_relative_iterator_base<C, F, E>::forward_complex_relative_iterator_base(const Fref& f_ref)
: super_(f_ref)
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
bool
- forward_complex_relative_iterator_base<F, E>::is_valid() const
+ forward_complex_relative_iterator_base<C, F, E>::is_valid() const
{
return i_ != this->adj_faces_.end();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::invalidate()
+ forward_complex_relative_iterator_base<C, F, E>::invalidate()
{
i_ = this->adj_faces_.end();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::do_start_()
+ forward_complex_relative_iterator_base<C, F, E>::do_start_()
{
exact(this)->update_adj_faces_();
i_ = this->adj_faces_.begin();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::do_next_()
+ forward_complex_relative_iterator_base<C, F, E>::do_next_()
{
++i_;
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- forward_complex_relative_iterator_base<F, E>::update_f_()
+ forward_complex_relative_iterator_base<C, F, E>::update_f_()
{
mln_precondition(is_valid());
this->f_ = *i_;
}
- /*----------------------------------------------------------------.
- | topo::internal::backward_complex_relative_iterator_base<F, E>. |
- `----------------------------------------------------------------*/
+ /*-------------------------------------------------------------------.
+ | topo::internal::backward_complex_relative_iterator_base<C, F, E>. |
+ `-------------------------------------------------------------------*/
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
- backward_complex_relative_iterator_base<F, E>::backward_complex_relative_iterator_base()
+ backward_complex_relative_iterator_base<C, F, E>::backward_complex_relative_iterator_base()
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
template <typename Fref>
inline
- backward_complex_relative_iterator_base<F, E>::backward_complex_relative_iterator_base(const Fref& f_ref)
+ backward_complex_relative_iterator_base<C, F, E>::backward_complex_relative_iterator_base(const Fref& f_ref)
: super_(f_ref)
{
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
bool
- backward_complex_relative_iterator_base<F, E>::is_valid() const
+ backward_complex_relative_iterator_base<C, F, E>::is_valid() const
{
return i_ != this->adj_faces_.rend();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::invalidate()
+ backward_complex_relative_iterator_base<C, F, E>::invalidate()
{
i_ = this->adj_faces_.rend();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::do_start_()
+ backward_complex_relative_iterator_base<C, F, E>::do_start_()
{
exact(this)->update_adj_faces_();
i_ = this->adj_faces_.rbegin();
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::do_next_()
+ backward_complex_relative_iterator_base<C, F, E>::do_next_()
{
++i_;
}
- template <typename F, typename E>
+ template <typename C, typename F, typename E>
inline
void
- backward_complex_relative_iterator_base<F, E>::update_f_()
+ backward_complex_relative_iterator_base<C, F, E>::update_f_()
{
mln_precondition(is_valid());
this->f_ = *i_;
diff --git a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
index d0756f4..57b4843 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
@@ -63,6 +63,8 @@ namespace mln
typedef complex_relative_iterator_sequence<I1, I2, E> self_;
public:
+ /// The type of the center face.
+ typedef typename I1::center_type center_type;
/// The type of the iterated faces.
typedef typename I1::face_type face_type;
@@ -76,7 +78,7 @@ namespace mln
/// Manipulation.
/// \{
/// Change the center face.
- void center_at(const face& c);
+ void center_at(const center_type& c);
/// Test if the iterator is valid.
bool is_valid() const;
@@ -145,7 +147,7 @@ namespace mln
template <typename I1, typename I2, typename E>
inline
void
- complex_relative_iterator_sequence<I1, I2, E>::center_at(const face& c)
+ complex_relative_iterator_sequence<I1, I2, E>::center_at(const center_type& c)
{
iter1_.center_at(c);
iter2_.center_at(c);
--
1.5.6.5
1
0
* mln/topo/complex.hh
(connect_(const n_face<N, D>&, const n_face<N + 1, D>&)):
Turn method into...
(connect_(const algebraic_n_face<N, D>&, const n_face<N + 1, D>&)):
...this.
(complex<D>::add_face): Adjust.
(internal::lower_dim_faces_set_mixin<N, D>::print)
(higher_dim_faces_set_mixin<N, D>::print):
Adjust.
* mln/topo/face_data.hh: Adjust friends.
(internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_type)
(internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_type):
New typedefs.
Use them as types of...
(internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_)
(internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_):
...these members.
(internal::lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face)
(internal::higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face):
Convert to algebraic n-faces.
---
milena/ChangeLog | 25 +++++++++++++++++++++++++
milena/mln/topo/complex.hh | 31 +++++++++++++++++++++----------
milena/mln/topo/face_data.hh | 24 +++++++++++++++---------
3 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5395ca0..e7adf55 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,30 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Convert mln::topo::complex to algebraic faces.
+
+ * mln/topo/complex.hh
+ (connect_(const n_face<N, D>&, const n_face<N + 1, D>&)):
+ Turn method into...
+ (connect_(const algebraic_n_face<N, D>&, const n_face<N + 1, D>&)):
+ ...this.
+ (complex<D>::add_face): Adjust.
+ (internal::lower_dim_faces_set_mixin<N, D>::print)
+ (higher_dim_faces_set_mixin<N, D>::print):
+ Adjust.
+ * mln/topo/face_data.hh: Adjust friends.
+ (internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_type)
+ (internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_type):
+ New typedefs.
+ Use them as types of...
+ (internal::lower_dim_faces_data_mixin<N, D>::lower_dim_faces_)
+ (internal::higher_dim_faces_data_mixin<N, D>::higher_dim_faces_):
+ ...these members.
+ (internal::lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face)
+ (internal::higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face):
+ Convert to algebraic n-faces.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Convert n-faces set to algebraic faces.
* milena/mln/topo/n_faces_set.hh
diff --git a/milena/mln/topo/complex.hh b/milena/mln/topo/complex.hh
index e6330e2..00a2bb2 100644
--- a/milena/mln/topo/complex.hh
+++ b/milena/mln/topo/complex.hh
@@ -44,8 +44,8 @@
# include <mln/util/tracked_ptr.hh>
# include <mln/topo/face_data.hh>
-# include <mln/topo/face.hh>
-# include <mln/topo/n_face.hh>
+# include <mln/topo/algebraic_face.hh>
+# include <mln/topo/algebraic_n_face.hh>
# include <mln/topo/n_faces_set.hh>
# include <mln/topo/complex_iterators.hh>
@@ -204,14 +204,15 @@ namespace mln
apply_if_dim_matches_(unsigned n, const UnaryFunction& f) const;
/// \}
- /// \brief connect two faces.
+ /// \brief Connect two algebraic faces.
///
- /// \param f1 A face of dimension \p N
+ /// \param f1 An algebraic face of dimension \p N
/// \param f2 A face of dimension \p N + 1
///
/// \pre \p N must be lower or equal to \p D.
template <unsigned N>
- void connect_(const n_face<N, D>& f1, const n_face<N + 1, D>& f2);
+ void connect_(const algebraic_n_face<N, D>& f1,
+ const n_face<N + 1, D>& f2);
};
@@ -494,7 +495,8 @@ namespace mln
n_face<N + 1, D>
complex<D>::add_face(const n_faces_set<N, D>& adjacent_faces)
{
- typedef typename std::vector< n_face<N, D> >::const_iterator iter_t;
+ typedef typename std::vector< algebraic_n_face<N, D> >::const_iterator
+ iter_t;
// Ensure ADJACENT_FACES are already part of the complex.
if (!HAS_NDEBUG)
@@ -515,6 +517,10 @@ namespace mln
// Connect F and its ADJACENT_FACES.
for (iter_t a = adjacent_faces.faces().begin();
a != adjacent_faces.faces().end(); ++a)
+ /* Connect
+ - algebraic n-face *A,
+ - and an (n+1)-algebraic face based on FH and having the
+ sign of *A. */
connect_(*a, fh);
return fh;
}
@@ -629,12 +635,17 @@ namespace mln
template <unsigned N>
inline
void
- complex<D>::connect_(const n_face<N, D>& f1, const n_face<N + 1, D>& f2)
+ complex<D>::connect_(const algebraic_n_face<N, D>& f1,
+ const n_face<N + 1, D>& f2)
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
- f1.data().connect_higher_dim_face(f2);
+ /* Connect
+ - F1, an algebraic n-face,
+ - and AF2, an algebraic (n+1)-face based on F2 and having the
+ sign of F1. */
+ f1.data().connect_higher_dim_face(make_algebraic_n_face(f2, f1.sign()));
f2.data().connect_lower_dim_face(f1);
}
@@ -801,7 +812,7 @@ namespace mln
lower_dim_faces_set_mixin<N, D>::print(std::ostream& ostr,
const face_data<N, D>& f) const
{
- for (typename std::vector< n_face<N - 1, D> >::const_iterator l =
+ for (typename std::vector< algebraic_n_face<N - 1, D> >::const_iterator l =
f.lower_dim_faces_.begin(); l != f.lower_dim_faces_.end(); ++l)
ostr << l->face_id() << " ";
}
@@ -812,7 +823,7 @@ namespace mln
higher_dim_faces_set_mixin<N, D>::print(std::ostream& ostr,
const face_data<N, D>& f) const
{
- for (typename std::vector< n_face<N + 1, D> >::const_iterator h =
+ for (typename std::vector< algebraic_n_face<N + 1, D> >::const_iterator h =
f.higher_dim_faces_.begin(); h != f.higher_dim_faces_.end(); ++h)
ostr << h->face_id() << " ";
}
diff --git a/milena/mln/topo/face_data.hh b/milena/mln/topo/face_data.hh
index 27e78cd..1cee9e1 100644
--- a/milena/mln/topo/face_data.hh
+++ b/milena/mln/topo/face_data.hh
@@ -36,7 +36,7 @@
# include <vector>
-# include <mln/topo/n_face.hh>
+# include <mln/topo/algebraic_n_face.hh>
namespace mln
@@ -110,31 +110,37 @@ namespace mln
template <unsigned N, unsigned D>
class lower_dim_faces_data_mixin
{
+ typedef std::vector< algebraic_n_face<N - 1, D> > lower_dim_faces_type;
+
public:
- void connect_lower_dim_face (const n_face<N - 1, D>& f);
+ void connect_lower_dim_face(const algebraic_n_face<N - 1, D>& f);
+
private:
friend class mln::topo::internal::lower_dim_faces_set_mixin<N, D>;
friend class mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>;
- friend std::vector< n_face<N - 1, D> >
+ friend lower_dim_faces_type
mln::topo::n_face<N, D>::lower_dim_adj_faces() const;
// FIXME: Rename as lower_dim_adj_faces_ (as well as related members).
- std::vector< n_face<N - 1, D> > lower_dim_faces_;
+ lower_dim_faces_type lower_dim_faces_;
};
template <unsigned N, unsigned D>
class higher_dim_faces_data_mixin
{
+ typedef std::vector< algebraic_n_face<N + 1, D> > higher_dim_faces_type;
+
public:
- void connect_higher_dim_face(const n_face<N + 1, D>& f);
+ void connect_higher_dim_face(const algebraic_n_face<N + 1, D>& f);
+
private:
friend class mln::topo::internal::higher_dim_faces_set_mixin<N, D>;
friend class mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>;
- friend std::vector< n_face<N + 1, D> >
+ friend higher_dim_faces_type
mln::topo::n_face<N, D>::higher_dim_adj_faces() const;
// FIXME: Rename as higher_dim_adj_faces_ (as well as related members).
- std::vector< n_face<N + 1, D> > higher_dim_faces_;
+ higher_dim_faces_type higher_dim_faces_;
};
/// \}
@@ -149,7 +155,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const n_face<N - 1, D>& f)
+ lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const algebraic_n_face<N - 1, D>& f)
{
lower_dim_faces_.push_back(f);
}
@@ -157,7 +163,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
void
- higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const n_face<N + 1, D>& f)
+ higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const algebraic_n_face<N + 1, D>& f)
{
higher_dim_faces_.push_back(f);
}
--
1.5.6.5
1
0
* milena/mln/topo/n_faces_set.hh
(mln::topo::n_faces_set::faces_type): New typedef.
Use it as type of...
(mln::topo::n_faces_set::faces_): ...this member.
(mln::topo::n_faces_set::faces)
(mln::topo::n_faces_set::add):
Adjust methods.
(operator+(const algebraic_n_face<N,D>&, const algebraic_n_face<N,D>&))
(operator+(const n_face<N,D>&, const algebraic_n_face<N,D>&))
(operator+(const algebraic_n_face<N,D>&, const n_face<N,D>&))
(operator+(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
(operator-(const algebraic_n_face<N,D>&, const algebraic_n_face<N,D>&))
(operator-(const n_face<N,D>&, const algebraic_n_face<N,D>&))
(operator-(const algebraic_n_face<N,D>&, const n_face<N,D>&))
(operator-(const n_face<N,D>&, const n_face<N,D>&))
(operator-(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
(operator-(const n_faces_set<N,D>&, const n_face<N,D>))
(operator-=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&))
New operators.
(operator+=(n_faces_set<N,D>&, const n_face<N, D>&)):
Turn into...
(operator+=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&)):
...this.
* tests/topo/complex.cc: Adjust test.
---
milena/ChangeLog | 29 +++++
milena/mln/topo/n_faces_set.hh | 229 +++++++++++++++++++++++++++++++++++++---
milena/tests/topo/complex.cc | 18 ++--
3 files changed, 251 insertions(+), 25 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6076a89..5395ca0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,34 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Convert n-faces set to algebraic faces.
+
+ * milena/mln/topo/n_faces_set.hh
+ (mln::topo::n_faces_set::faces_type): New typedef.
+ Use it as type of...
+ (mln::topo::n_faces_set::faces_): ...this member.
+ (mln::topo::n_faces_set::faces)
+ (mln::topo::n_faces_set::add):
+ Adjust methods.
+ (operator+(const algebraic_n_face<N,D>&, const algebraic_n_face<N,D>&))
+ (operator+(const n_face<N,D>&, const algebraic_n_face<N,D>&))
+ (operator+(const algebraic_n_face<N,D>&, const n_face<N,D>&))
+ (operator+(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
+ (operator-(const algebraic_n_face<N,D>&, const algebraic_n_face<N,D>&))
+ (operator-(const n_face<N,D>&, const algebraic_n_face<N,D>&))
+ (operator-(const algebraic_n_face<N,D>&, const n_face<N,D>&))
+ (operator-(const n_face<N,D>&, const n_face<N,D>&))
+ (operator-(const n_faces_set<N,D>&, const algebraic_n_face<N,D>))
+ (operator-(const n_faces_set<N,D>&, const n_face<N,D>))
+ (operator-=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&))
+ New operators.
+ (operator+=(n_faces_set<N,D>&, const n_face<N, D>&)):
+ Turn into...
+ (operator+=(n_faces_set<N,D>&, const algebraic_n_face<N, D>&)):
+ ...this.
+ * tests/topo/complex.cc: Adjust test.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Adjust (non algebraic) faces.
* mln/topo/face.hh
diff --git a/milena/mln/topo/n_faces_set.hh b/milena/mln/topo/n_faces_set.hh
index cf11eef..cafd410 100644
--- a/milena/mln/topo/n_faces_set.hh
+++ b/milena/mln/topo/n_faces_set.hh
@@ -34,7 +34,9 @@
#include <vector>
#include <mln/core/contract.hh>
-#include <mln/topo/n_face.hh>
+#include <mln/topo/algebraic_n_face.hh>
+
+// FIXME: Rename as algebraic_n_faces_set?
namespace mln
@@ -47,17 +49,17 @@ namespace mln
template <unsigned D> class complex;
- /*------------------------.
- | Set of n-face handles. |
- `------------------------*/
+ /*------------------------------------.
+ | Set of (algebraic) n-face handles. |
+ `------------------------------------*/
/// \brief Set of face handles of dimension \p N.
template <unsigned N, unsigned D>
class n_faces_set
{
public:
- /// \brief Append face \a f to the set.
- void add(const n_face<N, D>& f);
+ /// \brief Append an algebraic face \a f to the set.
+ void add(const algebraic_n_face<N, D>& f);
/// \brief Reserve \a n cells in the set.
///
@@ -66,44 +68,109 @@ namespace mln
/// efficiency purpose, and its use is completely optional.
void reserve(size_t n);
+ /// The type of the set of face handles.
+ typedef std::vector< algebraic_n_face<N, D> > faces_type;
+
/// \brief Accessors.
///
/// Return the set of handles.
/// \{
- const std::vector< n_face<N, D> >& faces() const;
+ const faces_type& faces() const;
/// \}
private:
friend class complex<D>;
- // FIXME: Rename this as `handles_'?
- std::vector< n_face<N, D> > faces_;
+ /// The set of face handles.
+ faces_type faces_;
};
- /// Construction helpers for mln::topo::n_faces_set.
+ /*-----------------------.
+ | Construction helpers. |
+ `-----------------------*/
+
+ /* FIXME: We can probably reduce the number of operators, given
+ the fact that ``a - b'' is equivalent to ``a + (-b)''. */
+
+ /// Addition.
/// \{
template <unsigned N, unsigned D>
n_faces_set<N, D>
+ operator+(const algebraic_n_face<N, D>& f1,
+ const algebraic_n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator+(const algebraic_n_face<N, D>& f1, const n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator+(const n_face<N, D>& f1, const algebraic_n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
operator+(const n_face<N, D>& f1, const n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f);
+
template <unsigned N, unsigned D>
n_faces_set<N, D>
operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f);
template <unsigned N, unsigned D>
n_faces_set<N, D>&
- operator+=(n_faces_set<N, D>& fs, const n_face<N, D>& f);
+ operator+=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f);
+ /// \}
+
+ /// Subtraction.
+ /// \{
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const algebraic_n_face<N, D>& f1,
+ const algebraic_n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const algebraic_n_face<N, D>& f1, const n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const n_face<N, D>& f1, const algebraic_n_face<N, D>& f2);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const n_face<N, D>& f1, const n_face<N, D>& f2);
+
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>
+ operator-(const n_faces_set<N, D>& fs, const n_face<N, D>& f);
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>&
+ operator-=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f);
/// \}
# ifndef MLN_INCLUDE_ONLY
+ /*------------------------------------.
+ | Set of (algebraic) n-face handles. |
+ `------------------------------------*/
+
template <unsigned N, unsigned D>
inline
void
- n_faces_set<N, D>::add(const n_face<N, D>& f)
+ n_faces_set<N, D>::add(const algebraic_n_face<N, D>& f)
{
// Check consistency.
if (!faces_.empty())
@@ -121,17 +188,25 @@ namespace mln
template <unsigned N, unsigned D>
inline
- const std::vector< n_face<N, D> >&
+ const std::vector< algebraic_n_face<N, D> >&
n_faces_set<N, D>::faces() const
{
return faces_;
}
+ /*-----------------------.
+ | Construction helpers. |
+ `-----------------------*/
+
+ // ---------- //
+ // Addition. //
+ // ---------- //
template <unsigned N, unsigned D>
inline
n_faces_set<N, D>
- operator+(const n_face<N, D>& f1, const n_face<N, D>& f2)
+ operator+(const algebraic_n_face<N, D>& f1,
+ const algebraic_n_face<N, D>& f2)
{
n_faces_set<N, D> fs;
fs.add(f1);
@@ -142,7 +217,41 @@ namespace mln
template <unsigned N, unsigned D>
inline
n_faces_set<N, D>
- operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f)
+ operator+(const algebraic_n_face<N, D>& f1, const n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(f1);
+ fs.add(make_algebraic_n_face(f2, true));
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_face<N, D>& f1, const algebraic_n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(make_algebraic_n_face(f1, true));
+ fs.add(f2);
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_face<N, D>& f1, const n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(make_algebraic_n_face(f1, true));
+ fs.add(make_algebraic_n_face(f2, true));
+ return fs;
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f)
{
n_faces_set<N, D> fs2(fs);
fs2.add(f);
@@ -150,13 +259,101 @@ namespace mln
}
template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator+(const n_faces_set<N, D>& fs, const n_face<N, D>& f)
+ {
+ n_faces_set<N, D> fs2(fs);
+ fs2.add(make_algebraic_n_face(f, true));
+ return fs2;
+ }
+
+ template <unsigned N, unsigned D>
n_faces_set<N, D>&
- operator+=(n_faces_set<N, D>& fs, const n_face<N, D>& f)
+ operator+=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f)
{
fs.add(f);
return fs;
}
+ // ------------- //
+ // Subtraction. //
+ // ------------- //
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const algebraic_n_face<N, D>& f1,
+ const algebraic_n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(f1);
+ fs.add(-f2);
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const algebraic_n_face<N, D>& f1, const n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(f1);
+ fs.add(make_algebraic_n_face(f2, false));
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const n_face<N, D>& f1, const algebraic_n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(make_algebraic_n_face(f1, true));
+ fs.add(-f2);
+ return fs;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const n_face<N, D>& f1, const n_face<N, D>& f2)
+ {
+ n_faces_set<N, D> fs;
+ fs.add(make_algebraic_n_face(f1, true));
+ fs.add(make_algebraic_n_face(f2, false));
+ return fs;
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f)
+ {
+ n_faces_set<N, D> fs2(fs);
+ fs2.add(-f);
+ return fs2;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ n_faces_set<N, D>
+ operator-(const n_faces_set<N, D>& fs, const n_face<N, D>& f)
+ {
+ n_faces_set<N, D> fs2(fs);
+ fs2.add(make_algebraic_n_face(f, false));
+ return fs2;
+ }
+
+ template <unsigned N, unsigned D>
+ n_faces_set<N, D>&
+ operator-=(n_faces_set<N, D>& fs, const algebraic_n_face<N, D>& f)
+ {
+ fs.add(-f);
+ return fs;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
diff --git a/milena/tests/topo/complex.cc b/milena/tests/topo/complex.cc
index 7d5d354..3f87de7 100644
--- a/milena/tests/topo/complex.cc
+++ b/milena/tests/topo/complex.cc
@@ -85,15 +85,15 @@ int main()
topo::n_face<0, D> v3 = c.add_face();
// 1-faces (segments).
- topo::n_face<1, D> e0 = c.add_face(v0 + v1);
- topo::n_face<1, D> e1 = c.add_face(v0 + v2);
- topo::n_face<1, D> e2 = c.add_face(v1 + v2);
- topo::n_face<1, D> e3 = c.add_face(v0 + v3);
- topo::n_face<1, D> e4 = c.add_face(v2 + v3);
+ topo::n_face<1, D> e0 = c.add_face(-v1 + v0);
+ topo::n_face<1, D> e1 = c.add_face(-v0 + v2);
+ topo::n_face<1, D> e2 = c.add_face(-v2 + v1);
+ topo::n_face<1, D> e3 = c.add_face(-v0 + v3);
+ topo::n_face<1, D> e4 = c.add_face(-v3 + v2);
// 2-faces (triangles).
- topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
- topo::n_face<2, D> t1 = c.add_face(e1 + e3 + e4);
+ topo::n_face<2, D> t0 = c.add_face( e0 + e1 + e2);
+ topo::n_face<2, D> t1 = c.add_face(-e1 + e3 + e4);
std::cout << c << std::endl;
@@ -133,7 +133,7 @@ int main()
`-----------------*/
// Adjacent lower-dimension faces of AF.
- std::vector< topo::face<D> > af_lower_dim_adj_faces =
+ std::vector< topo::algebraic_face<D> > af_lower_dim_adj_faces =
af.lower_dim_adj_faces();
std::cout << "lower-dimension faces adjacent to " << af << ":" << std::endl;
std::copy (af_lower_dim_adj_faces.begin(), af_lower_dim_adj_faces.end(),
@@ -141,7 +141,7 @@ int main()
std::cout << std::endl;
// Adjacent higher-dimension faces of AF.
- std::vector< topo::face<D> > af_higher_dim_adj_faces =
+ std::vector< topo::algebraic_face<D> > af_higher_dim_adj_faces =
af.higher_dim_adj_faces();
std::cout << "higher-dimension faces adjacent to " << af << ":" << std::endl;
std::copy (af_higher_dim_adj_faces.begin(), af_higher_dim_adj_faces.end(),
--
1.5.6.5
1
0
* mln/topo/face.hh
(mln::topo::face<D>::lower_dim_adj_faces)
(mln::topo::face<D>::higher_dim_adj_faces):
Return algebraic faces.
(mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
(mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
Split the interface from the implementation, and move the
latter...
* mln/topo/algebraic_face.hh: ...here.
Update w.r.t. algebraic faces.
---
milena/ChangeLog | 15 +++++
milena/mln/topo/algebraic_face.hh | 94 +++++++++++++++++++++++++++++++++
milena/mln/topo/face.hh | 103 ++++++++++---------------------------
3 files changed, 137 insertions(+), 75 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 334b083..6076a89 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Adjust (non algebraic) faces.
+
+ * mln/topo/face.hh
+ (mln::topo::face<D>::lower_dim_adj_faces)
+ (mln::topo::face<D>::higher_dim_adj_faces):
+ Return algebraic faces.
+ (mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>)
+ (mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>):
+ Split the interface from the implementation, and move the
+ latter...
+ * mln/topo/algebraic_face.hh: ...here.
+ Update w.r.t. algebraic faces.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Adjust (non algebraic) n-faces.
* mln/topo/n_face.hh
diff --git a/milena/mln/topo/algebraic_face.hh b/milena/mln/topo/algebraic_face.hh
index 79f9116..1c666ac 100644
--- a/milena/mln/topo/algebraic_face.hh
+++ b/milena/mln/topo/algebraic_face.hh
@@ -276,6 +276,100 @@ namespace mln
<< ", id = " << f.face_id() << ", sign = " << f.sign()<< ')';
}
+
+ /*-----------------------------------------------.
+ | Helpers for face<D>::lower_dim_adj_faces() and |
+ | face<D>::higher_dim_adj_faces(). |
+ `-----------------------------------------------*/
+
+ /* FIXME: This is way too complicated; should disappear when the
+ implementation of complexes is simplified (see
+ https://trac.lrde.org/olena/ticket/168) */
+
+ namespace internal
+ {
+
+ template <unsigned N, unsigned D>
+ std::vector< algebraic_face<D> >
+ lower_dim_adj_faces_if_dim_matches_<N, D>::operator()(const face<D>& face)
+ {
+ metal::bool_< (N <= D) >::check();
+ metal::bool_< (N > 1) >::check();
+
+ if (face.n() == N)
+ {
+ face_data<N, D>& data = face.template data<N>();
+ std::vector< algebraic_n_face<N - 1, D> > lower_dim_faces =
+ data.lower_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<N - 1, D> >::const_iterator f =
+ lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ else
+ return internal::lower_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
+ }
+
+ template <unsigned D>
+ std::vector< algebraic_face<D> >
+ lower_dim_adj_faces_if_dim_matches_<1, D>::operator()(const face<D>& face)
+ {
+ /// If we reached this function, then the dimension of FACE
+ /// has to be 1.
+ mln_precondition(face.n() == 1);
+ face_data<1, D>& data = face.template data<1>();
+ std::vector< algebraic_n_face<0, D> > lower_dim_faces =
+ data.lower_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<0, D> >::const_iterator f =
+ lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+
+ template <unsigned N, unsigned D>
+ std::vector< algebraic_face<D> >
+ higher_dim_adj_faces_if_dim_matches_<N, D>::operator()(const face<D>& face)
+ {
+ metal::bool_< (N < D) >::check();
+
+ if (face.n() == N)
+ {
+ face_data<N, D>& data = face.template data<N>();
+ std::vector< algebraic_n_face<N + 1, D> > higher_dim_faces =
+ data.higher_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<N + 1, D> >::const_iterator f =
+ higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+ else
+ return
+ internal::higher_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
+ }
+
+ template <unsigned D>
+ std::vector< algebraic_face<D> >
+ higher_dim_adj_faces_if_dim_matches_<0, D>::operator()(const face<D>& face)
+ {
+ /// If we reached this function, then the dimension of face
+ /// has to be D - 1.
+ mln_precondition(face.n() == 0);
+ face_data<0, D>& data = face.template data<0>();
+ std::vector< algebraic_n_face<1, D> > higher_dim_faces =
+ data.higher_dim_faces_;
+ std::vector< topo::algebraic_face<D> > result;
+ for (typename std::vector< algebraic_n_face<1, D> >::const_iterator f =
+ higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
+ result.push_back(*f);
+ return result;
+ }
+
+ } // end of namespace mln::topo::internal
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
diff --git a/milena/mln/topo/face.hh b/milena/mln/topo/face.hh
index 371cf21..4ace2ab 100644
--- a/milena/mln/topo/face.hh
+++ b/milena/mln/topo/face.hh
@@ -47,7 +47,8 @@ namespace mln
template <unsigned D> class complex;
template <unsigned N, unsigned D> class n_face;
template <unsigned N, unsigned D> class face_data;
-
+ template <unsigned N> class algebraic_face;
+
/*-------.
| Face. |
@@ -60,6 +61,7 @@ namespace mln
template <unsigned D>
struct face
{
+ public:
// The type of the complex this handle points to.
typedef complex<D> complex_type;
@@ -111,9 +113,9 @@ namespace mln
// FIXME: To be overhauled.
/// Return an array of face handles pointing to adjacent (n-1)-faces.
- std::vector< face<D> > lower_dim_adj_faces() const;
+ std::vector< algebraic_face<D> > lower_dim_adj_faces() const;
/// Return an array of face handles pointing to adjacent (n+1)-faces.
- std::vector< face<D> > higher_dim_adj_faces() const;
+ std::vector< algebraic_face<D> > higher_dim_adj_faces() const;
/// \}
private:
@@ -195,7 +197,6 @@ namespace mln
{
// Ensure N is compatible with D.
metal::bool_< N <= D >::check();
-
}
template <unsigned D>
@@ -307,98 +308,50 @@ namespace mln
}
- // FIXME: This is way too complicated.
+ /*-----------------------------------------------.
+ | Helpers for face<D>::lower_dim_adj_faces() and |
+ | face<D>::higher_dim_adj_faces(). |
+ `-----------------------------------------------*/
+
+ /* FIXME: This is way too complicated; should disappear when the
+ implementation of complexes is simplified (see
+ https://trac.lrde.org/olena/ticket/168) */
+
+ // Implementation is in mln/topo/algebraic_face.hh.
+
namespace internal
{
+
template <unsigned N, unsigned D>
struct lower_dim_adj_faces_if_dim_matches_
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- metal::bool_< (N <= D) >::check();
- metal::bool_< (N > 1) >::check();
-
- if (face.n() == N)
- {
- face_data<N, D>& data = face.template data<N>();
- std::vector< n_face<N - 1, D> > lower_dim_faces =
- data.lower_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<N - 1, D> >::const_iterator f =
- lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
- else
- return internal::lower_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
template <unsigned D>
struct lower_dim_adj_faces_if_dim_matches_<1, D>
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- /// If we reached this function, then the dimension of FACE
- /// has to be 1.
- mln_precondition(face.n() == 1);
- face_data<1, D>& data = face.template data<1>();
- std::vector< n_face<0, D> > lower_dim_faces = data.lower_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<0, D> >::const_iterator f =
- lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
template <unsigned N, unsigned D>
struct higher_dim_adj_faces_if_dim_matches_
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- metal::bool_< (N < D) >::check();
-
- if (face.n() == N)
- {
- face_data<N, D>& data = face.template data<N>();
- std::vector< n_face<N + 1, D> > higher_dim_faces =
- data.higher_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<N + 1, D> >::const_iterator f =
- higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
- else
- return
- internal::higher_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
template <unsigned D>
struct higher_dim_adj_faces_if_dim_matches_<0, D>
{
- std::vector< face<D> > operator()(const face<D>& face)
- {
- /// If we reached this function, then the dimension of face
- /// has to be D - 1.
- mln_precondition(face.n() == 0);
- face_data<0, D>& data = face.template data<0>();
- std::vector< n_face<1, D> > higher_dim_faces =
- data.higher_dim_faces_;
- std::vector< topo::face<D> > result;
- for (typename std::vector< n_face<1, D> >::const_iterator f =
- higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
- result.push_back(*f);
- return result;
- }
+ std::vector< algebraic_face<D> > operator()(const face<D>& face);
};
- }
+
+ } // end of namespace mln::topo::internal
+
template <unsigned D>
inline
- std::vector< face<D> >
+ std::vector< algebraic_face<D> >
face<D>::lower_dim_adj_faces() const
{
// FIXME: Warning: might prevent any attempt to build a complex<0>.
@@ -406,12 +359,12 @@ namespace mln
return n_ > 0 ?
internal::lower_dim_adj_faces_if_dim_matches_<D, D>()(*this) :
- std::vector< face<D> >();
+ std::vector< algebraic_face<D> >();
}
template <unsigned D>
inline
- std::vector< face<D> >
+ std::vector< algebraic_face<D> >
face<D>::higher_dim_adj_faces() const
{
// FIXME: Warning: might prevent any attempt to build a complex<0>.
@@ -419,7 +372,7 @@ namespace mln
return n_ < D ?
internal::higher_dim_adj_faces_if_dim_matches_<D - 1, D>()(*this) :
- std::vector< face<D> >();
+ std::vector< algebraic_face<D> >();
}
--
1.5.6.5
1
0
* mln/topo/n_face.hh
(mln::topo::n_face<D>::lower_dim_adj_faces)
(mln::topo::n_face<D>::higher_dim_adj_faces):
Return algebraic n-faces.
(mln::topo::make_n_face): Remove useless helper.
(mln::topo::edge(const n_face<0, D>&, const n_face<0, D>&)):
Have this helper return an algebraic 1-face, and move it...
* milena/mln/topo/face.hh: ...here.
---
milena/ChangeLog | 13 ++++++
milena/mln/topo/algebraic_n_face.hh | 53 +++++++++++++++++++++++
milena/mln/topo/n_face.hh | 78 +++-------------------------------
3 files changed, 73 insertions(+), 71 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8f68af8..334b083 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Adjust (non algebraic) n-faces.
+
+ * mln/topo/n_face.hh
+ (mln::topo::n_face<D>::lower_dim_adj_faces)
+ (mln::topo::n_face<D>::higher_dim_adj_faces):
+ Return algebraic n-faces.
+ (mln::topo::make_n_face): Remove useless helper.
+ (mln::topo::edge(const n_face<0, D>&, const n_face<0, D>&)):
+ Have this helper return an algebraic 1-face, and move it...
+ * milena/mln/topo/face.hh: ...here.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Add an algebraic (oriented) face handle (descriptor).
* mln/topo/algebraic_face.hh: New.
diff --git a/milena/mln/topo/algebraic_n_face.hh b/milena/mln/topo/algebraic_n_face.hh
index fbfccf4..9228963 100644
--- a/milena/mln/topo/algebraic_n_face.hh
+++ b/milena/mln/topo/algebraic_n_face.hh
@@ -134,6 +134,32 @@ namespace mln
operator<<(std::ostream& ostr, const algebraic_n_face<N, D>& f);
+ /// \brief Helpers
+ /// \{
+
+ /** \brief Return the algebraic 1-face (edge) linking the 0-faces
+ (vertices) \a f1 and \a f2. If there is no 1-face between \a
+ f1 and \a f2, return an invalid 1-face.
+
+ \pre \a f1 and \a f2 must belong to the same complex.
+
+ Note: this routine assumes the complex is not degenerated, i.e,
+ \li it does not check that \a f1 and \a f2 are the only
+ 0-faces adjacent to an hypothetical 1-face; it just checks
+ that \a f1 and \a f2 <em>share</em> a common 1-face;
+
+ \li if there are several ajacent 1-faces shared by \a f1 and
+ \a f2 (if the complex is ill-formed), there is no
+ guarantee on the returned 1-face (the current
+ implementation return the first 1-face found, but client
+ code should not rely on this implementation-defined
+ behavior). */
+ template <unsigned D>
+ algebraic_n_face<1, D>
+ edge(const n_face<0, D>& f1, const n_face<0, D>& f2);
+ /// \}
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -253,6 +279,33 @@ namespace mln
<< ", id = " << f.face_id() << ", sign = " << f.sign()<< ')';
}
+ /*----------.
+ | Helpers. |
+ `----------*/
+
+ template <unsigned D>
+ algebraic_n_face<1, D>
+ edge(const n_face<0, D>& f1, const n_face<0, D>& f2)
+ {
+ typedef std::vector< algebraic_n_face<0, D> > n0_faces_t;
+ typedef std::vector< algebraic_n_face<1, D> > n1_faces_t;
+
+ n1_faces_t f1_adj_edges = f1.higher_dim_adj_faces();
+ for (typename n1_faces_t::const_iterator e = f1_adj_edges.begin();
+ e != f1_adj_edges.end(); ++e)
+ {
+ n0_faces_t e_adj_vertices = e->lower_dim_adj_faces();
+ for (typename n0_faces_t::const_iterator w = e_adj_vertices.begin();
+ w != e_adj_vertices.end(); ++w)
+ if (*w == f2)
+ // E is the edge linking F1 and F2.
+ return *e;
+ }
+
+ // If no shared edge was found, retun an empty (invalid) 1-face.
+ return algebraic_n_face<1, D>();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
diff --git a/milena/mln/topo/n_face.hh b/milena/mln/topo/n_face.hh
index 68a9512..2f8a7e0 100644
--- a/milena/mln/topo/n_face.hh
+++ b/milena/mln/topo/n_face.hh
@@ -46,6 +46,7 @@ namespace mln
// Forward declaration.
template <unsigned D> class complex;
template <unsigned N, unsigned D> class face_data;
+ template <unsigned N, unsigned D> class algebraic_n_face;
/*---------.
@@ -57,8 +58,9 @@ namespace mln
/// Contrary to an mln::topo::face, the dimension of an
/// mln::topo::n_face is fixed.
template <unsigned N, unsigned D>
- struct n_face
+ class n_face
{
+ public:
// The type of the complex this handle points to.
typedef complex<D> complex_type;
@@ -98,9 +100,9 @@ namespace mln
/* FIXME: We should not provide lower_dim_adj_faces() when N ==
0 nor higher_dim_adj_faces() when N == D. */
/// \Return an array of face handles pointing to adjacent (n-1)-faces.
- std::vector< n_face<N - 1, D> > lower_dim_adj_faces() const;
+ std::vector< algebraic_n_face<N - 1, D> > lower_dim_adj_faces() const;
/// Return an array of face handles pointing to adjacent (n+1)-faces.
- std::vector< n_face<N + 1, D> > higher_dim_adj_faces() const;
+ std::vector< algebraic_n_face<N + 1, D> > higher_dim_adj_faces() const;
/// \}
private:
@@ -114,12 +116,6 @@ namespace mln
};
- /// Create a handle for \p N-face of a \p D-complex.
- template <unsigned N, unsigned D>
- n_face<N, D>
- make_n_face(const complex<D>& c, unsigned face_id);
-
-
/// Comparison of two instances of mln::topo::n_face.
/// \{
@@ -155,31 +151,6 @@ namespace mln
operator<<(std::ostream& ostr, const n_face<N, D>& f);
- /// \brief Helpers
- /// \{
-
- /** \brief Return the 1-face (edge) linking the 0-faces (vertices)
- \a f1 and \a f2. If there is no 1-face between \a f1 and \a
- f2, return an invalid 1-face.
-
- \pre \a f1 and \a f2 must belong to the same complex.
-
- Note: this routine assumes the complex is not degenerated, i.e,
- \li it does not check that \a f1 and \a f2 are the only
- 0-faces adjacent to an hypothetical 1-face; it just checks
- that \a f1 and \a f2 <em>share</em> a common 1-face;
-
- \li if there are several ajacent 1-faces shared by \a f1 and
- \a f2 (if the complex is ill-formed), there is no
- guarantee on the returned 1-face (the current
- implementation return the first 1-face found, but client
- code should not rely on this implementation-defined
- behavior). */
- template <unsigned D>
- n_face<1, D> edge(const n_face<0, D>& f1, const n_face<0, D>& f2);
- /// \}
-
-
# ifndef MLN_INCLUDE_ONLY
@@ -285,7 +256,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- std::vector< n_face<N - 1, D> >
+ std::vector< algebraic_n_face<N - 1, D> >
n_face<N, D>::lower_dim_adj_faces() const
{
mln_precondition(N > 0);
@@ -295,7 +266,7 @@ namespace mln
template <unsigned N, unsigned D>
inline
- std::vector< n_face<N + 1, D> >
+ std::vector< algebraic_n_face<N + 1, D> >
n_face<N, D>::higher_dim_adj_faces() const
{
mln_precondition(N <= D);
@@ -306,15 +277,6 @@ namespace mln
template <unsigned N, unsigned D>
inline
- n_face<N, D>
- make_n_face(const complex<D>& c, unsigned face_id)
- {
- return n_face<N, D>(&c, face_id);
- }
-
-
- template <unsigned N, unsigned D>
- inline
bool
operator==(const n_face<N, D>& lhs, const n_face<N, D>& rhs)
{
@@ -353,32 +315,6 @@ namespace mln
<< ", id = " << f.face_id() << ')';
}
- /*----------.
- | Helpers. |
- `----------*/
-
- template <unsigned D>
- n_face<1, D> edge(const n_face<0, D>& f1, const n_face<0, D>& f2)
- {
- typedef std::vector< n_face<0, D> > n0_faces_t;
- typedef std::vector< n_face<1, D> > n1_faces_t;
-
- n1_faces_t f1_adj_edges = f1.higher_dim_adj_faces();
- for (typename n1_faces_t::const_iterator e = f1_adj_edges.begin();
- e != f1_adj_edges.end(); ++e)
- {
- n0_faces_t e_adj_vertices = e->lower_dim_adj_faces();
- for (typename n0_faces_t::const_iterator w = e_adj_vertices.begin();
- w != e_adj_vertices.end(); ++w)
- if (*w == f2)
- // E is the edge linking F1 and F2.
- return *e;
- }
-
- // If no shared edge was found, retun an empty (invalid) 1-face.
- return n_face<1, D>();
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::topo
--
1.5.6.5
1
0
23 Oct '08
* mln/topo/algebraic_face.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/topo/algebraic_face.hh | 285 +++++++++++++++++++++++++++++++++++++
2 files changed, 291 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/topo/algebraic_face.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 57d15fd..8f68af8 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Add an algebraic (oriented) face handle (descriptor).
+
+ * mln/topo/algebraic_face.hh: New.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Add an algebraic (oriented) n-face handle (descriptor).
* mln/topo/algebraic_n_face.hh: New.
diff --git a/milena/mln/topo/algebraic_face.hh b/milena/mln/topo/algebraic_face.hh
new file mode 100644
index 0000000..79f9116
--- /dev/null
+++ b/milena/mln/topo/algebraic_face.hh
@@ -0,0 +1,285 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TOPO_ALGEBRAIC_FACE_HH
+# define MLN_TOPO_ALGEBRAIC_FACE_HH
+
+/// \file mln/topo/algebraic_face.hh
+/// \brief Algebraic face of a complex.
+
+#include <mln/topo/face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ // Forward declarations.
+ template <unsigned D> class complex;
+ template <unsigned N, unsigned D> class n_face;
+ template <unsigned N, unsigned D> class face_data;
+
+
+ /*-------.
+ | Face. |
+ `-------*/
+
+ /// \brief Algebraic face handle in a complex; the face dimension
+ /// is dynamic.
+ ///
+ /// Contrary to an mln::topo::algebraic_n_face, the dimension of an
+ /// mln::topo::algebraic_face is not fixed.
+ template <unsigned D>
+ struct algebraic_face : public face<D>
+ {
+ typedef face<D> super_;
+
+ public:
+ // The type of the complex this handle points to.
+ typedef complex<D> complex_type;
+
+ /// Build a non-initialized algebraic face handle.
+ algebraic_face();
+ /// Build an algebraic face handle from \a complex and \a face_id.
+ algebraic_face(complex<D>& complex, unsigned n, unsigned face_id,
+ bool sign);
+ /// Build an algebraic face handle from an mln::face.
+ algebraic_face(const face<D>& f, bool sign);
+
+ /// Build a face handle from an mln::topo::algebraic_n_face.
+ template <unsigned N>
+ algebraic_face(const algebraic_n_face<N, D>& f);
+
+ /// Accessors.
+ /// \{
+ /// Return the sign of this face.
+ bool sign() const;
+ /// Set the sign of this face.
+ void set_sign(bool sign);
+ /// \}
+
+ private:
+ /// The sign of this algebraic face.
+ bool sign_;
+ };
+
+
+ /// Create an algebraic face handle of a \p D-complex.
+ template <unsigned D>
+ algebraic_face<D>
+ make_algebraic_face(const face<D>& f, bool sign);
+
+
+ /// Inversion operators.
+ /// \{
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const face<D>& f);
+
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const algebraic_face<D>& f);
+ /// \}
+
+
+ /// Comparison of two instances of mln::topo::algebraic_face.
+ /// \{
+
+ /// \brief Is \a lhs equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned D>
+ bool operator==(const algebraic_face<D>& lhs,
+ const algebraic_face<D>& rhs);
+
+ /// \brief Is \a lhs different from \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned D>
+ bool operator!=(const algebraic_face<D>& lhs,
+ const algebraic_face<D>& rhs);
+
+ /// \brief Is \a lhs ``less'' than \a rhs?
+ ///
+ /// This comparison is required by algorithms sorting algebraic
+ /// face handles.
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ /// \pre Arguments \a lhs and \a rhs must have the same dimension.
+ template <unsigned D>
+ bool operator< (const algebraic_face<D>& lhs,
+ const algebraic_face<D>& rhs);
+
+ /// \}
+
+
+ /// Print an mln::topo::algebraic_face.
+ template <unsigned D>
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_face<D>& f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned D>
+ inline
+ algebraic_face<D>::algebraic_face()
+ : super_(), sign_(true)
+ {
+ }
+
+ template <unsigned D>
+ inline
+ algebraic_face<D>::algebraic_face(complex<D>& c, unsigned n,
+ unsigned face_id, bool sign)
+ : super_(c, n, face_id), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ mln_precondition(n <= D);
+ }
+
+ template <unsigned D>
+ inline
+ algebraic_face<D>::algebraic_face(const face<D>& f, bool sign)
+ : super_(f), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ mln_precondition(f.n() <= D);
+ }
+
+ template <unsigned D>
+ template <unsigned N>
+ inline
+ algebraic_face<D>::algebraic_face(const algebraic_n_face<N, D>& f)
+ : super_(f), sign_(f.sign())
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+
+ template <unsigned D>
+ inline
+ bool
+ algebraic_face<D>::sign() const
+ {
+ return sign_;
+ }
+
+ template <unsigned D>
+ inline
+ void
+ algebraic_face<D>::set_sign(bool sign)
+ {
+ sign_ = sign;
+ }
+
+
+ template <unsigned D>
+ algebraic_face<D>
+ make_algebraic_face(const face<D>& f, bool sign)
+ {
+ return algebraic_face<D>(f, sign);
+ }
+
+
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const face<D>& f)
+ {
+ return algebraic_face<D>(f, false);
+ }
+
+ template <unsigned D>
+ algebraic_face<D>
+ operator-(const algebraic_face<D>& f)
+ {
+ algebraic_face<D> f2(f);
+ f2.set_sign(!f.sign());
+ return f2;
+ }
+
+
+ template <unsigned D>
+ inline
+ bool
+ operator==(const algebraic_face<D>& lhs, const algebraic_face<D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return
+ lhs.n() == rhs.n() &&
+ lhs.face_id() == rhs.face_id() &&
+ lhs.sign() == rhs.sign();
+ }
+
+ template <unsigned D>
+ inline
+ bool
+ operator!=(const algebraic_face<D>& lhs, const algebraic_face<D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return !(lhs == rhs);
+ }
+
+ template <unsigned D>
+ inline
+ bool
+ operator< (const algebraic_face<D>& lhs, const algebraic_face<D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ // Ensure LHS and RHS have the same dimension.
+ mln_precondition(lhs.n() == rhs.n());
+ return lhs.face_id() < rhs.face_id();
+ }
+
+
+ template <unsigned D>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_face<D>& f)
+ {
+ return
+ ostr << "(cplx = " << f.cplx().addr() << ", dim = " << f.n()
+ << ", id = " << f.face_id() << ", sign = " << f.sign()<< ')';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_FACE_HH
--
1.5.6.5
1
0
23 Oct '08
* mln/topo/algebraic_n_face.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/topo/algebraic_n_face.hh | 262 +++++++++++++++++++++++++++++++++++
2 files changed, 268 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/topo/algebraic_n_face.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6bf9126..57d15fd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Add an algebraic (oriented) n-face handle (descriptor).
+
+ * mln/topo/algebraic_n_face.hh: New.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Fix a bug in OFF file saving.
* mln/io/off/save.hh
diff --git a/milena/mln/topo/algebraic_n_face.hh b/milena/mln/topo/algebraic_n_face.hh
new file mode 100644
index 0000000..fbfccf4
--- /dev/null
+++ b/milena/mln/topo/algebraic_n_face.hh
@@ -0,0 +1,262 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_TOPO_ALGEBRAIC_N_FACE_HH
+# define MLN_TOPO_ALGEBRAIC_N_FACE_HH
+
+/// \file mln/topo/algebraic_n_face.hh
+/// \brief Algebraic n-face of a complex.
+
+#include <mln/topo/n_face.hh>
+
+
+namespace mln
+{
+
+ namespace topo
+ {
+
+ /*-------------------.
+ | Algebraic n-Face. |
+ `-------------------*/
+
+ /// \brief Algebraic \p N-face handle in a complex.
+ ///
+ /// Contrary to an mln::topo::algebraic_face, the dimension of an
+ /// mln::topo::algebraic_n_face is fixed.
+ template <unsigned N, unsigned D>
+ class algebraic_n_face : public n_face<N, D>
+ {
+ typedef n_face<N, D> super_;
+
+ public:
+ /// Build a non-initialized algebraic face handle.
+ algebraic_n_face();
+ /// Build an algebraic face handle from \a complex and \a face_id.
+ algebraic_n_face(complex<D>& complex, unsigned face_id, bool sign);
+ /// Build an algebraic face handle from an mln::n_face.
+ algebraic_n_face(const n_face<N, D>& f, bool sign);
+
+ /// Accessors.
+ /// \{
+ /// Return the sign of this face.
+ bool sign() const;
+ /// Set the sign of this face.
+ void set_sign(bool sign);
+ /// \}
+
+ private:
+ bool sign_;
+ };
+
+
+ /// Create an algebraic \p N-face handle of a \p D-complex.
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ make_algebraic_n_face(const n_face<N, D>& f, bool sign);
+
+
+ /// Inversion operators.
+ /// \{
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const n_face<N, D>& f);
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const algebraic_n_face<N, D>& f);
+ /// \}
+
+
+ /// Comparison of two instances of mln::topo::algebraic_n_face.
+ /// \{
+
+ /// \brief Is \a lhs equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned N, unsigned D>
+ bool
+ operator==(const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs);
+
+ /// \brief Is \a lhs different from \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned N, unsigned D>
+ bool
+ operator!=(const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs);
+
+ /// \brief Is \a lhs ``less'' than \a rhs?
+ ///
+ /// This comparison is required by algorithms sorting algebraic
+ /// face handles.
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::topo::complex.
+ template <unsigned N, unsigned D>
+ bool
+ operator< (const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs);
+
+ /// \}
+
+
+ /// Print an mln::topo::algebraic_n_face.
+ template <unsigned N, unsigned D>
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_n_face<N, D>& f);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned N, unsigned D>
+ inline
+ algebraic_n_face<N, D>::algebraic_n_face()
+ : super_(), sign_(true)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ mln_postcondition(!this->is_valid());
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ algebraic_n_face<N, D>::algebraic_n_face(complex<D>& c, unsigned face_id,
+ bool sign)
+ : super_(c, face_id), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ algebraic_n_face<N, D>::algebraic_n_face(const n_face<N, D>& f, bool sign)
+ : super_(f), sign_(sign)
+ {
+ // Ensure N is compatible with D.
+ metal::bool_< N <= D >::check();
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ algebraic_n_face<N, D>::sign() const
+ {
+ return sign_;
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ void
+ algebraic_n_face<N, D>::set_sign(bool sign)
+ {
+ sign_ = sign;
+ }
+
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ make_algebraic_n_face(const n_face<N, D>& f, bool sign)
+ {
+ return algebraic_n_face<N, D>(f, sign);
+ }
+
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const n_face<N, D>& f)
+ {
+ return algebraic_n_face<N, D>(f, false);
+ }
+
+ template <unsigned N, unsigned D>
+ algebraic_n_face<N, D>
+ operator-(const algebraic_n_face<N, D>& f)
+ {
+ algebraic_n_face<N, D> f2(f);
+ f2.set_sign(!f.sign());
+ return f2;
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator==(const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return lhs.face_id() == rhs.face_id() && lhs.sign() == rhs.sign();
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator!=(const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return !(lhs == rhs);
+ }
+
+ template <unsigned N, unsigned D>
+ inline
+ bool
+ operator< (const algebraic_n_face<N, D>& lhs,
+ const algebraic_n_face<N, D>& rhs)
+ {
+ // Ensure LHS and RHS belong to the same complex.
+ mln_precondition(lhs.cplx() == rhs.cplx());
+ return lhs.face_id() < rhs.face_id();
+ }
+
+
+ template <unsigned N, unsigned D>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const algebraic_n_face<N, D>& f)
+ {
+ return
+ ostr << "(cplx = " << f.cplx().addr() << ", dim = " << f.n()
+ << ", id = " << f.face_id() << ", sign = " << f.sign()<< ')';
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::topo
+
+} // end of namespace mln
+
+#endif // ! MLN_TOPO_ALGEBRAIC_N_FACE_HH
--
1.5.6.5
1
0
* mln/io/off/save.hh
(save(const bin_2complex_image3df&, const std::string&)):
Swap the positions of the number of edges and number of faces in
the written file.
---
milena/ChangeLog | 9 +++++++++
milena/mln/io/off/save.hh | 4 ++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f6299c9..6bf9126 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+ Fix a bug in OFF file saving.
+
+ * mln/io/off/save.hh
+ (save(const bin_2complex_image3df&, const std::string&)):
+ Swap the positions of the number of edges and number of faces in
+ the written file.
+
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
Remove seldom used macros mln_face and mln_face_.
* mln/core/macros.hh (mln_face, mln_face_): Remove macros.
diff --git a/milena/mln/io/off/save.hh b/milena/mln/io/off/save.hh
index eba2aeb..dce42fd 100644
--- a/milena/mln/io/off/save.hh
+++ b/milena/mln/io/off/save.hh
@@ -113,8 +113,8 @@ namespace mln
ima.nfaces<0>().
*/
ostr << ima.domain().cplx().nfaces<0>() << ' '
- << ima.domain().cplx().nfaces<1>() << ' '
- << ima.domain().cplx().nfaces<2>() << std::endl;
+ << ima.domain().cplx().nfaces<2>() << ' '
+ << ima.domain().cplx().nfaces<1>() << std::endl;
/*-------.
| Data. |
--
1.5.6.5
1
0
* mln/core/macros.hh (mln_face, mln_face_): Remove macros.
* mln/topo/internal/complex_relative_iterator_sequence: Adjust.
(internal/complex_relative_iterator_sequence<I1, I2, E>::face):
Rename typedef as...
(internal/complex_relative_iterator_sequence<I1, I2, E>::face_type):
...this.
---
milena/ChangeLog | 11 +++++++++++
milena/mln/core/macros.hh | 6 ------
.../internal/complex_relative_iterator_sequence.hh | 14 +++++++-------
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 524fd7c..f6299c9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,14 @@
+2008-10-23 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Remove seldom used macros mln_face and mln_face_.
+
+ * mln/core/macros.hh (mln_face, mln_face_): Remove macros.
+ * mln/topo/internal/complex_relative_iterator_sequence: Adjust.
+ (internal/complex_relative_iterator_sequence<I1, I2, E>::face):
+ Rename typedef as...
+ (internal/complex_relative_iterator_sequence<I1, I2, E>::face_type):
+ ...this.
+
2008-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
Update tutorial.
diff --git a/milena/mln/core/macros.hh b/milena/mln/core/macros.hh
index afbf50c..130cb89 100644
--- a/milena/mln/core/macros.hh
+++ b/milena/mln/core/macros.hh
@@ -146,12 +146,6 @@
// f
-/// Shortcuts to access the (complex) face type associated to T.
-/// \{
-# define mln_face(T) typename T::face
-# define mln_face_(T) T::face
-/// \}
-
/// Shortcuts to access the element-forward-iterator type associated
/// to T.
/// \{
diff --git a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
index 424ff71..d0756f4 100644
--- a/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
+++ b/milena/mln/topo/internal/complex_relative_iterator_sequence.hh
@@ -64,7 +64,7 @@ namespace mln
public:
/// The type of the iterated faces.
- typedef mln_face(I1) face;
+ typedef typename I1::face_type face_type;
/// Construction and assignment.
/// \{
@@ -92,7 +92,7 @@ namespace mln
/// Conversion.
/// \{
/// Return a reference to the corresponding face handle.
- operator const face&() const;
+ operator const face_type&() const;
/// \}
protected:
@@ -106,7 +106,7 @@ namespace mln
I2 iter2_;
/// The face handle this iterator is pointing to.
- face f_;
+ face_type f_;
};
@@ -126,7 +126,7 @@ namespace mln
complex_relative_iterator_sequence<I1, I2, E>::complex_relative_iterator_sequence()
{
// Ensure I1 and I2 are compatible.
- mlc_equal(mln_face(I1), mln_face(I2))::check();
+ mlc_equal(typename I1::face_type, typename I2::face_type)::check();
invalidate();
}
@@ -137,7 +137,7 @@ namespace mln
complex_relative_iterator_sequence<I1, I2, E>::complex_relative_iterator_sequence(const Fref& f_ref)
{
// Ensure I1 and I2 are compatible.
- mlc_equal(mln_face(I1), mln_face(I2))::check();
+ mlc_equal(typename I1::face_type, typename I2::face_type)::check();
center_at(f_ref);
}
@@ -209,7 +209,7 @@ namespace mln
template <typename I1, typename I2, typename E>
inline
- complex_relative_iterator_sequence<I1, I2, E>::operator const face&() const
+ complex_relative_iterator_sequence<I1, I2, E>::operator const face_type&() const
{
return f_;
}
@@ -221,7 +221,7 @@ namespace mln
operator<<(std::ostream& ostr,
const complex_relative_iterator_sequence<I1, I2, E>& p)
{
- return ostr << mln_face(I1)(p);
+ return ostr << typename I1::face_type(p);
}
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* doc/tutorial/samples/fun-p2b-1.tex,
* doc/tutorial/samples/graph-output-1.tex,
* doc/tutorial/samples/ima2d-display-1.tex,
* doc/tutorial/samples/ima2d-display-2.tex,
* doc/tutorial/samples/parray-display-1.tex,
* doc/tutorial/samples/paste.tex: Fix indentation
* doc/tutorial/samples/dpoint-1-output.tex,
* doc/tutorial/samples/dpoint-1.tex,
* doc/tutorial/samples/win-create-1-display.tex,
* doc/tutorial/samples/win-create-1.tex,
* doc/tutorial/samples/win-create-2.tex: new sample code.
* doc/tutorial/tutorial.tex: Update.
- Start writing section about windows and neighborhoods.
- Write section about dpoints.
- Add a section about the global variables.
---
milena/ChangeLog | 22 ++
milena/doc/tutorial/samples/dpoint-1-output.tex | 1 +
milena/doc/tutorial/samples/dpoint-1.tex | 11 +
milena/doc/tutorial/samples/fun-p2b-1.tex | 2 +-
milena/doc/tutorial/samples/graph-output-1.tex | 4 +-
milena/doc/tutorial/samples/ima2d-display-1.tex | 12 +-
milena/doc/tutorial/samples/ima2d-display-2.tex | 6 +-
milena/doc/tutorial/samples/parray-display-1.tex | 6 +-
milena/doc/tutorial/samples/paste.tex | 6 +-
.../doc/tutorial/samples/win-create-1-display.tex | 3 +
milena/doc/tutorial/samples/win-create-1.tex | 5 +
milena/doc/tutorial/samples/win-create-2.tex | 8 +
milena/doc/tutorial/tutorial.tex | 333 +++++++++++++++++++-
13 files changed, 386 insertions(+), 33 deletions(-)
create mode 100644 milena/doc/tutorial/samples/dpoint-1-output.tex
create mode 100644 milena/doc/tutorial/samples/dpoint-1.tex
create mode 100644 milena/doc/tutorial/samples/win-create-1-display.tex
create mode 100644 milena/doc/tutorial/samples/win-create-1.tex
create mode 100644 milena/doc/tutorial/samples/win-create-2.tex
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4aca6f2..524fd7c 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,25 @@
+2008-10-23 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update tutorial.
+
+ * doc/tutorial/samples/fun-p2b-1.tex,
+ * doc/tutorial/samples/graph-output-1.tex,
+ * doc/tutorial/samples/ima2d-display-1.tex,
+ * doc/tutorial/samples/ima2d-display-2.tex,
+ * doc/tutorial/samples/parray-display-1.tex,
+ * doc/tutorial/samples/paste.tex: Fix indentation
+
+ * doc/tutorial/samples/dpoint-1-output.tex,
+ * doc/tutorial/samples/dpoint-1.tex,
+ * doc/tutorial/samples/win-create-1-display.tex,
+ * doc/tutorial/samples/win-create-1.tex,
+ * doc/tutorial/samples/win-create-2.tex: new sample code.
+
+ * doc/tutorial/tutorial.tex: Update.
+ - Start writing section about windows and neighborhoods.
+ - Write section about dpoints.
+ - Add a section about the global variables.
+
2008-10-23 Nicolas Ballas <ballas(a)lrde.epita.fr>
Make extension images and cast image work with fill_with_value routine.
diff --git a/milena/doc/tutorial/samples/dpoint-1-output.tex b/milena/doc/tutorial/samples/dpoint-1-output.tex
new file mode 100644
index 0000000..8982f0f
--- /dev/null
+++ b/milena/doc/tutorial/samples/dpoint-1-output.tex
@@ -0,0 +1 @@
+(0, 1)
diff --git a/milena/doc/tutorial/samples/dpoint-1.tex b/milena/doc/tutorial/samples/dpoint-1.tex
new file mode 100644
index 0000000..65b2628
--- /dev/null
+++ b/milena/doc/tutorial/samples/dpoint-1.tex
@@ -0,0 +1,11 @@
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/alias/dpoint2d.hh>
+int main()
+{
+ using namespace mln;
+
+ dpoint2d dp(-1,0);
+ point2d p(1,1);
+
+ std::cout << p + dp << std::endl;
+}
diff --git a/milena/doc/tutorial/samples/fun-p2b-1.tex b/milena/doc/tutorial/samples/fun-p2b-1.tex
index a43ca77..0354bcb 100644
--- a/milena/doc/tutorial/samples/fun-p2b-1.tex
+++ b/milena/doc/tutorial/samples/fun-p2b-1.tex
@@ -1,4 +1,4 @@
bool row_oddity(mln::point2d p)
{
-return p.row() % 2;
+ return p.row() % 2;
}
diff --git a/milena/doc/tutorial/samples/graph-output-1.tex b/milena/doc/tutorial/samples/graph-output-1.tex
index d3bf445..4647780 100644
--- a/milena/doc/tutorial/samples/graph-output-1.tex
+++ b/milena/doc/tutorial/samples/graph-output-1.tex
@@ -1,5 +1,5 @@
-0 1 2 3 4
-.-----------
+ 0 1 2 3 4
+ .-----------
0 | 0 2
1 | \ / |
2 | 1 |
diff --git a/milena/doc/tutorial/samples/ima2d-display-1.tex b/milena/doc/tutorial/samples/ima2d-display-1.tex
index 3929a1b..56c17da 100644
--- a/milena/doc/tutorial/samples/ima2d-display-1.tex
+++ b/milena/doc/tutorial/samples/ima2d-display-1.tex
@@ -1,7 +1,7 @@
-c 0 1 2 3
+ c 0 1 2 3
r
-+-+-+-+-+
-0 | |x| | |
-+-+-+-+-+
-1 | | | | |
-+-+-+-+-+
+ +-+-+-+-+
+0 | |x| | |
+ +-+-+-+-+
+1 | | | | |
+ +-+-+-+-+
diff --git a/milena/doc/tutorial/samples/ima2d-display-2.tex b/milena/doc/tutorial/samples/ima2d-display-2.tex
index cd5144f..ce18cb0 100644
--- a/milena/doc/tutorial/samples/ima2d-display-2.tex
+++ b/milena/doc/tutorial/samples/ima2d-display-2.tex
@@ -1,7 +1,7 @@
c 6 7 8 9
r
-+-+-+-+
+ +-+-+-+
3 | |x| |
-+-+-+-+-+
+ +-+-+-+-+
4 | | |
-+-+-+
+ +-+-+
diff --git a/milena/doc/tutorial/samples/parray-display-1.tex b/milena/doc/tutorial/samples/parray-display-1.tex
index 2003777..734594b 100644
--- a/milena/doc/tutorial/samples/parray-display-1.tex
+++ b/milena/doc/tutorial/samples/parray-display-1.tex
@@ -1,4 +1,4 @@
arr[] = 0 1 2 3 4
-+-+-+-+-+-+
-| |x| | | |
-+-+-+-+-+-+
+ +-+-+-+-+-+
+ | |x| | | |
+ +-+-+-+-+-+
diff --git a/milena/doc/tutorial/samples/paste.tex b/milena/doc/tutorial/samples/paste.tex
index cf1bcf3..327b226 100644
--- a/milena/doc/tutorial/samples/paste.tex
+++ b/milena/doc/tutorial/samples/paste.tex
@@ -1,7 +1,7 @@
template <typename I, typename J>
void paste(const I& data, J& dest)
{
-mln_piter(I) p(data.domain());
-for_all(p)
-dest(p) = data(p);
+ mln_piter(I) p(data.domain());
+ for_all(p)
+ dest(p) = data(p);
}
diff --git a/milena/doc/tutorial/samples/win-create-1-display.tex b/milena/doc/tutorial/samples/win-create-1-display.tex
new file mode 100644
index 0000000..028b663
--- /dev/null
+++ b/milena/doc/tutorial/samples/win-create-1-display.tex
@@ -0,0 +1,3 @@
+o -
+o X
+o -
diff --git a/milena/doc/tutorial/samples/win-create-1.tex b/milena/doc/tutorial/samples/win-create-1.tex
new file mode 100644
index 0000000..9e86ffb
--- /dev/null
+++ b/milena/doc/tutorial/samples/win-create-1.tex
@@ -0,0 +1,5 @@
+window2d win;
+win.insert(-1, 0)
+win.insert(0, -1)
+win.insert(-1,-1);
+
diff --git a/milena/doc/tutorial/samples/win-create-2.tex b/milena/doc/tutorial/samples/win-create-2.tex
new file mode 100644
index 0000000..a76e9c2
--- /dev/null
+++ b/milena/doc/tutorial/samples/win-create-2.tex
@@ -0,0 +1,8 @@
+bool b[9] = { 1, 0, 0,
+ 1, 0, 0,
+ 1, 0, 0 };
+bool b2[3][3] = { { 1, 0, 0 },
+ { 1, 0, 0 },
+ { 1, 0, 0 } };
+window2d win = convert::to<window2d>(b)
+window2d win2 = convert::to<window2d>(b2);
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index d91f56f..d6a9226 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -48,25 +48,147 @@ showstringspaces=false,linewidth=14cm}
\backslash page #1 #2%
\backslash htmlonly%
}
+
+% #1 : section name
+% #2 : section title
\newcommand{\doxysection}[2]{%
\label{#1}
\backslash endhtmlonly%
\backslash section #1 #2%
\backslash htmlonly%
}
+\newcommand{\doxysubsection}[2]{%
+\label{#1}
+\backslash endhtmlonly%
+\backslash subsection #1 #2%
+\backslash htmlonly%
+}
+
\newcommand{\doxycode}[1]{
\backslash endhtmlonly%
\backslash include #1.tex%
\backslash htmlonly%
}
+\newenvironment{doxymath}
+{
+%\backslash endhtmlonly%
+%\backslash f\$
+%\begin{rawtext}
+$$
+}
+{
+$$
+%\end{rawtext}
+%\backslash f\$
+%\backslash htmlonly%
+}
+
%\begin{latexonly}
\renewcommand{\doxychapter}[2]{\chapter{#2}\label{#1}}
\renewcommand{\doxysection}[2]{\section{#2}\label{#1}}
+\renewcommand{\doxysubsection}[2]{\subsection{#2}\label{#1}}
\renewcommand{\doxycode}[1]{\lstinputlisting[frame=single]{samples/#1}}
+\renewenvironment{doxymath}
+{
+ $$
+}
+{
+ $$
+}
+
%\end{latexonly}
+\usetikzlibrary{er}
+\newcommand{\neighcfour}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[fill=orange!20,draw=orange] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+\end{tikzpicture}%
+\end{latexonly}
+}
+
+\newcommand{\neighceight}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[fill=orange!20,draw=orange] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+ %Top left
+ \draw (-0.25,0.25) node[entity,draw] {};
+ %Top right
+ \draw (0.26,0.25) node[entity,draw] {};%
+ %Bottom left
+ \draw (-0.25,-0.25) node[entity,draw] {};%
+ %Bottom Right
+ \draw (0.26,-0.25) node[entity,draw] {};%
+\end{tikzpicture}%
+\end{latexonly}
+}
+
+\newcommand{\wincfour}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[entity,draw] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+
+\end{tikzpicture}%
+\end{latexonly}
+}
+
+\newcommand{\winceight}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[entity,draw] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+ %Top left
+ \draw (-0.25,0.25) node[entity,draw] {};
+ %Top right
+ \draw (0.26,0.25) node[entity,draw] {};%
+ %Bottom left
+ \draw (-0.25,-0.25) node[entity,draw] {};%
+ %Bottom Right
+ \draw (0.26,-0.25) node[entity,draw] {};%
+\end{tikzpicture}%
+\end{latexonly}
+}
\begin{document}
@@ -85,6 +207,7 @@ showstringspaces=false,linewidth=14cm}
- \backslash subpage graphandima
- \backslash subpage arithmops
- \backslash subpage mathtools
+- \backslash subpage globalvars
\backslash htmlonly
\end{htmlonly}
@@ -206,6 +329,18 @@ means we have the following equivalence:
The site does not store any value but refer to an area where we will be able
to read its value.
+Sites may have a different types, depending on the image type:
+
+\begin{tabular}{l|l}
+Name & Description \\
+\hline
+point2d & 2D point on a regular grid \\
+point & Generic point ($n-D$) on a regular grid \\
+util::vec & Algebraic vector \\
+util::vertex & Graph vertex \\
+util::edge & Graph edge \\
+\end{tabular}
+
[Illustration : grille + intersection + pmin() + pmax() + distance entre 2
points en x et en y = 1]\\
@@ -311,19 +446,38 @@ constant time retrieval.
\doxysection{definition}{Definition}
An image is composed both of:
\begin{itemize}
-\item A function $$
+\item A function
+\begin{doxymath}
ima : \left\{
\begin{array}{lll}
Site &\rightarrow & Value \\
p & \mapsto & ima(p)
\end{array}
\right.
-$$
+\end{doxymath}
\item A site set, also called the "domain".
\end{itemize}
%**************************
-\doxysection{imavalues}{Possible value types}
+\doxysection{imatypes}{Possible image types}
+
+Here is a short list of the main/usual image types you may want to use with
+Olena: \\
+\bigskip
+
+\begin{tabular}{l|l}
+Name & Description \\
+\hline
+image1d & 1D image \\
+image2d & 2D image \\
+image3d & 3D image \\
+flat\_image & Constant value image \\
+image\_if & Image defined by a function \\
+FIXME & FIXME \\
+\end{tabular}
+
+%**************************
+\doxysection{imapossvalues}{Possible value types}
Every image type must take its type of value as parameter.
The value type can be one of the builtins one:
@@ -370,7 +524,7 @@ rgb8.hh.
%----------------
-\subsection{About value, rvalue and lvalue}
+\doxysubsection{imavalues}{About value, rvalue and lvalue}
Since the values are of a specific type, it exists a set of all the possible
site values. This set is called "destination" set. It may be iterable and
@@ -632,7 +786,7 @@ case will be detailed further in section \ref{iterators}.
-%================================================
+s%================================================
\doxysection{imasize}{Image size}
Most typical image types owns special methods to retrieve the image size.
@@ -661,13 +815,128 @@ Output:
%====================================
\clearpage
\newpage
-\doxychapter{winneigh}{Window and neighborhood}
+\doxychapter{winneigh}{Structural elements: Window and neighborhood}
-%**************************
-\doxysection{winfixme}{FIXME}
-FIXME
+In Olena, there are both the window and neighborhood concept. A window can be
+defined on any sites around a central site which may also be included.
+A neighborhood is more restrictive and must not include the central site.
+Therefore these two concepts are really similar and are detailed together in
+this section.
-\doxycode{ima2d-display-1}
+By default, structural elements are centered. The central site is located at the
+origin of the grid: ``literal::origin''. With image2d, the central site is
+(0,0).
+
+
+\doxysection{sedef}{Define an element}
+
+\doxysubsection{winwin}{Window}
+
+\subsubsection*{Generic Predefined windows}
+
+\begin{tabular}{l|l|l}
+Name & Description & Representation \\
+\hline
+win\_c4p & 4-connectivity & \wincfour \\
+win\_c8p & 8-connectivity & \winceight \\
+\end{tabular}
+%
+\bigskip
+%
+
+\subsubsection*{1D Predefined windows}
+
+\begin{tabular}{l|l|l}
+Name & Description & Representation \\
+\hline
+segment1d & 1D segment & - \\
+\end{tabular}
+%
+\bigskip
+%
+
+\subsubsection*{2D Predefined windows}
+
+\begin{tabular}{l|l|l}
+Name & Description & Representation \\
+\hline
+backdiag2d & Back diagonal & - \\
+diag2d & 2D diagonal & - \\
+disk2d & 2D disk & - \\
+hline2d & 2D horizontal line & - \\
+octagon2d & 2D octogon & - \\
+rectangle2d & 2D rectangle & - \\
+vline2d & 2D vertical line & - \\
+\end{tabular}
+%
+\bigskip
+%
+
+\subsubsection*{3D Predefined windows}
+
+\begin{tabular}{l|l|l}
+Name & Description & Representation \\
+\hline
+cube3d & 3D Cube & - \\
+cuboid3d & Cuboid & - \\
+\end{tabular}
+
+These predefined windows can be passed directly to a function. The headers are
+located in mln/core/alias/window*.hh.
+
+
+
+\doxysubsection{neighborhood}{Neighborhood}
+
+Predefined neighborhood:\\
+
+\begin{tabular}{l|l|l}
+Name & Description & Representation \\
+\hline
+c4 & 4-connectivity & \neighcfour \\
+c8 & 8-connectivity & \neighceight \\
+\end{tabular}
+
+These predefined neighborhood can be passed directly to a function. The headers are
+located in mln/core/alias/neigh*.hh.
+
+Use case example:
+\doxycode{ima2d-decl-2-blobs}
+
+\doxysubsection{customse}{Custom structural elements}
+
+\subsubsection{Windows}
+
+There are several ways to define a new window.
+The first and the most common way is to declare a window variable and insert
+dpoints:
+\doxycode{win-create-1}
+This code creates the following window where ``X'' is the central point from
+which the window is computed:
+\doxycode{win-create-1-display}
+
+Another way to define the same window is to provide a bool array:
+\doxycode{win-create-2}
+
+Note that ``win'' == ``win2''.
+The boolean array must always have an odd size.
+While creating a windows thanks to a bool array/matrix, the window's center is the
+central site of the array/matrix.
+
+
+\subsubsection{Neighborhood}
+
+
+\doxysubsection{sitedepse}{Site dependent structural elements}
+
+\doxysubsection{convneighwin}{Conversion between Neighborhoods and Windows}
+
+Windows are not convertible to a Neighborhood.
+Neighborhood are convertible to a window though.
+
+A neighborhood has a method ``win()'' which returns the definition window.
+Be ware that this window is not centered, thus does not include the central
+point.
@@ -767,14 +1036,24 @@ owns the method "coord row() const" which is defined as
"return exact(this)-$>$to\_site().row()"
%**************************
-\doxysection{sitesdpoint}{Need for dpoint}
-//FIXME
+\doxysection{sitesdpoint}{Dpoint}
+Dpoints are relative sites. They are usually used in window and neighborhood
+definitions. Since the central site is not constant, windows and neighborhoods
+must be recomputed and dpoints help in doing that.
+
+\doxycode{dpoint-1}
+Output:
+\doxycode{dpoint-1-output}
%====================================
\clearpage
\newpage
+%Ugly workaround to avoid missing chapter references in doxygen.
+\begin{htmlonly}
+\doxychapter{1}{}
+\end{htmlonly}
\doxychapter{iterators}{Iterators}
Each container object in Olena like site sets or images have iterators.
@@ -1009,7 +1288,7 @@ image. \\
level::compute() & compute an accumulator on the values of an image. \\
\end{tabular}
-\subsection{Accumulators}
+\doxysubsection{accu}{Accumulators}
An accumulator is a special object accumulating data while iterating all over
the image values or sites. Hereby follows a list of accumulators available in
Olena.
@@ -1074,7 +1353,7 @@ You cannot write:
Instead, you must write:
\doxycode{accu-right-instanciation}
-\subsection{Example with labeling::compute()}
+\doxysubsection{exlblcompute}{Example with labeling::compute()}
In this example we will try to retrieve the bounding box of each component in an
image.
@@ -1100,8 +1379,8 @@ set the background to 0, we will want to iterate from 1 to nlabels included.
Output:
\doxycode{labeling-compute-result-output}
-\subsection{Routines based on accumulators and *::compute()}
+\subsection{Routines based on accumulators and *::compute()}
In order to make the code cleaner, small routines are available for the
most used accumulators.
@@ -1218,6 +1497,8 @@ site set.
%====================================
\newpage
\clearpage
+%Ugly workaround to avoid missing chapter references in doxygen.
+\doxychapter{2}{}
\doxychapter{graphandima}{Graphes and images}
FIXME: REWRITE
@@ -1393,4 +1674,26 @@ FIXME write it
FIXME write it
+%====================================
+\newpage
+\clearpage
+\doxychapter{globalvars}{Useful global variables}
+
+\begin{tabular}{l|p{8cm}|l}
+\hline
+Name & Description & Possible values \\
+\hline
+literal::zero & Generic zero value. Can be used with various types such as
+util::vec, dpoint\dots & n.a.\\
+& & \\
+literal::one & Generic one value. Can be used with various types such as
+util::vec, dpoint\dots & n.a.\\
+& & \\
+literal::origin & Generic value for the origin point on a grid.& n.a.\\
+& & \\
+border::thickness & Set the default border thickness of images & $[0-UINT_MAX]$\\
+& & \\
+trace::quiet & Enable trace printing & true/false \\
+\end{tabular}
+
\end{document}
--
1.5.6.5
1
0