DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
exampleTrofoliKnot.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
37
#include "DGtal/geometry/curves/parametric/Knot_3_1.h"
38
#include "DGtal/geometry/curves/parametric/NaiveParametricCurveDigitizer3D.h"
39
40
#ifdef DGTAL_WITH_POLYSCOPE_VIEWER
41
#include "DGtal/io/viewers/PolyscopeViewer.h"
42
#endif
43
45
46
using namespace
std
;
47
using namespace
DGtal
;
48
using namespace
Z3i
;
49
using namespace
functors
;
50
51
template
<
typename
T>
52
inline
53
unsigned
char
findMainAxis
(
const
T & curve,
const
long
double
& t )
54
{
55
RealPoint
value;
56
value[0] = std::abs ( curve.xp ( t )[0] );
57
value[1] = std::abs ( curve.xp ( t )[1] );
58
value[2] = std::abs ( curve.xp ( t )[2] );
59
60
if
( value[0] >= value[1] && value[0] >= value[2] )
61
return
0;
62
else
if
( value[1] >= value[0] && value[1] >= value[2] )
63
return
1;
64
else
65
return
2;
66
}
67
69
int
main
()
70
{
71
typedef
Knot_3_1< Space >
MyKnot;
72
typedef
NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
73
typedef
NaiveParametricCurveDigitizer3D < MyKnot >::DigitalCurve
MyDigitalCurve;
74
typedef
NaiveParametricCurveDigitizer3D < MyKnot >::MetaData
MyMetaData;
75
76
trace
.
info
() <<
"exampleParamCurve3dDigitization"
<< endl;
77
78
PolyscopeViewer
viewer;
79
80
MyDigitalCurve digitalCurve;
81
MyMetaData metaData;
82
MyKnot knot ( 10, 10, 10 );
83
Digitizer
digitize
;
84
digitize
.attach ( &knot );
85
digitize
.init ( -2.1, 2.1, 0.0001 );
86
digitize
.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
87
88
trace
.
info
() <<
"Number of points: "
<< digitalCurve.size () <<
" number of metadata: "
<< metaData.size () << endl;
89
90
for
(
unsigned
int
i = 0; i < digitalCurve.size ( ); i++ )
91
{
92
if
(
findMainAxis
( knot, metaData.at ( i ).first ) == 0 )
93
viewer.
drawColor
(
Color
( 255, 0, 0, 128 ) );
94
if
(
findMainAxis
( knot, metaData.at ( i ).first ) == 1 )
95
viewer.
drawColor
(
Color
( 0, 255, 0, 128 ) );
96
if
(
findMainAxis
( knot, metaData.at ( i ).first ) == 2 )
97
viewer.
drawColor
(
Color
( 0, 0, 255, 128 ) );
98
viewer << digitalCurve.at ( i );
99
}
100
101
viewer.
show
();
102
return
0;
103
}
104
// //
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition
Color.h:77
DGtal::Display3D::drawColor
void drawColor(const DGtal::Color &color)
DGtal::Knot_3_1
Aim: Implement a parametrized knot 3, 1.
Definition
Knot_3_1.h:60
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
exampleTrofoliKnot.cpp
Generated on
for DGtal by
1.18.0