DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
shapeDTViewer.cpp
1 
31 
32 #include <iostream>
33 #include <fstream>
34 #include <algorithm>
36 
38 #include "DGtal/base/Common.h"
39 #include "DGtal/helpers/StdDefs.h"
40 #include "ConfigExamples.h"
41 
42 #include "DGtal/shapes/Shapes.h"
43 #include "DGtal/shapes/ShapeFactory.h"
44 
45 #include <QtGui/qapplication.h>
46 #include "DGtal/io/viewers/Viewer3D.h"
47 #include "DGtal/io/DrawWithDisplay3DModifier.h"
48 
49 #include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
50 #include "DGtal/kernel/sets/SetPredicate.h"
51 #include "DGtal/io/colormaps/GradientColorMap.h"
54 
55 int main(int argc, char **argv)
56 {
57  QApplication application(argc,argv);
58 
59  DGtal::Viewer3D viewer;
60 
61  DGtal::Z3i::Point center(0,0,0);
62  DGtal::ImplicitRoundedHyperCube<Z3i::Space> myCube( center, 20, 2.8);
63  DGtal::Z3i::Domain domain(myCube.getLowerBound(),
64  myCube.getUpperBound());
65 
66  DGtal::Z3i::DigitalSet mySet(domain);
67 
69 
70 
71  viewer.show();
72  // viewer << mySet << DGtal::Display3D::updateDisplay;
73 
74 
77  Predicate aPredicate(mySet);
78 
80  typedef DTL2::OutputImage OutputImage;
81  DTL2 dt(domain,aPredicate);
82 
83  OutputImage result = dt.compute();
85 
86  OutputImage::Value maxDT = (*std::max_element(result.begin(),
87  result.end()));
88 
89 
90  GradientColorMap<OutputImage::Value> gradient( 0, maxDT);
91  gradient.addColor(DGtal::Color::Blue);
92  gradient.addColor(DGtal::Color::Green);
93  gradient.addColor(DGtal::Color::Yellow);
94  gradient.addColor(DGtal::Color::Red);
95 
96 
97  for(Z3i::Domain::ConstIterator it = domain.begin(),
98  itend = domain.end(); it != itend;
99  ++it)
100  if (result(*it) != 0)
101  {
102  OutputImage::Value val= result( *it );
103  DGtal::Color c= gradient(val);
104 
105  viewer << DGtal::CustomColors3D(c,c) << *it ;
106 
107  }
108 
109 
110  viewer << DGtal::ClippingPlane(1,0,0,0);
111  //@todo updateDisplay is in Display3D or Viewer3D (cf doc)?
113 
114  return application.exec();
115 
116 
117 }
118