DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
exampleParamCurve3dDigitizationTransformationDecorator.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "DGtal/helpers/StdDefs.h"
34
#include "ConfigExamples.h"
35
36
#include "DGtal/geometry/curves/parametric/EllipticHelix.h"
37
#include "DGtal/geometry/curves/parametric/NaiveParametricCurveDigitizer3D.h"
39
#include "DGtal/geometry/curves/parametric/DecoratorParametricCurveTransformation.h"
40
#include "DGtal/images/RigidTransformation3D.h"
42
43
#ifdef DGTAL_WITH_POLYSCOPE_VIEWER
44
#include "DGtal/io/viewers/PolyscopeViewer.h"
45
#endif
46
48
49
using namespace
std
;
50
using namespace
DGtal
;
51
using namespace
Z3i
;
52
using namespace
functors
;
53
54
template
<
typename
T>
55
inline
56
unsigned
char
findMainAxis
(
const
T & curve,
const
long
double
& t )
57
{
58
RealPoint
value;
59
value[0] = std::abs ( curve.xp ( t )[0] );
60
value[1] = std::abs ( curve.xp ( t )[1] );
61
value[2] = std::abs ( curve.xp ( t )[2] );
62
63
if
( value[0] >= value[1] && value[0] >= value[2] )
64
return
0;
65
else
if
( value[1] >= value[0] && value[1] >= value[2] )
66
return
1;
67
else
68
return
2;
69
}
70
72
int
main
()
73
{
75
typedef
EllipticHelix < Space > MyHelix;
76
typedef
ForwardRigidTransformation3D < Space, RealPoint, RealPoint, Identity > ForwardTrans;
77
typedef
DecoratorParametricCurveTransformation < MyHelix, ForwardTrans > MyRotatedCurve;
78
typedef
NaiveParametricCurveDigitizer3D < MyRotatedCurve > Digitizer;
79
typedef
typename
NaiveParametricCurveDigitizer3D < MyRotatedCurve >::DigitalCurve
MyDigitalCurve;
81
typedef
NaiveParametricCurveDigitizer3D < MyRotatedCurve >::MetaData
MyMetaData;
82
trace
.
info
() <<
"exampleParamCurve3dDigitizationTransformationDecorator"
<< endl;
83
84
PolyscopeViewer<>
viewer;
85
86
MyMetaData metaData;
87
89
MyDigitalCurve digitalCurve;
90
MyHelix helix( 30, 20, 1 );
92
94
double
angle
= M_PI/3.;
95
RealVector
axis ( 1., 0., 1. );
96
ForwardTrans trans (
RealPoint
( 0, 0, 0 ), axis,
angle
,
RealVector
( 0, 0, 0 ) );
97
MyRotatedCurve rotCurve ( helix, trans );
99
101
Digitizer
digitize
;
102
digitize
.attach ( &rotCurve );
103
digitize
.init ( 0, MyHelix::getPeriod() * 10., 0.0001 );
104
digitize
.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
106
107
trace
.
info
() <<
"Number of points: "
<< digitalCurve.size () <<
" number of metadata: "
<< metaData.size () << endl;
108
109
for
(
unsigned
int
i = 0; i < digitalCurve.size ( ); i++ )
110
{
111
if
(
findMainAxis
( rotCurve, metaData.at ( i ).first ) == 0 )
112
viewer.
drawColor
(
Color
( 255, 0, 0, 128 ) );
113
if
(
findMainAxis
( rotCurve, metaData.at ( i ).first ) == 1 )
114
viewer.
drawColor
(
Color
( 0, 255, 0, 128 ) );
115
if
(
findMainAxis
( rotCurve, metaData.at ( i ).first ) == 2 )
116
viewer.
drawColor
(
Color
( 0, 0, 255, 128 ) );
117
viewer << digitalCurve.at ( i );
118
}
119
120
viewer.
show
();
121
return
0;
122
}
123
// //
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition
Color.h:77
DGtal::Display3D::drawColor
void drawColor(const DGtal::Color &color)
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::RealVector
Space::RealVector RealVector
Definition
StdDefs.h:171
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
angle
double angle(const DGtal::Z2i::RealPoint &point)
Definition
testProjection.cpp:56
examples
geometry
curves
exampleParamCurve3dDigitizationTransformationDecorator.cpp
Generated on
for DGtal by
1.18.0