Commit 1f09a450 authored by Roland Levillain's avatar Roland Levillain
Browse files

Add a missing (disabled) conversion method to

	mln::any_face_handle.

	* mln/core/complex.hh: Make mln::any_face_handle a friend of
	mln::complex.
	* mln/core/face.hh (mln::any_face_handle<D>::to_face<N>):
	New method.
	Exercise it...
	* tests/core/complex.cc: ...here.
	Check conversion from handles to face data.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@2146 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 07263f66
2008-08-12 Roland Levillain <roland@lrde.epita.fr>
Add a missing (disabled) conversion method to
mln::any_face_handle.
* mln/core/complex.hh: Make mln::any_face_handle a friend of
mln::complex.
* mln/core/face.hh (mln::any_face_handle<D>::to_face<N>):
New method.
Exercise it...
* tests/core/complex.cc: ...here.
Check conversion from handles to face data.
2008-08-12 Roland Levillain <roland@lrde.epita.fr>
Add a printing operator for mln::complex_psite.
......
......@@ -118,6 +118,7 @@ namespace mln
/// Accessors.
/// \{
template <unsigned N, unsigned D_> friend class face_handle;
template <unsigned D_> friend class any_face_handle;
template <unsigned N>
face<N, D>& face_(unsigned face_id);
......
......@@ -279,10 +279,9 @@ namespace mln
/// Return the id of the face.
unsigned face_id() const;
// FIXME: Implement.
// /// Return the mln::face pointed by this handle.
// template <unsigned N>
// face<N, D>& to_face() const;
/// Return the mln::face pointed by this handle.
template <unsigned N>
face<N, D>& to_face() const;
/// \}
private:
......@@ -564,15 +563,15 @@ namespace mln
return face_id_;
}
// template <unsigned D>
// template <unsigned n>
// face<N, D>&
// any_face_handle<D>::to_face() const
// {
// // FIXME: Adjust.
// // mln_precondition(is_valid());
// // return cplx_->template face_<N>(face_id_);
// }
template <unsigned D>
template <unsigned N>
face<N, D>&
any_face_handle<D>::to_face() const
{
mln_precondition(n_ == N);
mln_precondition(is_valid());
return cplx_->template face_<N>(face_id_);
}
template <unsigned D>
......
......@@ -49,43 +49,64 @@ int main()
o-----------o v1----e2----v2
v1 e2 v2
v = vertex
e = edge
t = triangle
v = vertex (0-face)
e = edge (1-face)
t = triangle (2-face)
*/
complex<2> c;
const unsigned D = 2;
/*-----------------------.
| Complex construction. |
`-----------------------*/
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);
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;
std::cout
<< "Using ``static'' manipulators." << std::endl
<< " number of 0-faces: c.nfaces<0>() = " << c.nfaces<0>() << std::endl
<< " number of 1-faces: c.nfaces<1>() = " << c.nfaces<1>() << std::endl
<< " number of 2-faces: c.nfaces<2>() = " << c.nfaces<2>() << std::endl
<< " total number of faces: c.nfaces() = " << c.nfaces() << std::endl
<< std::endl;
std::cout
<< "Using ``dynamic'' manipulators." << std::endl
<< " number of 0-faces: c.nfaces(0) = " << c.nfaces(0) << std::endl
<< " number of 1-faces: c.nfaces(1) = " << c.nfaces(1) << std::endl
<< " number of 2-faces: c.nfaces(2) = " << c.nfaces(2) << std::endl;
/*-------------------.
| Handles and data. |
`-------------------*/
// Get the face data from (``static'') face handle E0.
const face<1, D>& face1 = e0.to_face();
// Any-face handle.
any_face_handle<D> af(e0);
// Get the face data from (``dynamic'') face handle AF.
const face<1, D>& face2 = af.to_face<1>();
mln_assertion(&face1 == &face2);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment