DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
homotopicThinning3D.cpp
1 
30 
31 #include <iostream>
32 #include <queue>
33 #include <QImageReader>
34 #include <QtGui/qapplication.h>
35 #include "DGtal/io/viewers/Viewer3D.h"
36 #include "DGtal/io/DrawWithDisplay3DModifier.h"
37 #include "DGtal/io/Color.h"
38 #include "DGtal/shapes/Shapes.h"
39 #include "DGtal/helpers/StdDefs.h"
40 
42 
43 using namespace std;
44 using namespace DGtal;
45 using namespace Z3i;
46 
48 
49 
50 
51 int main( int argc, char** argv )
52 {
53 
54  trace.beginBlock ( "Example simple example of 3DViewer" );
55 
56  QApplication application(argc,argv);
57  Viewer3D viewer;
58  viewer.setWindowTitle("simpleExample3DViewer");
59  viewer.show();
60 
61  // Domain cretation from two bounding points.
62  Point c( 0, 0, 0 );
63  Point p1( -50, -50, -50 );
64  Point p2( 50, 50, 50 );
65  Domain domain( p1, p2 );
66 
67  trace.warning() << "Constructing a ring DigitalSet ... ";
68  DigitalSet shape_set( domain );
69  for ( Domain::ConstIterator it = domain.begin(); it != domain.end(); ++it )
70  {
71  if ( ((*it - c ).norm() <= 25) && ((*it - c ).norm() >= 18)
72  && ( (((*it)[0] <= 3)&& ((*it)[0] >= -3))|| (((*it)[1] <= 3)&& ((*it)[1] >= -3)))){
73  shape_set.insertNew( *it );
74  }
75  }
76  trace.warning() << " [Done]";
77 
78 
79  Object6_26 shape( dt6_26, shape_set );
80  int nb_simple=0;
81  int layer = 0;
82  do
83  {
84  DigitalSet & S = shape.pointSet();
85  std::queue<DigitalSet::Iterator> Q;
86  for ( DigitalSet::Iterator it = S.begin(); it != S.end(); ++it )
87  if ( shape.isSimple( *it ) )
88  Q.push( it );
89  nb_simple = 0;
90  while ( ! Q.empty() )
91  {
92  DigitalSet::Iterator it = Q.front();
93  Q.pop();
94  if ( shape.isSimple( *it ) )
95  {
96  cerr << "point simple " << (*it) << endl;
97  S.erase( *it );
98  ++nb_simple;
99  }
100  }
101  ++layer;
102  }
103  while ( nb_simple != 0 );
104 
105  DigitalSet & S = shape.pointSet();
106 
107  // Display by using two different list to manage OpenGL transparency.
108 
109  viewer << SetMode3D( shape_set.className(), "Paving" );
110  viewer << CustomColors3D(Color(25,25,255, 255), Color(25,25,255, 255));
111  viewer << S ;
112 
113  viewer << SetMode3D( shape_set.className(), "PavingTransp" );
114  viewer << CustomColors3D(Color(250, 0,0, 25), Color(250, 0,0, 5));
115  viewer << shape_set;
116 
117  viewer<< Viewer3D::updateDisplay;
118 
119 
120  trace.endBlock();
121  return application.exec();
122 
123 }
124 // //
126 
127