DGtal  0.9.3
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"
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 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.

References DGtal::HyperRectDomain< TSpace >::begin(), DGtal::Trace::beginBlock(), domain(), DGtal::HyperRectDomain< TSpace >::end(), DGtal::Trace::endBlock(), DGtal::Viewer3D< Space, KSpace >::show(), DGtal::trace, and DGtal::Trace::warning().

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;
94  DigitalSet::Iterator it, itE;
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 }
void beginBlock(const std::string &keyword="")
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
const ConstIterator & end() const
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
double endBlock()
const ConstIterator & begin() const
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & warning()
Object< DT18_6, DigitalSet > Object18_6
Definition: StdDefs.h:178
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.