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
exampleTrofoliKnot.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/Knot_3_1.h"
#include "DGtal/geometry/curves/parametric/NaiveParametricCurveDigitizer3D.h"
Include dependency graph for exampleTrofoliKnot.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 exampleTrofoliKnot.cpp.

Function Documentation

◆ findMainAxis()

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

Definition at line 53 of file exampleTrofoliKnot.cpp.

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

◆ main()

int main ( int argc,
char ** argv )

Definition at line 69 of file exampleTrofoliKnot.cpp.

70{
71 typedef Knot_3_1< Space > MyKnot;
72 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
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}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
void drawColor(const DGtal::Color &color)
Aim: Implement a parametrized knot 3, 1.
Definition Knot_3_1.h:60
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(), DGtal::Display3D< Space, KSpace >::drawColor(), findMainAxis(), DGtal::PolyscopeViewer< Space, KSpace >::show(), and DGtal::trace.