Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
exampleParamCurve3dDigitization.cpp File Reference
#include <iostream>
#include <iterator>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/geometry/curves/parametric/EllipticHelix.h"
#include "DGtal/geometry/curves/parametric/NaiveParametricCurveDigitizer3D.h"
Include dependency graph for exampleParamCurve3dDigitization.cpp:

Go to the source code of this file.

Functions

template<typename T>
unsigned char findMainAxis (const T &curve, const long double &t)
int main (int argc, char **argv)

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Kacper Pluta (kacper.pluta@esiee.fr ) Laboratoire d'Informatique Gaspard-Monge - LIGM, A3SI, France
Date
2018/08/03

An example file for ParametriCurveDigitizer3D.

This file is part of the DGtal library.

Definition in file exampleParamCurve3dDigitization.cpp.

Function Documentation

◆ findMainAxis()

template<typename T>
unsigned char findMainAxis ( const T & curve,
const long double & t )
inline

Definition at line 55 of file exampleParamCurve3dDigitization.cpp.

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}
Space::RealPoint RealPoint
Definition StdDefs.h:170

Referenced by main().

◆ main()

int main ( int argc,
char ** argv )

[DigiHelixConstr]

[DigiHelixConstr]

[DigiHelixInit]

[DigiHelixInit]

[DigiHelixComp]

[DigiHelixComp]

[DigiHelixMetadata]

[DigiHelixMetadata]

Definition at line 71 of file exampleParamCurve3dDigitization.cpp.

72{
74 typedef EllipticHelix < Space > MyHelix;
75 typedef NaiveParametricCurveDigitizer3D < MyHelix > DigitizerHelix;
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}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
std::vector< std::pair< long double, unsigned int > > MetaData
std::vector< Point > DigitalCurve
Digital curve type.
void show() override
Starts the event loop and display of elements.
unsigned char findMainAxis(const T &curve, const long double &t)
Trace trace
void digitize(Shape &shape, std::vector< SCell > &sCells0, std::vector< SCell > &sCells1, KSpace &kspace, const double h)

References digitize(), findMainAxis(), DGtal::PolyscopeViewer< Space, KSpace >::show(), and DGtal::trace.