$extrastylesheet
Olena
User documentation 2.1
An Image Processing Platform
Milena
Getting started
API Reference Manual
All Classes
Examples
Demos
Publications
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
detach_cell.hh
1
// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
2
// Laboratory (LRDE)
3
//
4
// This file is part of Olena.
5
//
6
// Olena is free software: you can redistribute it and/or modify it under
7
// the terms of the GNU General Public License as published by the Free
8
// Software Foundation, version 2 of the License.
9
//
10
// Olena is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
17
//
18
// As a special exception, you may use this file as part of a free
19
// software project without restriction. Specifically, if other files
20
// instantiate templates or use macros or inline functions from this
21
// file, or you compile this file and link it with other files to produce
22
// an executable, this file does not by itself cause the resulting
23
// executable to be covered by the GNU General Public License. This
24
// exception does not however invalidate any other reasons why the
25
// executable file might be covered by the GNU General Public License.
26
27
#ifndef MLN_TOPO_DETACH_CELL_HH
28
# define MLN_TOPO_DETACH_CELL_HH
29
32
33
# include <mln/core/concept/function.hh>
34
# include <mln/core/concept/image.hh>
35
# include <mln/core/concept/neighborhood.hh>
36
37
# include <mln/core/site_set/p_set.hh>
38
39
# include <mln/make/detachment.hh>
40
41
42
namespace
mln
43
{
44
45
namespace
topo
46
{
47
55
template
<
typename
I,
typename
N>
56
class
detach_cell
57
{
58
public
:
61
66
detach_cell
(
const
Neighborhood<N>
& nbh);
67
78
detach_cell
(
mln::Image<I>
& ima,
const
Neighborhood<N>
& nbh);
80
81
/* FIXME: Rename as init() or something like this? See how other
82
functors are written. */
86
void
set_image
(
mln::Image<I>
& ima);
87
91
void
operator()
(
const
mln_psite(I)& f);
92
93
private
:
94
I* ima_;
95
const
N& nbh_;
96
};
97
98
99
100
# ifndef MLN_INCLUDE_ONLY
101
102
template
<
typename
I,
typename
N>
103
inline
104
detach_cell<I, N>::detach_cell
(
const
Neighborhood<N>
& nbh)
105
: ima_(0), nbh_(
exact
(nbh))
106
{
107
mlc_equal(mln_value(I),
bool
)::check();
108
}
109
110
template
<
typename
I,
typename
N>
111
inline
112
detach_cell<I, N>::detach_cell
(
mln::Image<I>
& ima,
113
const
Neighborhood<N>
& nbh)
114
: ima_(
exact
(&ima)), nbh_(
exact
(nbh))
115
{
116
mlc_equal(mln_value(I),
bool
)::check();
117
}
118
119
template
<
typename
I,
typename
N>
120
inline
121
void
122
detach_cell<I, N>::set_image
(
mln::Image<I>
& ima)
123
{
124
ima_ =
exact
(&ima);
125
}
126
127
template
<
typename
I,
typename
N>
128
inline
129
void
130
detach_cell<I, N>::operator()
(
const
mln_psite(I)& f)
131
{
132
mln_precondition(ima_);
133
134
typedef
p_set<mln_psite(I)> faces_t;
135
136
// Compute the detachment of P from *IMA_.
137
faces_t detach =
make::detachment
(*ima_, f, nbh_);
138
// Detach all its faces from *IMA_.
139
# if 0
140
// FIXME: Does not work yet? Check again.
141
data::fill
(*ima_ | detach,
false
);
142
# endif
143
mln_piter(faces_t)
p
(detach);
144
for_all(
p
)
145
(*ima_)(
p
) = false;
146
}
147
148
# endif // MLN_INCLUDE_ONLY
149
150
}
// end of namespace mln::topo
151
152
}
// end of namespace mln
153
154
#endif // ! MLN_TOPO_DETACH_CELL_HH
mln
topo
detach_cell.hh
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)