DGtal  1.5.beta
exampleParamCurve3dDigitization.cpp File Reference
#include <iostream>
#include <iterator>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/io/viewers/Viewer3D.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 56 of file exampleParamCurve3dDigitization.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 }
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

[DigiHelixConstr]

[DigiHelixConstr]

[DigiHelixInit]

[DigiHelixInit]

[DigiHelixComp]

[DigiHelixComp]

[DigiHelixMetadata]

[DigiHelixMetadata]

Definition at line 72 of file exampleParamCurve3dDigitization.cpp.

73 {
74  QApplication application(argc,argv);
76  typedef EllipticHelix < Space > MyHelix;
77  typedef NaiveParametricCurveDigitizer3D < MyHelix > DigitizerHelix;
81  trace.info() << "exampleParamCurve3dDigitization" << endl;
82 
83  Viewer3D<> viewer;
84 
86  MyDigitalCurve digitalCurve;
87  MyMetaData metaData;
88  MyHelix helix( 15, 10, 1 );
89  DigitizerHelix digitize;
90  digitize.init ( M_PI / 2., ( MyHelix::getPeriod() * 10. ) + M_PI / 2., 0.0001 );
91  digitize.attach ( &helix );
93 
95  digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
97 
98  trace.info() << "Number of points: " << digitalCurve.size () << " number of metadata: " << metaData.size () << endl;
99 
100  viewer.show();
101 
103  for ( unsigned int i = 0; i < digitalCurve.size ( ); i++ )
104  {
105  if ( findMainAxis ( helix, metaData.at ( i ).first ) == 0 )
106  viewer.setFillColor ( Color ( 255, 0, 0, 128 ) );
107  if ( findMainAxis ( helix, metaData.at ( i ).first ) == 1 )
108  viewer.setFillColor ( Color ( 0, 255, 0, 128 ) );
109  if ( findMainAxis ( helix, metaData.at ( i ).first ) == 2 )
110  viewer.setFillColor ( Color ( 0, 0, 255, 128 ) );
111  viewer << SetMode3D ( digitalCurve.at ( i ).className ( ), "PavingWired" ) << digitalCurve.at ( i );
112  }
114  viewer << Viewer3D<>::updateDisplay;
115 
116  return application.exec();
117 }
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
virtual void setFillColor(DGtal::Color aColor)
Aim: Implement a parametric curve – elliptic helix.
Definition: EllipticHelix.h:60
Aim: Digitization of 3D parametric curves. This method produces, for good parameters step and k_next,...
std::vector< std::pair< long double, unsigned int > > MetaData
std::vector< Point > DigitalCurve
Digital curve type.
std::ostream & info()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
unsigned char findMainAxis(const T &curve, const long double &t)
Trace trace
Definition: Common.h:153
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
void digitize(Shape &shape, std::vector< SCell > &sCells0, std::vector< SCell > &sCells1, KSpace &kspace, const double h)

References digitize(), findMainAxis(), DGtal::Trace::info(), DGtal::Display3D< Space, KSpace >::setFillColor(), DGtal::Viewer3D< TSpace, TKSpace >::show(), and DGtal::trace.