DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
EstimatorCache.h
1
16
17
#pragma once
18
30
31
#if defined(EstimatorCache_RECURSES)
32
#error Recursive header files inclusion detected in EstimatorCache.h
33
#else
// defined(EstimatorCache_RECURSES)
35
#define EstimatorCache_RECURSES
36
37
#if !defined EstimatorCache_h
39
#define EstimatorCache_h
40
42
// Inclusions
43
#include <iostream>
44
#include <map>
45
#include "DGtal/base/Common.h"
46
#include "DGtal/base/Alias.h"
47
#include "DGtal/geometry/surfaces/estimation/CSurfelLocalEstimator.h"
49
50
namespace
DGtal
51
{
52
54
// template class EstimatorCache
74
template
<
typename
TEstimator,
75
typename
TContainer = std::map<
typename
TEstimator::Surfel,
76
typename
TEstimator::Quantity> >
77
class
EstimatorCache
78
{
79
// ----------------------- Standard services ------------------------------
80
public
:
81
82
84
typedef
TEstimator
Estimator
;
85
BOOST_CONCEPT_ASSERT
((
concepts::CSurfelLocalEstimator<TEstimator>
));
86
88
typedef
TContainer
Container
;
89
BOOST_CONCEPT_ASSERT
((
boost::PairAssociativeContainer<TContainer>
));
90
91
//Concept of CSurfelLocalEstimator
92
94
typedef
typename
Estimator::Surfel
Surfel
;
95
97
typedef
typename
Estimator::Quantity
Quantity
;
98
100
typedef
EstimatorCache<Estimator,Container>
Self
;
101
105
EstimatorCache
():
myInit
(false)
106
{}
107
112
EstimatorCache
(
Alias<Estimator>
anEstimator):
myEstimator
(&anEstimator),
113
myInit
(false)
114
{}
115
119
~EstimatorCache
()
120
{}
121
125
EstimatorCache
(
const
Self
&other):
myContainer
(other.
myContainer
),
126
myEstimator
(other.
myEstimator
),
127
myInit
(other.
myInit
)
128
{}
129
136
Self
&
operator=
(
const
Self
& other )
137
{
138
myContainer
= other.
myContainer
;
139
myEstimator
= other.
myEstimator
;
140
myInit
= other.
myInit
;
141
142
return
*
this
;
143
}
144
145
// ----------------------- CSurfelLocalEstimator Interface --------------------------------------
146
157
template
<
typename
SurfelConstIterator>
158
void
init
(
const
double
aH, SurfelConstIterator itb, SurfelConstIterator ite)
159
{
160
ASSERT(
myEstimator
);
161
myEstimator
->init(aH,itb,ite);
162
myContainer
.clear();
163
164
//We estimate and store the quantities
165
//(since SurfelConstIterator models are usually SinglePass, we
166
//cannot use the optimized "range" eval on the estimator)
167
for
(SurfelConstIterator it = itb; it != ite; ++it)
168
myContainer
.insert( std::pair<Surfel, Quantity>(*it,
myEstimator
->eval(it) ) );
169
170
myInit
=
true
;
171
}
172
182
template
<
typename
SurfelConstIterator>
183
Quantity
eval
(
const
SurfelConstIterator it)
const
184
{
185
ASSERT_MSG(
myInit
,
" init() method must have been called first."
);
186
return
myContainer
.find( *it )->second;
187
}
188
197
Quantity
eval
(
const
Surfel
s)
const
198
{
199
ASSERT_MSG(
myInit
,
" init() method must have been called first."
);
200
return
myContainer
.find( s )->second;
201
}
202
203
217
template
<
typename
SurfelConstIterator,
typename
OutputIterator>
218
OutputIterator
eval
(SurfelConstIterator itb,
219
SurfelConstIterator ite,
220
OutputIterator result )
const
221
{
222
ASSERT_MSG(
myInit
,
" init() method must have been called first."
);
223
for
(SurfelConstIterator it = itb; it != ite; ++it)
224
*result++ = this->
eval
(it);
225
226
return
result;
227
}
228
236
double
h
()
const
237
{
238
return
myEstimator
->h();
239
}
240
241
// ----------------------- Interface --------------------------------------
242
public
:
243
248
typename
Container::size_type
size
()
const
249
{
250
ASSERT_MSG(
myInit
,
" init() method must have been called first."
);
251
return
myContainer
.size();
252
}
253
258
void
selfDisplay
( std::ostream & out )
const
259
{
260
out<<
"[EstimatorCache] number of surfels="
<<
myContainer
.size();
261
}
262
267
bool
isValid
()
const
268
{
269
return
myEstimator
&&
myEstimator
->isValid();
270
}
271
272
// ------------------------- Protected Data ------------------------------
273
private
:
274
// ------------------------- Private Data --------------------------------
275
private
:
276
277
279
Container
myContainer
;
280
282
Estimator
*
myEstimator
;
283
285
bool
myInit
;
286
287
// ------------------------- Internals ------------------------------------
288
private
:
289
290
};
// end of class EstimatorCache
291
292
299
template
<
typename
T,
typename
TC>
300
std::ostream&
301
operator<<
( std::ostream & out,
const
EstimatorCache<T,TC>
&
object
)
302
{
303
object
.selfDisplay( out );
304
return
out;
305
}
306
307
}
// namespace DGtal
308
// //
310
311
#endif
// !defined EstimatorCache_h
312
313
#undef EstimatorCache_RECURSES
314
#endif
// else defined(EstimatorCache_RECURSES)
DGtal::Alias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition
Alias.h:183
DGtal::EstimatorCache
Aim: this class adapts any local surface estimator to cache the estimated values in a associative con...
Definition
EstimatorCache.h:78
DGtal::EstimatorCache::eval
Quantity eval(const SurfelConstIterator it) const
Definition
EstimatorCache.h:183
DGtal::EstimatorCache< Estimator, Container >::myContainer
Container myContainer
Definition
EstimatorCache.h:279
DGtal::EstimatorCache::Container
TContainer Container
Container type.
Definition
EstimatorCache.h:88
DGtal::EstimatorCache::operator=
Self & operator=(const Self &other)
Definition
EstimatorCache.h:136
DGtal::EstimatorCache::Self
EstimatorCache< Estimator, Container > Self
Self.
Definition
EstimatorCache.h:100
DGtal::EstimatorCache::size
Container::size_type size() const
Definition
EstimatorCache.h:248
DGtal::EstimatorCache::EstimatorCache
EstimatorCache(Alias< Estimator > anEstimator)
Definition
EstimatorCache.h:112
DGtal::EstimatorCache::Quantity
Estimator::Quantity Quantity
Quantity type.
Definition
EstimatorCache.h:97
DGtal::EstimatorCache::selfDisplay
void selfDisplay(std::ostream &out) const
Definition
EstimatorCache.h:258
DGtal::EstimatorCache::eval
Quantity eval(const Surfel s) const
Definition
EstimatorCache.h:197
DGtal::EstimatorCache< Estimator, Container >::myEstimator
Estimator * myEstimator
Definition
EstimatorCache.h:282
DGtal::EstimatorCache::~EstimatorCache
~EstimatorCache()
Definition
EstimatorCache.h:119
DGtal::EstimatorCache< Estimator, Container >::myInit
bool myInit
Definition
EstimatorCache.h:285
DGtal::EstimatorCache::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSurfelLocalEstimator< TEstimator >))
DGtal::EstimatorCache::EstimatorCache
EstimatorCache()
Definition
EstimatorCache.h:105
DGtal::EstimatorCache::h
double h() const
Definition
EstimatorCache.h:236
DGtal::EstimatorCache::Surfel
Estimator::Surfel Surfel
Surfel type.
Definition
EstimatorCache.h:94
DGtal::EstimatorCache::Estimator
TEstimator Estimator
Estimator type.
Definition
EstimatorCache.h:84
DGtal::EstimatorCache::isValid
bool isValid() const
Definition
EstimatorCache.h:267
DGtal::EstimatorCache::EstimatorCache
EstimatorCache(const Self &other)
Definition
EstimatorCache.h:125
DGtal::EstimatorCache::init
void init(const double aH, SurfelConstIterator itb, SurfelConstIterator ite)
Definition
EstimatorCache.h:158
DGtal::EstimatorCache::eval
OutputIterator eval(SurfelConstIterator itb, SurfelConstIterator ite, OutputIterator result) const
Definition
EstimatorCache.h:218
DGtal::EstimatorCache::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((boost::PairAssociativeContainer< TContainer >))
DGtal::PlaneProbingParallelepipedEstimator< DigitalPlane, ProbingMode::R1 >::Quantity
typename TetrahedronEstimator::Quantity Quantity
Definition
PlaneProbingParallelepipedEstimator.h:77
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::concepts::CSurfelLocalEstimator
Aim: This concept describes an object that can process a range of surfels (that are supposed to belon...
Definition
CSurfelLocalEstimator.h:108
boost::PairAssociativeContainer
Go to http://www.sgi.com/tech/stl/PairAssociativeContainer.html.
Definition
Boost.dox:149
src
DGtal
geometry
surfaces
estimation
EstimatorCache.h
Generated on
for DGtal by
1.18.0