DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FunctorsLambdaMST.h
1
16
17
#pragma once
18
28
29
#if defined(FunctorsLambdaMST_RECURSES)
30
#error Recursive header files inclusion detected in FunctorsLambdaMST.h
31
#else
// defined(FunctorsLambdaMST_RECURSES)
33
#define FunctorsLambdaMST_RECURSES
34
35
#if !defined FunctorsLambdaMST_h
37
#define FunctorsLambdaMST_h
38
40
// Inclusions
41
#include <functional>
42
#include <iterator>
43
#include <stdexcept>
44
#include "DGtal/base/Common.h"
45
#include "DGtal/base/IteratorCirculatorTraits.h"
46
#include "DGtal/base/CUnaryFunctor.h"
48
49
namespace
DGtal
50
{
52
61
namespace
functors
62
{
68
struct
Lambda64Function
69
{
70
double
operator()
(
double
x)
const
71
{
72
double
e2 = x * x;
73
double
e3 = e2 * x;
74
return
64.0 * ( -e3 * e3 + 3.0 * e3 * e2 - 3.0 * e2 * e2 + e3 );
75
}
76
};
77
82
struct
LambdaSinFromPiFunction
83
{
84
double
operator()
(
double
x)
const
85
{
86
return
std::sin ( M_PI * x );
87
}
88
};
89
95
struct
LambdaExponentialFunction
96
{
97
double
operator()
(
double
x)
const
98
{
99
return
2.0 / ( std::exp ( 15.0 * ( x - 0.5 ) ) + std::exp ( -15.0 * ( x - 0.5 ) ) );
100
}
101
};
102
}
103
111
template
<
typename
DSS,
typename
LambdaFunction>
112
class
TangentFromDSS2DFunctor
113
{
114
BOOST_CONCEPT_ASSERT
(( concepts::CUnaryFunctor < LambdaFunction, double, double > ));
115
// ----------------------- Types ------------------------------
116
public
:
117
typedef
PointVector<2, double>
RealVector
;
118
typedef
DSS
TDSS
;
119
120
struct
Value
121
{
122
RealVector
first
;
123
double
second
;
124
Value
() :
second
( 0. ) {}
125
Value
&
operator+=
(
const
Value
&
ch
)
126
{
127
this->first +=
ch
.first;
128
this->second +=
ch
.second;
129
return
*
this
;
130
}
131
};
132
133
134
// ----------------------- Interface --------------------------------------
135
public
:
143
Value
operator()
(
const
TDSS
& aDSS,
const
int
& indexOfPointInDSS,
const
int
& dssLen )
const
144
{
145
Value
result;
146
double
norm = std::sqrt ( aDSS.a() * aDSS.a() + aDSS.b() * aDSS.b() );
147
result.
second
=
lambdaFunctor
( (
double
)indexOfPointInDSS / (
double
)dssLen );
148
if
( norm > 0. )
149
{
150
result.
first
[0] = result.
second
* aDSS.b() / norm;
151
result.
first
[1] = result.
second
* aDSS.a() / norm;
152
}
153
else
154
{
155
result.
first
[0] = 0.;
156
result.
first
[1] = 0.;
157
}
158
return
result;
159
}
160
private
:
161
// ------------------------- Private Data --------------------------------
162
LambdaFunction
lambdaFunctor
;
163
};
164
172
template
<
typename
DSS,
typename
LambdaFunction>
173
class
TangentFromDSS3DFunctor
174
{
175
BOOST_CONCEPT_ASSERT
(( concepts::CUnaryFunctor < LambdaFunction, double, double > ));
176
public
:
177
// ----------------------- Types ------------------------------
178
typedef
PointVector<3, double>
RealVector
;
179
typedef
DSS
TDSS
;
180
struct
Value
181
{
182
RealVector
first
;
183
double
second
;
184
Value
() :
second
( 0. ) {}
185
Value
&
operator +=
(
const
Value
&
ch
)
186
{
187
this->first +=
ch
.first;
188
this->second +=
ch
.second;
189
return
*
this
;
190
}
191
};
192
193
// ----------------------- Interface --------------------------------------
201
Value
operator()
(
const
TDSS
& aDSS,
const
unsigned
int
indexOfPointInDSS,
const
unsigned
int
dssLen )
const
202
{
203
Value
result;
204
typename
DSS::Point3d directionZ3;
205
RealVector
direction;
206
typename
DSS::PointR3d intercept;
207
typename
DSS::PointR3d thickness;
208
209
aDSS.getParameters ( directionZ3, intercept, thickness );
210
direction[0] = directionZ3[0];
211
direction[1] = directionZ3[1];
212
direction[2] = directionZ3[2];
213
214
result.
second
=
lambdaFunctor
( (
double
)indexOfPointInDSS / (
double
)dssLen );
215
216
double
norm = direction.
norm
();
217
if
( norm != 0. )
218
direction /= norm;
219
result.
first
= direction * result.
second
;
220
return
result;
221
}
222
private
:
223
// ------------------------- Private Data --------------------------------
225
LambdaFunction
lambdaFunctor
;
226
};
227
228
234
template
<
typename
DSS >
235
class
DSSMuteFilter
236
{
237
public
:
238
// ----------------------- Types ------------------------------
239
typedef
DSS
DSSType
;
240
typedef
typename
IteratorCirculatorTraits< typename DSSType::ConstIterator >::Value
Point
;
241
243
bool
operator()
(
const
DSSType
& )
const
244
{
245
return
false
;
246
}
247
249
bool
admissibility
(
const
DSSType
&,
const
Point
& )
const
250
{
251
return
false
;
252
}
253
255
long
int
position
(
const
DSSType
&,
const
Point
& )
const
256
{
257
throw
std::runtime_error (
"You are not suppose to see this error!"
);
258
}
259
};
260
261
268
template
<
typename
DSS >
269
class
DSSLengthLessEqualFilter
270
{
271
public
:
272
// ----------------------- Types ------------------------------
273
typedef
DSS
DSSType
;
274
typedef
typename
IteratorCirculatorTraits< typename DSSType::ConstIterator >::Value
Point
;
275
276
DSSLengthLessEqualFilter
( ) :
lenThreshold
(0),
initThreshold
( false ) { }
277
281
void
init
(
double
threshold )
282
{
283
if
( threshold < 0. )
284
throw
std::runtime_error (
"The threshold has to be positive!"
);
285
lenThreshold
= threshold;
286
initThreshold
=
true
;
287
}
288
293
bool
operator()
(
const
DSSType
& dss )
const
294
{
295
if
(!
initThreshold
)
296
throw
std::runtime_error (
"The filter has to be initialized!"
);
297
298
return
std::distance ( dss.begin ( ), dss.end ( ) ) <
lenThreshold
;
299
}
300
307
bool
admissibility
(
const
DSSType
& dss,
const
Point
& p )
const
308
{
309
return
( p - *dss.begin ( ) ).norm ( ) <=
lenThreshold
|| ( p - *( dss.end ( ) - 1 ) ).norm ( ) <=
lenThreshold
;
310
}
311
319
long
int
position
(
const
DSSType
& dss,
const
Point
& p )
const
320
{
321
if
( ( p - *dss.begin ( ) ).norm ( ) <=
lenThreshold
)
322
return
1;
323
else
if
( ( p - *( dss.end ( ) - 1 ) ).norm ( ) <=
lenThreshold
)
324
return
std::distance ( dss.begin ( ), dss.end ( ) ) + 1;
325
else
326
throw
std::runtime_error (
"The DSS and the point are not admissible!"
);
327
}
328
329
private
:
330
double
lenThreshold
;
331
bool
initThreshold
;
332
};
333
334
}
// namespace DGtal
335
336
// //
338
339
#endif
// !defined FunctorsLambdaMST_h
340
341
#undef FunctorsLambdaMST_RECURSES
342
#endif
// else defined(FunctorsLambdaMST_RECURSES)
DGtal::DSSLengthLessEqualFilter::operator()
bool operator()(const DSSType &dss) const
Definition
FunctorsLambdaMST.h:293
DGtal::DSSLengthLessEqualFilter::DSSType
DSS DSSType
Definition
FunctorsLambdaMST.h:273
DGtal::DSSLengthLessEqualFilter::lenThreshold
double lenThreshold
Definition
FunctorsLambdaMST.h:330
DGtal::DSSLengthLessEqualFilter::init
void init(double threshold)
Definition
FunctorsLambdaMST.h:281
DGtal::DSSLengthLessEqualFilter::position
long int position(const DSSType &dss, const Point &p) const
Definition
FunctorsLambdaMST.h:319
DGtal::DSSLengthLessEqualFilter::admissibility
bool admissibility(const DSSType &dss, const Point &p) const
Definition
FunctorsLambdaMST.h:307
DGtal::DSSLengthLessEqualFilter::initThreshold
bool initThreshold
Definition
FunctorsLambdaMST.h:331
DGtal::DSSLengthLessEqualFilter::DSSLengthLessEqualFilter
DSSLengthLessEqualFilter()
Definition
FunctorsLambdaMST.h:276
DGtal::DSSLengthLessEqualFilter::Point
IteratorCirculatorTraits< typenameDSSType::ConstIterator >::Value Point
Definition
FunctorsLambdaMST.h:274
DGtal::DSSMuteFilter
Definition
FunctorsLambdaMST.h:236
DGtal::DSSMuteFilter::operator()
bool operator()(const DSSType &) const
Always returns false.
Definition
FunctorsLambdaMST.h:243
DGtal::DSSMuteFilter::position
long int position(const DSSType &, const Point &) const
When called always throws an exception.
Definition
FunctorsLambdaMST.h:255
DGtal::DSSMuteFilter::Point
IteratorCirculatorTraits< typenameDSSType::ConstIterator >::Value Point
Definition
FunctorsLambdaMST.h:240
DGtal::DSSMuteFilter::DSSType
DSS DSSType
Definition
FunctorsLambdaMST.h:239
DGtal::DSSMuteFilter::admissibility
bool admissibility(const DSSType &, const Point &) const
Always returns false.
Definition
FunctorsLambdaMST.h:249
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition
PointVector.h:593
DGtal::PointVector::norm
double norm(const NormType type=L_2) const
DGtal::TangentFromDSS2DFunctor
Definition
FunctorsLambdaMST.h:113
DGtal::TangentFromDSS2DFunctor::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CUnaryFunctor< LambdaFunction, double, double >))
DGtal::TangentFromDSS2DFunctor::operator()
Value operator()(const TDSS &aDSS, const int &indexOfPointInDSS, const int &dssLen) const
Definition
FunctorsLambdaMST.h:143
DGtal::TangentFromDSS2DFunctor::TDSS
DSS TDSS
Definition
FunctorsLambdaMST.h:118
DGtal::TangentFromDSS2DFunctor::RealVector
PointVector< 2, double > RealVector
Definition
FunctorsLambdaMST.h:117
DGtal::TangentFromDSS2DFunctor::lambdaFunctor
LambdaFunction lambdaFunctor
Definition
FunctorsLambdaMST.h:162
DGtal::TangentFromDSS3DFunctor
Definition
FunctorsLambdaMST.h:174
DGtal::TangentFromDSS3DFunctor::operator()
Value operator()(const TDSS &aDSS, const unsigned int indexOfPointInDSS, const unsigned int dssLen) const
Definition
FunctorsLambdaMST.h:201
DGtal::TangentFromDSS3DFunctor::TDSS
DSS TDSS
Definition
FunctorsLambdaMST.h:179
DGtal::TangentFromDSS3DFunctor::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CUnaryFunctor< LambdaFunction, double, double >))
DGtal::TangentFromDSS3DFunctor::lambdaFunctor
LambdaFunction lambdaFunctor
Definition
FunctorsLambdaMST.h:225
DGtal::TangentFromDSS3DFunctor::RealVector
PointVector< 3, double > RealVector
Definition
FunctorsLambdaMST.h:178
DGtal::functors
functors namespace gathers all DGtal functors.
Definition
BasicBoolFunctors.h:49
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::IteratorCirculatorTraits::Value
IC::value_type Value
Definition
IteratorCirculatorTraits.h:303
DGtal::TangentFromDSS2DFunctor::Value
Definition
FunctorsLambdaMST.h:121
DGtal::TangentFromDSS2DFunctor::Value::first
RealVector first
Definition
FunctorsLambdaMST.h:122
DGtal::TangentFromDSS2DFunctor::Value::Value
Value()
Definition
FunctorsLambdaMST.h:124
DGtal::TangentFromDSS2DFunctor::Value::operator+=
Value & operator+=(const Value &ch)
Definition
FunctorsLambdaMST.h:125
DGtal::TangentFromDSS2DFunctor::Value::second
double second
Definition
FunctorsLambdaMST.h:123
DGtal::TangentFromDSS3DFunctor::Value
Definition
FunctorsLambdaMST.h:181
DGtal::TangentFromDSS3DFunctor::Value::second
double second
Definition
FunctorsLambdaMST.h:183
DGtal::TangentFromDSS3DFunctor::Value::first
RealVector first
Definition
FunctorsLambdaMST.h:182
DGtal::TangentFromDSS3DFunctor::Value::operator+=
Value & operator+=(const Value &ch)
Definition
FunctorsLambdaMST.h:185
DGtal::TangentFromDSS3DFunctor::Value::Value
Value()
Definition
FunctorsLambdaMST.h:184
DGtal::functors::Lambda64Function
Definition
FunctorsLambdaMST.h:69
DGtal::functors::Lambda64Function::operator()
double operator()(double x) const
Definition
FunctorsLambdaMST.h:70
DGtal::functors::LambdaExponentialFunction
Definition
FunctorsLambdaMST.h:96
DGtal::functors::LambdaExponentialFunction::operator()
double operator()(double x) const
Definition
FunctorsLambdaMST.h:97
DGtal::functors::LambdaSinFromPiFunction
Definition
FunctorsLambdaMST.h:83
DGtal::functors::LambdaSinFromPiFunction::operator()
double operator()(double x) const
Definition
FunctorsLambdaMST.h:84
ch
DGtal::MelkmanConvexHull< Point, Functor > ch
Definition
testConvexHull2DReverse.cpp:52
src
DGtal
geometry
curves
estimation
FunctorsLambdaMST.h
Generated on
for DGtal by
1.18.0