$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
graph/attribute/card.hh
1
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
2
//
3
// This file is part of Olena.
4
//
5
// Olena is free software: you can redistribute it and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, version 2 of the License.
8
//
9
// Olena is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
16
//
17
// As a special exception, you may use this file as part of a free
18
// software project without restriction. Specifically, if other files
19
// instantiate templates or use macros or inline functions from this
20
// file, or you compile this file and link it with other files to produce
21
// an executable, this file does not by itself cause the resulting
22
// executable to be covered by the GNU General Public License. This
23
// exception does not however invalidate any other reasons why the
24
// executable file might be covered by the GNU General Public License.
25
26
#ifndef MLN_GRAPH_ATTRIBUTE_CARD_HH
27
# define MLN_GRAPH_ATTRIBUTE_CARD_HH
28
33
34
35
# include <mln/core/concept/graph.hh>
36
# include <mln/util/array.hh>
37
38
39
namespace
mln
40
{
41
42
namespace
graph
43
{
44
45
namespace
attribute
46
{
47
49
struct
card_t;
50
52
extern
card_t
card
;
53
54
55
# ifndef MLN_INCLUDE_ONLY
56
61
struct
card_t
62
{
64
typedef
util::array<unsigned>
result;
65
66
template
<
typename
G>
67
void
init(
const
Graph<G>
& g)
68
{
69
data
.resize(0);
70
deja_vu_.resize(
exact
(g).v_nmax());
71
deja_vu_.fill(
false
);
72
comp = 0;
73
}
74
75
bool
to_be_treated(
unsigned
id
)
76
{
return
!deja_vu_[
id
]; }
77
78
void
new_component_from_vertex(
unsigned
id
)
79
{
80
data
.append(1);
81
deja_vu_[
id
] =
true
;
82
}
83
84
void
process_vertex(
unsigned
)
85
{}
86
87
bool
to_be_queued(
unsigned
id
)
88
{
return
!deja_vu_[
id
]; }
89
90
void
added_to_queue(
unsigned
id
)
91
{
92
deja_vu_[
id
] =
true
;
93
++
data
[comp];
94
}
95
96
void
next_component()
97
{ ++comp; }
98
99
void
final
()
100
{}
101
102
unsigned
comp;
103
util::array<bool>
deja_vu_;
104
util::array<unsigned>
data
;
105
};
106
107
card_t
card
;
108
109
# endif // ! MLN_INCLUDE_ONLY
110
111
112
}
// end of namespace mln::graph::attribute
113
114
}
// end of namespace mln::graph
115
116
}
// end of namespace mln
117
118
119
#endif // ! MLN_GRAPH_ATTRIBUTE_CARD_HH
mln
graph
attribute
card.hh
Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)