Commit ae5b2f20 authored by Roland Levillain's avatar Roland Levillain
Browse files

Miscellaneous changes in mesh-related operations.

	* mln/topo/is_simple_cell.hh: Add static preconditions.
	Reduce the number of pointer manipulations.
	Aesthetic changes.
	* mln/topo/detach_cell.hh: Move a static precondition.
	Aesthetic changes.
	* mln/io/vtk/save.hh: Cosmetic changes.
parent aa7f3d1c
2011-03-14 Roland Levillain <roland@lrde.epita.fr>
Miscellaneous changes in mesh-related operations.
* mln/topo/is_simple_cell.hh: Add static preconditions.
Reduce the number of pointer manipulations.
Aesthetic changes.
* mln/topo/detach_cell.hh: Move a static precondition.
Aesthetic changes.
* mln/io/vtk/save.hh: Cosmetic changes.
2011-03-14 Roland Levillain <roland@lrde.epita.fr>
 
New apps: max curvature-based thinnings using 2- and 1-collapses.
// Copyright (C) 2008, 2009, 2010 EPITA Research and Development
// Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
......@@ -269,7 +269,7 @@ namespace mln
/* ``1. The first part is the file version and
identifier. This part contains the single line:
# vtk DataFile Version x.x.
# vtk DataFile Version x.x.
This line must be exactly as shown with the
exception of the version number x.x, which will vary
......@@ -492,6 +492,10 @@ namespace mln
ostr << std::endl;
}
// -------------------- //
// Dataset attributes. //
// -------------------- //
/* ``5. The final part describes the dataset attributes.
This part begins with the keywords POINT_DATA or
CELL_DATA,followed by an integer number specifying
......
......@@ -30,10 +30,15 @@
/// \file
/// \brief Detaching a cell from a binary (probably complex-based) image.
# include <mln/core/concept/function.hh>
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/site_set/p_set.hh>
# include <mln/core/image/complex_image.hh>
# include <mln/make/detachment.hh>
namespace mln
{
......@@ -66,7 +71,7 @@ namespace mln
\pre \a ima is an image of Boolean values.
\param ima The input image from which the cell is to be
detached.
detached.
\param nbh An adjacency relationship between faces
(should return the set of (n-1)- and (n+1)-faces
adjacent to an n-face). */
......@@ -80,14 +85,10 @@ namespace mln
\pre \a ima is an image of Boolean values. */
void set_image(mln::Image<I>& ima);
/** Detach the cell corresponding to \a f from \a ima.
/** Detach the cell corresponding to \a f from \a ima_.
\param f The psite corresponding to the cell to detach.
\param nbh An adjacency relationship between faces
(should return the set of (n-1)- and (n+1)-faces
adjacent to an n-face). */
void
operator()(const mln_psite(I)& f);
\param f The psite corresponding to the cell to detach. */
void operator()(const mln_psite(I)& f);
private:
I* ima_;
......@@ -95,6 +96,7 @@ namespace mln
};
# ifndef MLN_INCLUDE_ONLY
template <typename I, typename N>
......@@ -102,6 +104,7 @@ namespace mln
detach_cell<I, N>::detach_cell(const Neighborhood<N>& nbh)
: ima_(0), nbh_(exact(nbh))
{
mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N>
......@@ -118,7 +121,6 @@ namespace mln
void
detach_cell<I, N>::set_image(mln::Image<I>& ima)
{
mlc_equal(mln_value(I), bool)::check();
ima_ = exact(&ima);
}
......
......@@ -34,15 +34,15 @@
# include <mln/core/concept/image.hh>
# include <mln/core/site_set/p_set.hh>
# include <mln/core/site_set/complex_psite.hh>
# include <mln/core/site_set/p_complex_piter.hh>
# include <mln/core/image/complex_neighborhoods.hh>
# include <mln/core/image/complex_neighborhood_piter.hh>
# include <mln/topo/is_facet.hh>
# include <mln/make/attachment.hh>
// FIXME: Have the functor take N, NL and NH neighborhood objects at
// the construction (instead of building them in operator()), as in
// does is_simple_pair.
namespace mln
{
......@@ -69,7 +69,8 @@ namespace mln
\tparam NH The neighborhood type returning the set of
(n+1)-faces adjacent to a an n-face. */
template <typename I, typename N, typename NL, typename NH>
class is_simple_cell : public mln::Function_v2b< is_simple_cell<I, N, NL, NH> >
class is_simple_cell
: public mln::Function_v2b< is_simple_cell<I, N, NL, NH> >
{
public:
/// Result type of the functor.
......@@ -108,6 +109,7 @@ namespace mln
is_simple_cell<I, N, NL, NH>::is_simple_cell()
: ima_(0)
{
mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N, typename NL, typename NH>
......@@ -115,6 +117,7 @@ namespace mln
is_simple_cell<I, N, NL, NH>::is_simple_cell(const mln::Image<I>& ima)
: ima_(exact(&ima))
{
mlc_equal(mln_value(I), bool)::check();
}
template <typename I, typename N, typename NL, typename NH>
......@@ -131,23 +134,24 @@ namespace mln
is_simple_cell<I, N, NL, NH>::operator()(const mln_psite(I)& p) const
{
mln_precondition(ima_);
// FIXME: Introduce `const I& ima = *ima_;' and use it instead of
// `ima_'. Or introduce an `ima()' accessor?
// Shortcut.
// FIXME: Introduce an `ima()' accessor instead?
const I& ima = *ima_;
// The cell corresponding to P cannot be simple unless P is
// facet.
{
NH higher_adj_nbh;
if (!is_facet(*ima_, p, higher_adj_nbh))
if (!is_facet(ima, p, higher_adj_nbh))
return false;
}
typedef p_set<mln_psite(I)> faces_t;
// Compute the attachment of the cell corresponding to P to the
// domain of *IMA_.
// domain of IMA.
N adj_nbh;
faces_t att = make::attachment(*ima_, p, adj_nbh);
faces_t att = make::attachment(ima, p, adj_nbh);
// A cell with an empty attachment is not simple.
/* FIXME: Why p_set does not provide an empty() predicate? */
......
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