https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add actual complex-based psite and pset and give new names to
faces-related entities.
* mln/core/complex_psite.hh: Rename as...
* mln/core/faces_psite.hh: ...this.
(mln::complex_psite<P, N, D>): Turn into...
(mln::faces_psite<N, D, P>): ...this.
* mln/core/p_complex.hh: Rename as...
* mln/core/p_faces.hh: ...this.
(mln::p_complex<P, N, D>): Turn into...
(mln::p_faces<N, D, P>): ...this.
* mln/core/complex_psite.hh, mln/core/p_complex.hh: New.
* tests/core/complex.cc: Exercise the variants of
mln::complex<D>::nfaces().
* tests/core/p_complex.cc: Rename as...
* tests/core/complex_image.cc: ...this.
Exercise mln::p_complex, mln::complex_psite, and mln::faces_psite.
* tests/core/Makefile.am (check_PROGRAMS):
s/p_complex/complex_image/.
(p_complex_SOURCES): Likewise.
Rename as...
(complex_image_SOURCES): ...this.
mln/core/complex_psite.hh | 101 +++++++++++++++++++-----------------------
mln/core/faces_psite.hh | 104 +++++++++++++++++++++-----------------------
mln/core/p_complex.hh | 68 ++++++++++++++++------------
mln/core/p_faces.hh | 90 +++++++++++++++++++++-----------------
tests/core/Makefile.am | 4 -
tests/core/complex.cc | 13 +++++
tests/core/complex_image.cc | 83 +++++++++++++++++++++++++----------
7 files changed, 260 insertions(+), 203 deletions(-)
Index: tests/core/complex.cc
--- tests/core/complex.cc (revision 2127)
+++ tests/core/complex.cc (working copy)
@@ -75,4 +75,17 @@
face_handle<2, 2> t1 = c.add_face(e1 + e3 + e4);
std::cout << c << std::endl;
+
+ std::cout << "``Static'' manipulators." << std::endl;
+ std::cout << " number of 0-faces: " << c.nfaces<0>()
<< std::endl;
+ std::cout << " number of 1-faces: " << c.nfaces<1>()
<< std::endl;
+ std::cout << " number of 2-faces: " << c.nfaces<2>()
<< std::endl;
+ std::cout << " total number of faces: " << c.nfaces() <<
std::endl;
+
+ std::cout << std::endl;
+
+ std::cout << "``Dynamic'' manipulators." << std::endl;
+ std::cout << " number of 0-faces: " << c.nfaces(0) <<
std::endl;
+ std::cout << " number of 1-faces: " << c.nfaces(1) <<
std::endl;
+ std::cout << " number of 2-faces: " << c.nfaces(2) <<
std::endl;
}
Index: tests/core/complex_image.cc
--- tests/core/complex_image.cc (revision 2123)
+++ tests/core/complex_image.cc (working copy)
@@ -25,16 +25,18 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/// \file tests/core/p_complex.cc
-/// \brief Test of mln::p_complex.
+/// \file tests/core/complex_image.cc
+/// \brief Test of mln::complex_image.
#include <iostream>
-#include <mln/core/p_complex.hh>
#include <mln/core/point2d.hh>
+// #include <mln/core/complex_image.hh>
+#include <mln/core/p_faces.hh>
+#include <mln/core/p_complex.hh>
+
-// FIXME: Extend this test and rename it as complex_image.cc.
int main()
{
@@ -62,34 +64,71 @@
*/
- complex<2> c;
+ const unsigned D = 2;
+
+ complex<D> c;
// 0-faces (points).
- face_handle<0, 2> v0 = c.add_face();
- face_handle<0, 2> v1 = c.add_face();
- face_handle<0, 2> v2 = c.add_face();
- face_handle<0, 2> v3 = c.add_face();
+ face_handle<0, D> v0 = c.add_face();
+ face_handle<0, D> v1 = c.add_face();
+ face_handle<0, D> v2 = c.add_face();
+ face_handle<0, D> v3 = c.add_face();
// 1-faces (segments).
- face_handle<1, 2> e0 = c.add_face(v0 + v1);
- face_handle<1, 2> e1 = c.add_face(v0 + v2);
- face_handle<1, 2> e2 = c.add_face(v1 + v2);
- face_handle<1, 2> e3 = c.add_face(v0 + v3);
- face_handle<1, 2> e4 = c.add_face(v2 + v3);
+ face_handle<1, D> e0 = c.add_face(v0 + v1);
+ face_handle<1, D> e1 = c.add_face(v0 + v2);
+ face_handle<1, D> e2 = c.add_face(v1 + v2);
+ face_handle<1, D> e3 = c.add_face(v0 + v3);
+ face_handle<1, D> e4 = c.add_face(v2 + v3);
// 2-faces (triangles).
- face_handle<2, 2> t0 = c.add_face(e0 + e1 + e2);
- face_handle<2, 2> t1 = c.add_face(e1 + e3 + e4);
+ face_handle<2, D> t0 = c.add_face(e0 + e1 + e2);
+ face_handle<2, D> t1 = c.add_face(e1 + e3 + e4);
- /*----------------------.
- | Complex-based psets. |
- `----------------------*/
+ /*---------------------.
+ | Complex-based pset. |
+ `---------------------*/
+
+ // A pset.
+ p_complex<D, point2d> pc0(c);
+ // An any-face handle (on E0)
+ any_face_handle<D> af(c, 1, 0);
+ // An associated psite.
+ complex_psite<D, point2d> cs(af);
+
+
+ /*--------------------.
+ | Faces-based psets. |
+ `--------------------*/
// Pset of 0-faces.
- p_complex<point2d, 0, 2> pc0(c);
+ p_faces<0, D, point2d> pf0(c);
// Pset of 1-faces.
- p_complex<point2d, 1, 2> pc1(c);
+ p_faces<1, D, point2d> pf1(c);
// Pset of 2-faces.
- p_complex<point2d, 2, 2> pc2(c);
+ p_faces<2, D, point2d> pf2(c);
+
+ // Some psites on faces.
+ faces_psite<0, D, point2d> fs0(v0);
+ faces_psite<1, D, point2d> fs1(e0);
+ faces_psite<2, D, point2d> fs2(t0);
+
+
+ // FIXME: Enable when complex_image is available.
+#if 0
+ /*----------------------.
+ | Complex-based image. |
+ `----------------------*/
+
+ // An image type built on a 2-complex with mln::int_u8 values on
+ // each face.
+ typedef ima_t complex_image< p_complex<D, point2d>, int_u8>;
+
+ // FIXME: Create and init IMA.
+ // ...
+ ima_t ima(pc2);
+
+ mln_piter_(ima_t) p(ima.domain());
+#endif
}
Property changes on: tests/core/complex_image.cc
___________________________________________________________________
Added: svn:mergeinfo
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 2127)
+++ tests/core/Makefile.am (working copy)
@@ -13,6 +13,7 @@
clock_test \
clone \
complex \
+ complex_image \
\
decorated_image \
dpoint1d \
@@ -51,7 +52,6 @@
\
obased_rle_image \
\
- p_complex \
p_priority_queue \
p_priority_queue_fast \
p_priority_queue_fast_with_array \
@@ -101,6 +101,7 @@
clock_test_SOURCES = clock_test.cc
clone_SOURCES = clone.cc
complex_SOURCES = complex.cc
+complex_image_SOURCES = complex_image.cc
decorated_image_SOURCES = decorated_image.cc
dpoint1d_SOURCES = dpoint1d.cc
@@ -139,7 +140,6 @@
obased_rle_image_SOURCES = obased_rle_image.cc
-p_complex_SOURCES = p_complex.cc
p_priority_queue_SOURCES = p_priority_queue.cc
p_priority_queue_fast_SOURCES = p_priority_queue_fast.cc
p_priority_queue_fast_with_array_SOURCES = p_priority_queue_fast.cc
Index: mln/core/complex_psite.hh
--- mln/core/complex_psite.hh (revision 2127)
+++ mln/core/complex_psite.hh (working copy)
@@ -38,21 +38,16 @@
namespace mln
{
- /* FIXME: Write also a complex_psite where N is dynamic, and can be
- changed? */
+ /* FIXME: Get rid of P? */
- /* FIXME: Currently, P and N are free variables; we might want to
- relate them, e.g., have P::dim == N. Or even get rid of P. */
-
- /// \brief Point site associated to a mln::complex_image.
+ /// \brief Point site associated to a mln::p_complex.
///
+ /// \arg \p D The dimension of the complex this psite belongs to.
/// \arg \p P The type of point associated to this psite.
- /// \arg \p N The dimension of the face associated to this psite.
- /// \arg \p D The dimention of the complex this psite belongs to.
- template <typename P, unsigned N, unsigned D>
- class complex_psite : public Point_Site< complex_psite<P, N, D> >
+ template <unsigned D, typename P>
+ class complex_psite : public Point_Site< complex_psite<D, P> >
{
- typedef complex_psite<P, N, D> self_;
+ typedef complex_psite<D, P> self_;
typedef Point_Site<self_> super_;
public:
@@ -65,7 +60,7 @@
/// Construction and assignment.
/// \{
complex_psite();
- complex_psite(const face_handle<N, D>& face);
+ complex_psite(const any_face_handle<D>& face);
complex_psite(const self_& rhs);
self_& operator= (const self_& rhs);
/// \}
@@ -82,7 +77,7 @@
/// \}
/// Return the face handle of this point site.
- face_handle<N, D> face() const;
+ any_face_handle<D> face() const;
/// Return the complex on which this site is built.
const complex<D>& cplx() const;
@@ -91,7 +86,7 @@
private:
/// The handle of the face this psite is pointing towards.
- face_handle<N, D> face_;
+ any_face_handle<D> face_;
// FIXME: Actually, this is a dummy value!
point p_;
};
@@ -106,10 +101,10 @@
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::complex.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator==(const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs);
+ operator==(const complex_psite<D, P>& lhs,
+ const complex_psite<D, P>& rhs);
/// \brief Is \a lhs ``less'' than \a rhs?
///
@@ -117,51 +112,45 @@
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::complex.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator< (const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs);
+ operator< (const complex_psite<D, P>& lhs,
+ const complex_psite<D, P>& rhs);
/// \}
# ifndef MLN_INCLUDE_ONLY
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
- complex_psite<P, N, D>::complex_psite()
+ complex_psite<D, P>::complex_psite()
: super_(),
// Dummy initializations.
face_(), p_()
{
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
- complex_psite<P, N, D>::complex_psite(const face_handle<N, D>& face)
+ complex_psite<D, P>::complex_psite(const any_face_handle<D>& face)
: super_(),
face_(face), p_()
{
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
- complex_psite<P, N, D>::complex_psite(const complex_psite<P, N, D>&
rhs)
+ complex_psite<D, P>::complex_psite(const complex_psite<D, P>& rhs)
: super_(rhs),
face_(rhs.face_), p_()
{
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
- complex_psite<P, N, D>&
- complex_psite<P, N, D>::operator= (const complex_psite<P, N, D>& rhs)
+ complex_psite<D, P>&
+ complex_psite<D, P>::operator= (const complex_psite<D, P>& rhs)
{
if (&rhs == this)
return *this;
@@ -169,52 +158,52 @@
return *this;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
bool
- complex_psite<P, N, D>::is_valid() const
+ complex_psite<D, P>::is_valid() const
{
- return face.is_valid();
+ return face_.is_valid();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
- const complex_psite<P, N, D>&
- complex_psite<P, N, D>::to_psite() const
+ const complex_psite<D, P>&
+ complex_psite<D, P>::to_psite() const
{
return *this;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
const P&
- complex_psite<P, N, D>::to_point() const
+ complex_psite<D, P>::to_point() const
{
// FIXME: Dummy value.
return p_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
mln_coord(P)
- complex_psite<P, N, D>::operator[](unsigned i) const
+ complex_psite<D, P>::operator[](unsigned i) const
{
mln_precondition(is_valid());
return to_point()[i];
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
- face_handle<N, D>
- complex_psite<P, N, D>::face() const
+ any_face_handle<D>
+ complex_psite<D, P>::face() const
{
return face_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
const complex<D>&
- complex_psite<P, N, D>::cplx() const
+ complex_psite<D, P>::cplx() const
{
return face_.cplx();
}
@@ -223,19 +212,19 @@
| Comparisons. |
`--------------*/
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator==(const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs)
+ operator==(const complex_psite<D, P>& lhs,
+ const complex_psite<D, P>& rhs)
{
mln_precondition(&lhs.cplx() == &rhs.cplx());
return lhs.face() == rhs.face();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator< (const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs)
+ operator< (const complex_psite<D, P>& lhs,
+ const complex_psite<D, P>& rhs)
{
mln_precondition(&lhs.cplx() == &rhs.cplx());
return lhs.face() < rhs.face();
Index: mln/core/faces_psite.hh
--- mln/core/faces_psite.hh (revision 2123)
+++ mln/core/faces_psite.hh (working copy)
@@ -25,11 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_COMPLEX_PSITE_HH
-# define MLN_CORE_COMPLEX_PSITE_HH
+#ifndef MLN_CORE_FACES_PSITE_HH
+# define MLN_CORE_FACES_PSITE_HH
-/// \file mln/core/complex_psite.hh
-/// \brief Definition of a complex-based point site.
+/// \file mln/core/faces_psite.hh
+/// \brief Definition of a point site based on the n-faces of a
+/// complex.
# include <mln/core/concept/point_site.hh>
@@ -38,21 +39,18 @@
namespace mln
{
- /* FIXME: Write also a complex_psite where N is dynamic, and can be
- changed? */
-
/* FIXME: Currently, P and N are free variables; we might want to
relate them, e.g., have P::dim == N. Or even get rid of P. */
- /// \brief Point site associated to a mln::complex_image.
+ /// \brief Point site associated to a mln::p_faces.
///
- /// \arg \p P The type of point associated to this psite.
/// \arg \p N The dimension of the face associated to this psite.
- /// \arg \p D The dimention of the complex this psite belongs to.
- template <typename P, unsigned N, unsigned D>
- class complex_psite : public Point_Site< complex_psite<P, N, D> >
+ /// \arg \p D The dimension of the complex this psite belongs to.
+ /// \arg \p P The type of point associated to this psite.
+ template <unsigned N, unsigned D, typename P>
+ class faces_psite : public Point_Site< faces_psite<N, D, P> >
{
- typedef complex_psite<P, N, D> self_;
+ typedef faces_psite<N, D, P> self_;
typedef Point_Site<self_> super_;
public:
@@ -64,9 +62,9 @@
/// Construction and assignment.
/// \{
- complex_psite();
- complex_psite(const face_handle<N, D>& face);
- complex_psite(const self_& rhs);
+ faces_psite();
+ faces_psite(const face_handle<N, D>& face);
+ faces_psite(const self_& rhs);
self_& operator= (const self_& rhs);
/// \}
@@ -97,7 +95,7 @@
};
- /// Comparison of two instances of mln::complex_psite.
+ /// Comparison of two instances of mln::faces_psite.
/// \{
/* FIXME: Shouldn't those comparisons be part of a much general
mechanism? */
@@ -106,10 +104,10 @@
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::complex.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator==(const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs);
+ operator==(const faces_psite<N, D, P>& lhs,
+ const faces_psite<N, D, P>& rhs);
/// \brief Is \a lhs ``less'' than \a rhs?
///
@@ -117,19 +115,19 @@
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
/// mln::complex.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator< (const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs);
+ operator< (const faces_psite<N, D, P>& lhs,
+ const faces_psite<N, D, P>& rhs);
/// \}
# ifndef MLN_INCLUDE_ONLY
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
- complex_psite<P, N, D>::complex_psite()
+ faces_psite<N, D, P>::faces_psite()
: super_(),
// Dummy initializations.
face_(), p_()
@@ -138,9 +136,9 @@
metal::bool_< N <= D >::check();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
- complex_psite<P, N, D>::complex_psite(const face_handle<N, D>& face)
+ faces_psite<N, D, P>::faces_psite(const face_handle<N, D>& face)
: super_(),
face_(face), p_()
{
@@ -148,9 +146,9 @@
metal::bool_< N <= D >::check();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
- complex_psite<P, N, D>::complex_psite(const complex_psite<P, N, D>&
rhs)
+ faces_psite<N, D, P>::faces_psite(const faces_psite<N, D, P>& rhs)
: super_(rhs),
face_(rhs.face_), p_()
{
@@ -158,10 +156,10 @@
metal::bool_< N <= D >::check();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
- complex_psite<P, N, D>&
- complex_psite<P, N, D>::operator= (const complex_psite<P, N, D>& rhs)
+ faces_psite<N, D, P>&
+ faces_psite<N, D, P>::operator= (const faces_psite<N, D, P>& rhs)
{
if (&rhs == this)
return *this;
@@ -169,52 +167,52 @@
return *this;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
bool
- complex_psite<P, N, D>::is_valid() const
+ faces_psite<N, D, P>::is_valid() const
{
- return face.is_valid();
+ return face_.is_valid();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
- const complex_psite<P, N, D>&
- complex_psite<P, N, D>::to_psite() const
+ const faces_psite<N, D, P>&
+ faces_psite<N, D, P>::to_psite() const
{
return *this;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
const P&
- complex_psite<P, N, D>::to_point() const
+ faces_psite<N, D, P>::to_point() const
{
// FIXME: Dummy value.
return p_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
mln_coord(P)
- complex_psite<P, N, D>::operator[](unsigned i) const
+ faces_psite<N, D, P>::operator[](unsigned i) const
{
mln_precondition(is_valid());
return to_point()[i];
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
face_handle<N, D>
- complex_psite<P, N, D>::face() const
+ faces_psite<N, D, P>::face() const
{
return face_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
const complex<D>&
- complex_psite<P, N, D>::cplx() const
+ faces_psite<N, D, P>::cplx() const
{
return face_.cplx();
}
@@ -223,19 +221,19 @@
| Comparisons. |
`--------------*/
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator==(const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs)
+ operator==(const faces_psite<N, D, P>& lhs,
+ const faces_psite<N, D, P>& rhs)
{
mln_precondition(&lhs.cplx() == &rhs.cplx());
return lhs.face() == rhs.face();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator< (const complex_psite<P, N, D>& lhs,
- const complex_psite<P, N, D>& rhs)
+ operator< (const faces_psite<N, D, P>& lhs,
+ const faces_psite<N, D, P>& rhs)
{
mln_precondition(&lhs.cplx() == &rhs.cplx());
return lhs.face() < rhs.face();
@@ -246,4 +244,4 @@
} // end of mln
-#endif // MLN_CORE_COMPLEX_PSITE_HH
+#endif // MLN_CORE_FACES_PSITE_HH
Property changes on: mln/core/faces_psite.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/core/p_complex.hh
--- mln/core/p_complex.hh (revision 2127)
+++ mln/core/p_complex.hh (working copy)
@@ -43,12 +43,23 @@
namespace mln
{
- /// A complex psite set based on a complex of dimension \p D (a \p
- /// D-complex).
- template<typename P, unsigned N, unsigned D>
+ // FIXME: Rename as p_faces.
+
+ /* FIXME: For compatibility reasons with mln::Point_Set, a point
+ type \P is attached to this complex-based pset (but it is not
+ used actually). We should either:
+
+ - use it, and make it mandatory (good solution for the moment);
+ - use it, and make it optional (better solution, but implies
+ changes in mln::Point_Set;
+ - remove it (easy and bad solution). */
+
+ /// A complex psite set based on a the \N-faces of a complex of
+ /// dimension \p D (a \p D-complex).
+ template <unsigned D, typename P>
struct p_complex
- : public internal::point_set_base_< complex_psite<P, N, D>,
- p_complex<P, N, D> >
+ : public internal::point_set_base_< complex_psite<D, P>,
+ p_complex<D, P> >
{
/// \brief Construct a complex psite set from a complex.
///
@@ -59,7 +70,7 @@
p_complex (const complex<D>& cplx);
/// Point_Site associated type.
- typedef complex_psite<P, N, D> psite;
+ typedef complex_psite<D, P> psite;
// FIXME: Fake.
typedef void fwd_piter;
@@ -94,9 +105,9 @@
///
/// Two mln::p_complex's are considered equal if they share the
/// same complex.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator==(const p_complex<P, N, D>& lhs, const p_complex<P, N, D>&
rhs);
+ operator==(const p_complex<D, P>& lhs, const p_complex<D, P>&
rhs);
/// \brief Inclusion of a mln::p_complex in another one.
///
@@ -106,23 +117,20 @@
///
/// \todo Refine this later, when we are able to express subcomplex
/// relations.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator<=(const p_complex<P, N, D>& lhs, const p_complex<P, N,
D>& rhs);
+ operator<=(const p_complex<D, P>& lhs, const p_complex<D, P>&
rhs);
# ifndef MLN_INCLUDE_ONLY
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
- p_complex<P, N, D>::p_complex(const complex<D>& cplx)
+ p_complex<D, P>::p_complex(const complex<D>& cplx)
// Create a deep, managed copy of CPLX.
: cplx_(new complex<D>(cplx))
{
- // Ensure N is compatible with D.
- metal::bool_< N <= D >::check();
-
// FIXME: Dummy initialization.
accu::bbox<P> a;
for (unsigned i = 0; i < npoints(); ++i)
@@ -130,35 +138,35 @@
bb_ = a.to_result();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
std::size_t
- p_complex<P, N, D>::npoints() const
+ p_complex<D, P>::npoints() const
{
return nfaces();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
std::size_t
- p_complex<P, N, D>::nfaces() const
+ p_complex<D, P>::nfaces() const
{
- return this->cplx_->template nfaces<N>();
+ return cplx_->nfaces();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
const box_<P>&
- p_complex<P, N, D>::bbox() const
+ p_complex<D, P>::bbox() const
{
// FIXME: Dummy value.
return bb_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
inline
bool
- p_complex<P, N, D>::has(const psite& p) const
+ p_complex<D, P>::has(const psite& p) const
{
return
// Check whether P's complex is compatible with this pset's complex.
@@ -168,25 +176,25 @@
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
const complex<D>&
- p_complex<P, N, D>::cplx() const
+ p_complex<D, P>::cplx() const
{
mln_precondition(cplx_);
return *cplx_.ptr_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator==(const p_complex<P, N, D>& lhs, const p_complex<P, N, D>&
rhs)
+ operator==(const p_complex<D, P>& lhs, const p_complex<D, P>& rhs)
{
return lhs.cplx_.ptr_ == rhs.cplx_.ptr_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned D, typename P>
bool
- operator<=(const p_complex<P, N, D>& lhs, const p_complex<P, N,
D>& rhs)
+ operator<=(const p_complex<D, P>& lhs, const p_complex<D, P>&
rhs)
{
return lhs == rhs;
}
Index: mln/core/p_faces.hh
--- mln/core/p_faces.hh (revision 2123)
+++ mln/core/p_faces.hh (working copy)
@@ -25,11 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_P_COMPLEX_HH
-# define MLN_CORE_P_COMPLEX_HH
+#ifndef MLN_CORE_P_FACES_HH
+# define MLN_CORE_P_FACES_HH
-/// \file mln/core/p_complex.hh
-/// \brief Definition of a point set based on a complex.
+/// \file mln/core/p_faces.hh
+/// \brief Definition of a point set based on the set of n-faces of a
+/// complex.
# include <mln/core/internal/point_set_base.hh>
@@ -37,18 +38,27 @@
# include <mln/util/tracked_ptr.hh>
# include <mln/core/complex.hh>
-# include <mln/core/complex_psite.hh>
+# include <mln/core/faces_psite.hh>
namespace mln
{
- /// A complex psite set based on a complex of dimension \p D (a \p
- /// D-complex).
- template<typename P, unsigned N, unsigned D>
- struct p_complex
- : public internal::point_set_base_< complex_psite<P, N, D>,
- p_complex<P, N, D> >
+ /* FIXME: For compatibility reasons with mln::Point_Set, a point
+ type \P is attached to this complex-based pset (but it is not
+ used actually). We should either:
+
+ - use it, and make it mandatory (good solution for the moment);
+ - use it, and make it optional (better solution, but implies
+ changes in mln::Point_Set;
+ - remove it (easy and bad solution). */
+
+ /// A complex psite set based on a the \N-faces of a complex of
+ /// dimension \p D (a \p D-complex).
+ template <unsigned N, unsigned D, typename P>
+ struct p_faces
+ : public internal::point_set_base_< faces_psite<N, D, P>,
+ p_faces<N, D, P> >
{
/// \brief Construct a complex psite set from a complex.
///
@@ -56,10 +66,10 @@
///
/// \a gr is \em copied internally, so that the complex psite set is
/// still valid after the initial complex has been removed.
- p_complex (const complex<D>& cplx);
+ p_faces (const complex<D>& cplx);
/// Point_Site associated type.
- typedef complex_psite<P, N, D> psite;
+ typedef faces_psite<N, D, P> psite;
// FIXME: Fake.
typedef void fwd_piter;
@@ -79,7 +89,7 @@
bool has(const psite& p) const;
- /// Return the complex associated to the p_complex domain.
+ /// Return the complex associated to the p_faces domain.
const complex<D>& cplx() const;
private:
@@ -90,33 +100,33 @@
};
- /// \brief Comparison between two mln::p_complex's.
+ /// \brief Comparison between two mln::p_faces's.
///
- /// Two mln::p_complex's are considered equal if they share the
+ /// Two mln::p_faces's are considered equal if they share the
/// same complex.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator==(const p_complex<P, N, D>& lhs, const p_complex<P, N, D>&
rhs);
+ operator==(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>&
rhs);
- /// \brief Inclusion of a mln::p_complex in another one.
+ /// \brief Inclusion of a mln::p_faces in another one.
///
/// This inclusion relation is very strict for the moment, since our
- /// infrastrure for complexs is simple: a mln::p_complex is included
+ /// infrastrure for complexs is simple: a mln::p_faces is included
/// in another one if their are equal.
///
/// \todo Refine this later, when we are able to express subcomplex
/// relations.
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator<=(const p_complex<P, N, D>& lhs, const p_complex<P, N,
D>& rhs);
+ operator<=(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>&
rhs);
# ifndef MLN_INCLUDE_ONLY
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
- p_complex<P, N, D>::p_complex(const complex<D>& cplx)
+ p_faces<N, D, P>::p_faces(const complex<D>& cplx)
// Create a deep, managed copy of CPLX.
: cplx_(new complex<D>(cplx))
{
@@ -130,35 +140,35 @@
bb_ = a.to_result();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
std::size_t
- p_complex<P, N, D>::npoints() const
+ p_faces<N, D, P>::npoints() const
{
return nfaces();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
std::size_t
- p_complex<P, N, D>::nfaces() const
+ p_faces<N, D, P>::nfaces() const
{
- return this->cplx_->template nfaces<N>();
+ return cplx_->template nfaces<N>();
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
const box_<P>&
- p_complex<P, N, D>::bbox() const
+ p_faces<N, D, P>::bbox() const
{
// FIXME: Dummy value.
return bb_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
inline
bool
- p_complex<P, N, D>::has(const psite& p) const
+ p_faces<N, D, P>::has(const psite& p) const
{
return
// Check whether P's complex is compatible with this pset's complex.
@@ -168,25 +178,25 @@
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
const complex<D>&
- p_complex<P, N, D>::cplx() const
+ p_faces<N, D, P>::cplx() const
{
mln_precondition(cplx_);
return *cplx_.ptr_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator==(const p_complex<P, N, D>& lhs, const p_complex<P, N, D>&
rhs)
+ operator==(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>&
rhs)
{
return lhs.cplx_.ptr_ == rhs.cplx_.ptr_;
}
- template <typename P, unsigned N, unsigned D>
+ template <unsigned N, unsigned D, typename P>
bool
- operator<=(const p_complex<P, N, D>& lhs, const p_complex<P, N,
D>& rhs)
+ operator<=(const p_faces<N, D, P>& lhs, const p_faces<N, D, P>&
rhs)
{
return lhs == rhs;
}
@@ -196,4 +206,4 @@
} // end of mln
-#endif // MLN_CORE_P_COMPLEX_HH
+#endif // MLN_CORE_P_FACES_HH