Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
homotopicThinning3D.cpp File Reference
#include <iostream>
#include <queue>
#include "DGtal/base/Common.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/Color.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
Include dependency graph for homotopicThinning3D.cpp:

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 Viewer.

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 63 of file homotopicThinning3D.cpp.

64{
65
66 trace.beginBlock ( "Example simple example of 3DViewer" );
67
68 PolyscopeViewer<> viewer;
69
70 // Domain cretation from two bounding points.
71 Point c( 0, 0, 0 );
72 Point p1( -50, -50, -50 );
73 Point p2( 50, 50, 50 );
74 Domain domain( p1, p2 );
75
76 trace.warning() << "Constructing a ring DigitalSet ... ";
77 DigitalSet shape_set( domain );
78 for (Domain::ConstIterator it = domain.begin(); it != domain.end(); ++it )
79 {
80 if ( ((*it - c ).norm() <= 25) && ((*it - c ).norm() >= 18)
81 && ( (((*it)[0] <= 3)&& ((*it)[0] >= -3))|| (((*it)[1] <= 3)&& ((*it)[1] >= -3)))){
82 shape_set.insertNew( *it );
83 }
84 }
85 trace.warning() << " [Done]" << std::endl;
86
87 trace.beginBlock ( "Thinning" );
88 Object18_6 shape( dt18_6, shape_set );
89 int nb_simple=0;
91 do
92 {
93 DigitalSet & S = shape.pointSet();
94 std::queue<DigitalSet::Iterator> Q;
95 it = S.begin();
96 itE = S.end();
97#ifdef DGTAL_WITH_OPENMP
98 std::vector<DigitalSet::Iterator> v( S.size() );
99 std::vector<uint8_t> b( v.size() );
100 for ( size_t i = 0; it != itE; ++it, ++i )
101 v[ i ] = it;
102#pragma omp parallel for schedule(dynamic)
103 for ( size_t i = 0; i < v.size(); ++i )
104 b[ i ] = shape.isSimple( *(v[ i ]) );
105
106 for ( size_t i = 0; i < v.size(); ++i )
107 if ( b[ i ] ) Q.push( v[ i ] );
108#else
109 for ( ; it != itE; ++it )
110 if ( shape.isSimple( *it ) )
111 Q.push( it );
112#endif
113 nb_simple = 0;
114 while ( ! Q.empty() )
115 {
116 DigitalSet::Iterator itt = Q.front();
117 Q.pop();
118 if ( shape.isSimple( *itt ) )
119 {
120 S.erase( *itt );
121 ++nb_simple;
122 }
123 }
124 }
125 while ( nb_simple != 0 );
126 DigitalSet & S = shape.pointSet();
127 trace.endBlock();
128
129 // Display by using two different list to manage OpenGL transparency.
130
131 viewer << Color(25,25,255, 255);
132 viewer << S ;
133
134 viewer << Color(250, 0,0, 25);
135 viewer << shape_set;
136
137
138 trace.endBlock();
139 viewer.show();
140 return 0;
141
142}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
void show() override
Starts the event loop and display of elements.
static const DT18_6 dt18_6
Definition StdDefs.h:195
Object< DT18_6, DigitalSet > Object18_6
Definition StdDefs.h:178
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition StdDefs.h:173
Trace trace
Domain domain

References DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::begin(), domain, DGtal::Z3i::dt18_6, DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::end(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::erase(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::insertNew(), DGtal::Object< TDigitalTopology, TDigitalSet >::isSimple(), DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet(), DGtal::PolyscopeViewer< Space, KSpace >::show(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::size(), and DGtal::trace.