DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
homotopicThinning3D.cpp File Reference
#include <iostream>
#include <queue>
#include "DGtal/base/Common.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/Color.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"

Go to the source code of this file.

Functions

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
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2011/01/04

An example file named qglViewer.

This file is part of the DGtal library.

Definition in file homotopicThinning3D.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 64 of file homotopicThinning3D.cpp.

65{
66
67 trace.beginBlock ( "Example simple example of 3DViewer" );
68
69 QApplication application(argc,argv);
70 Viewer3D<> viewer;
71 viewer.setWindowTitle("simpleExample3DViewer");
72 viewer.show();
73
74 // Domain cretation from two bounding points.
75 Point c( 0, 0, 0 );
76 Point p1( -50, -50, -50 );
77 Point p2( 50, 50, 50 );
78 Domain domain( p1, p2 );
79
80 trace.warning() << "Constructing a ring DigitalSet ... ";
81 DigitalSet shape_set( domain );
82 for (Domain::ConstIterator it = domain.begin(); it != domain.end(); ++it )
83 {
84 if ( ((*it - c ).norm() <= 25) && ((*it - c ).norm() >= 18)
85 && ( (((*it)[0] <= 3)&& ((*it)[0] >= -3))|| (((*it)[1] <= 3)&& ((*it)[1] >= -3)))){
86 shape_set.insertNew( *it );
87 }
88 }
89 trace.warning() << " [Done]" << std::endl;
90
91 trace.beginBlock ( "Thinning" );
92 Object18_6 shape( dt18_6, shape_set );
93 int nb_simple=0;
95 do
96 {
97 DigitalSet & S = shape.pointSet();
98 std::queue<DigitalSet::Iterator> Q;
99 it = S.begin();
100 itE = S.end();
101#ifdef WITH_OPENMP
102 std::vector<DigitalSet::Iterator> v( S.size() );
103 std::vector<uint8_t> b( v.size() );
104 for ( size_t i = 0; it != itE; ++it, ++i )
105 v[ i ] = it;
106#pragma omp parallel for schedule(dynamic)
107 for ( size_t i = 0; i < v.size(); ++i )
108 b[ i ] = shape.isSimple( *(v[ i ]) );
109
110 for ( size_t i = 0; i < v.size(); ++i )
111 if ( b[ i ] ) Q.push( v[ i ] );
112#else
113 for ( ; it != itE; ++it )
114 if ( shape.isSimple( *it ) )
115 Q.push( it );
116#endif
117 nb_simple = 0;
118 while ( ! Q.empty() )
119 {
120 DigitalSet::Iterator itt = Q.front();
121 Q.pop();
122 if ( shape.isSimple( *itt ) )
123 {
124 S.erase( *itt );
125 ++nb_simple;
126 }
127 }
128 }
129 while ( nb_simple != 0 );
130 DigitalSet & S = shape.pointSet();
131 trace.endBlock();
132
133 // Display by using two different list to manage OpenGL transparency.
134
135 viewer << SetMode3D( shape_set.className(), "Paving" );
136 viewer << CustomColors3D(Color(25,25,255, 255), Color(25,25,255, 255));
137 viewer << S ;
138
139 viewer << SetMode3D( shape_set.className(), "PavingTransp" );
140 viewer << CustomColors3D(Color(250, 0,0, 25), Color(250, 0,0, 5));
141 viewer << shape_set;
142
143 viewer<< Viewer3D<>::updateDisplay;
144
145
146 trace.endBlock();
147 return application.exec();
148
149}
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Container::iterator Iterator
Iterator type of the container.
Iterator for HyperRectDomain.
const ConstIterator & begin() const
const ConstIterator & end() const
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
Definition: Object.h:120
void beginBlock(const std::string &keyword="")
std::ostream & warning()
double endBlock()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
static const DT18_6 dt18_6
Definition: StdDefs.h:195
Trace trace
Definition: Common.h:154
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Domain domain

References DGtal::HyperRectDomain< TSpace >::begin(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::className(), domain, DGtal::Z3i::dt18_6, DGtal::HyperRectDomain< TSpace >::end(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::end(), DGtal::Trace::endBlock(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::erase(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::insertNew(), DGtal::Object< TDigitalTopology, TDigitalSet >::isSimple(), DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet(), DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::size(), DGtal::trace, and DGtal::Trace::warning().