DGtal  1.1.0
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"
50 
51 #include <boost/algorithm/minmax_element.hpp>
53 
54 
56 
57 using namespace DGtal;
58 
59 int main(int argc, char **argv)
60 {
61  QApplication application(argc,argv);
62 
63  DGtal::Viewer3D<> viewer;
64 
65  DGtal::Z3i::Point center(0,0,0);
66  DGtal::ImplicitRoundedHyperCube<Z3i::Space> myCube( center, 20, 2.8);
67  DGtal::Z3i::Domain domain(myCube.getLowerBound(),
68  myCube.getUpperBound());
69 
71 
73 
74 
75  viewer.show();
76  // viewer << mySet << DGtal::Display3D::updateDisplay;
77 
78 
81  DTL2 dt(&domain,&mySet,&Z3i::l2Metric );
83 
84  DTL2::Value maxDT = (*boost::first_max_element(dt.constRange().begin(),
85  dt.constRange().end()));
86 
87 
88  GradientColorMap<DTL2::Value> gradient( 0, maxDT);
89  gradient.addColor(DGtal::Color::Blue);
90  gradient.addColor(DGtal::Color::Green);
91  gradient.addColor(DGtal::Color::Yellow);
92  gradient.addColor(DGtal::Color::Red);
93 
94 
96  itend = domain.end(); it != itend;
97  ++it)
98  if (dt(*it) != 0)
99  {
100  DTL2::Value val= dt( *it );
101  DGtal::Color c= gradient(val);
102 
103  viewer << DGtal::CustomColors3D(c,c) << *it ;
104 
105  }
106 
107 
108  viewer << DGtal::ClippingPlane(1,0,0,0);
109  //@todo updateDisplay is in Display3D or Viewer3D (cf doc)?
110  viewer << DGtal::Viewer3D<>::updateDisplay;
111 
112  return application.exec();
113 
114 
115 }
116 
DGtal::HyperRectDomain< Space >
DGtal::ImplicitRoundedHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
Definition: ImplicitRoundedHyperCube.h:63
DGtal::Color::Green
static const Color Green
Definition: Color.h:401
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::Color::Yellow
static const Color Yellow
Definition: Color.h:406
DGtal::Z3i::l2Metric
static const L2Metric l2Metric
Definition: StdDefs.h:204
DGtal::Color::Blue
static const Color Blue
Definition: Color.h:403
DGtal::Color::Red
static const Color Red
Definition: Color.h:400
DGtal::Viewer3D
Definition: Viewer3D.h:133
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::CustomColors3D
Definition: DrawWithDisplay3DModifier.h:130
DGtal::HyperRectDomain::end
const ConstIterator & end() const
Definition: HyperRectDomain.h:201
DGtal::ClippingPlane
Class for adding a Clipping plane through the Viewer3D stream. Realizes the concept CDrawableWithView...
Definition: DrawWithDisplay3DModifier.h:157
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:154
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal::DistanceTransformation
Aim: Implementation of the linear in time distance transformation for separable metrics.
Definition: DistanceTransformation.h:100
DGtal::HyperRectDomain::begin
const ConstIterator & begin() const
Definition: HyperRectDomain.h:176
DGtal::GradientColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition: GradientColorMap.h:120
DGtal::Shapes::euclideanShaper
static void euclideanShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor, const double h=1.0)
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::DigitalSetByAssociativeContainer
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Definition: DigitalSetByAssociativeContainer.h:90