File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
exampleParamCurve3dDigitizationTransformationDecorator.cpp File Reference
#include <iostream>
#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 "DGtal/geometry/curves/parametric/DecoratorParametricCurveTransformation.h"
#include "DGtal/images/RigidTransformation3D.h"
Include dependency graph for exampleParamCurve3dDigitizationTransformationDecorator.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 DecoratorParametricCurveTransformation.h.

This file is part of the DGtal library.

Definition in file exampleParamCurve3dDigitizationTransformationDecorator.cpp.

Function Documentation

◆ findMainAxis()

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

Definition at line 56 of file exampleParamCurve3dDigitizationTransformationDecorator.cpp.

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

◆ main()

int main ( int argc,
char ** argv )

[DigiRotHelixConstr]

[DigiRotHelixConstr]

[DigiRotHelixConstrCurve]

[DigiRotHelixConstrCurve]

[DigiRotHelixConstrRot]

[DigiRotHelixConstrRot]

[DigiRotHelixDigitize]

[DigiRotHelixDigitize]

Definition at line 72 of file exampleParamCurve3dDigitizationTransformationDecorator.cpp.

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;
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}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
void drawColor(const DGtal::Color &color)
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)
Space::RealVector RealVector
Definition StdDefs.h:171
Trace trace
void digitize(Shape &shape, std::vector< SCell > &sCells0, std::vector< SCell > &sCells1, KSpace &kspace, const double h)
double angle(const DGtal::Z2i::RealPoint &point)

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