DGtal  0.9.3
shapeDTViewer.cpp
1 
31 #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 #include "DGtal/io/DrawWithDisplay3DModifier.h"
45 #include "DGtal/io/viewers/Viewer3D.h"
46 
47 #include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
48 #include "DGtal/io/colormaps/GradientColorMap.h"
49 #include "DGtal/helpers/StdDefs.h"
52 
53 using namespace DGtal;
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 
67 
69 
70 
71  viewer.show();
72  // viewer << mySet << DGtal::Display3D::updateDisplay;
73 
74 
77  DTL2 dt(&domain,&mySet,&Z3i::l2Metric );
79 
80  DTL2::Value maxDT = (*std::max_element(dt.constRange().begin(),
81  dt.constRange().end()));
82 
83 
84  GradientColorMap<DTL2::Value> gradient( 0, maxDT);
85  gradient.addColor(DGtal::Color::Blue);
86  gradient.addColor(DGtal::Color::Green);
87  gradient.addColor(DGtal::Color::Yellow);
88  gradient.addColor(DGtal::Color::Red);
89 
90 
92  itend = domain.end(); it != itend;
93  ++it)
94  if (dt(*it) != 0)
95  {
96  DTL2::Value val= dt( *it );
97  DGtal::Color c= gradient(val);
98 
99  viewer << DGtal::CustomColors3D(c,c) << *it ;
100 
101  }
102 
103 
104  viewer << DGtal::ClippingPlane(1,0,0,0);
105  //@todo updateDisplay is in Display3D or Viewer3D (cf doc)?
106  viewer << DGtal::Viewer3D<>::updateDisplay;
107 
108  return application.exec();
109 
110 
111 }
112 
const ConstIterator & end() const
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
Aim: Implementation of the linear in time distance transformation for separable metrics.
const Domain domain(Point(1, 2), Point(6, 5))
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
static void euclideanShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor, const double h=1.0)
static const Color Yellow
Definition: Color.h:397
static const Color Blue
Definition: Color.h:394
const ConstIterator & begin() const
int main(int argc, char **argv)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
static const L2Metric l2Metric
Definition: StdDefs.h:204
static const Color Red
Definition: Color.h:391
Class for adding a Clipping plane through the Viewer3D stream. Realizes the concept CDrawableWithView...
static const Color Green
Definition: Color.h:392