DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
exampleParamCurve3dDigitization.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include <iterator>
33
#include "DGtal/base/Common.h"
34
#include "DGtal/helpers/StdDefs.h"
35
#include "ConfigExamples.h"
36
38
#include "DGtal/geometry/curves/parametric/EllipticHelix.h"
39
#include "DGtal/geometry/curves/parametric/NaiveParametricCurveDigitizer3D.h"
41
42
#ifdef DGTAL_WITH_POLYSCOPE_VIEWER
43
#include "DGtal/io/viewers/PolyscopeViewer.h"
44
#endif
45
47
48
using namespace
std
;
49
using namespace
DGtal
;
50
using namespace
Z3i
;
51
using namespace
functors
;
52
53
template
<
typename
T>
54
inline
55
unsigned
char
findMainAxis
(
const
T & curve,
const
long
double
& t )
56
{
57
RealPoint
value;
58
value[0] = std::abs ( curve.xp ( t )[0] );
59
value[1] = std::abs ( curve.xp ( t )[1] );
60
value[2] = std::abs ( curve.xp ( t )[2] );
61
62
if
( value[0] >= value[1] && value[0] >= value[2] )
63
return
0;
64
else
if
( value[1] >= value[0] && value[1] >= value[2] )
65
return
1;
66
else
67
return
2;
68
}
69
71
int
main
()
72
{
74
typedef
EllipticHelix < Space > MyHelix;
75
typedef
NaiveParametricCurveDigitizer3D < MyHelix > DigitizerHelix;
76
typedef
NaiveParametricCurveDigitizer3D < MyHelix >::DigitalCurve
MyDigitalCurve;
77
typedef
NaiveParametricCurveDigitizer3D < MyHelix >::MetaData
MyMetaData;
79
trace
.
info
() <<
"exampleParamCurve3dDigitization"
<< endl;
80
81
PolyscopeViewer<>
viewer;
82
84
MyDigitalCurve digitalCurve;
85
MyMetaData metaData;
86
MyHelix helix( 15, 10, 1 );
87
DigitizerHelix
digitize
;
88
digitize
.init ( M_PI / 2., ( MyHelix::getPeriod() * 10. ) + M_PI / 2., 0.0001 );
89
digitize
.attach ( &helix );
91
93
digitize
.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
95
96
trace
.
info
() <<
"Number of points: "
<< digitalCurve.size () <<
" number of metadata: "
<< metaData.size () << endl;
97
99
for
(
unsigned
int
i = 0; i < digitalCurve.size ( ); i++ )
100
{
101
if
(
findMainAxis
( helix, metaData.at ( i ).first ) == 0 )
102
viewer <<
Color
( 255, 0, 0, 128 );
103
if
(
findMainAxis
( helix, metaData.at ( i ).first ) == 1 )
104
viewer <<
Color
( 0, 255, 0, 128 );
105
if
(
findMainAxis
( helix, metaData.at ( i ).first ) == 2 )
106
viewer <<
Color
( 0, 0, 255, 128 );
107
viewer << digitalCurve.at ( i );
108
}
110
111
viewer.
show
();
112
return
0;
113
}
114
// //
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::NaiveParametricCurveDigitizer3D::MetaData
std::vector< std::pair< long double, unsigned int > > MetaData
Definition
NaiveParametricCurveDigitizer3D.h:89
DGtal::NaiveParametricCurveDigitizer3D::DigitalCurve
std::vector< Point > DigitalCurve
Digital curve type.
Definition
NaiveParametricCurveDigitizer3D.h:82
DGtal::PolyscopeViewer
Definition
PolyscopeViewer.h:57
DGtal::PolyscopeViewer::show
void show() override
Starts the event loop and display of elements.
Definition
PolyscopeViewer.h:73
DGtal::Trace::info
std::ostream & info()
findMainAxis
unsigned char findMainAxis(const T &curve, const long double &t)
Definition
exampleParamCurve3dDigitization.cpp:55
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal::Z3i::RealPoint
Space::RealPoint RealPoint
Definition
StdDefs.h:170
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::trace
Trace trace
std
STL namespace.
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
digitize
void digitize(Shape &shape, std::vector< SCell > &sCells0, std::vector< SCell > &sCells1, KSpace &kspace, const double h)
Definition
testProjection.cpp:91
examples
geometry
curves
exampleParamCurve3dDigitization.cpp
Generated on
for DGtal by
1.18.0