DGtal 1.4.0
Loading...
Searching...
No Matches
test3DImage3DView.cpp
Go to the documentation of this file.
1
31#include <iostream>
32#include "DGtal/base/Common.h"
33#include "DGtal/io/viewers/Viewer3D.h"
34#include "DGtal/io/DrawWithDisplay3DModifier.h"
35#include "DGtal/io/Color.h"
36#include "DGtal/io/readers/VolReader.h"
37#include "DGtal/helpers/StdDefs.h"
38#include "DGtal/shapes/Shapes.h"
39#include "DGtal/math/BasicMathFunctions.h"
40#include "ConfigTest.h"
41#include "DGtal/io/colormaps/HueShadeColorMap.h"
42
43
45
46using namespace std;
47using namespace DGtal;
48using namespace Z3i;
49
50
51
53// Functions for testing class Viewer3D.
55struct hueFct{
56inline
57 unsigned int operator() (unsigned int aVal) const
58 {
59 HueShadeColorMap<unsigned int> hueShade(0,255);
60 DGtal::Color col = hueShade(aVal);
61 return col.getRGB();
62 }
63};
65// Standard services - public :
66
67int main( int argc, char** argv )
68{
70
71 QApplication application(argc,argv);
72 Viewer3D<> viewer;
73 viewer.setWindowTitle("simpleViewer");
74 viewer.show();
75 trace.beginBlock("Testing Viewer with display of 3D Image ");
76
77 Point p1( 0, 0, 0 );
78 Point p2( 125, 188, 0 );
79 Point p3( 30, 30, 30 );
80
81 std::string filename = testPath + "samples/lobsterCroped.vol";
82 hueFct huefct;
83
84 viewer.setFillTransparency(150);
85 Image3D image3d = VolReader<Image3D>::importVol(filename);
86 viewer << SetMode3D(image3d.className(), "BoundingBox");
87
88 viewer << DGtal::AddTextureImage3DWithFunctor<Image3D, hueFct , Space, KSpace>(image3d, huefct, Viewer3D<>::RGBMode );
89 viewer.setFillTransparency(255);
90 // Extract some slice images:
91 // Get the 2D domain of the slice:
93 DGtal::Z2i::Domain domain2D(invFunctor(image3d.domain().lowerBound()),
94 invFunctor(image3d.domain().upperBound()));
95
97 Image3D::Value, functors::Identity > SliceImageAdapter;
99 functors::Projector<DGtal::Z3i::Space> aSliceFunctorZ(5); aSliceFunctorZ.initAddOneDim(2);
100
101 SliceImageAdapter sliceImageZ(image3d, domain2D, aSliceFunctorZ, idV);
102
103 viewer << sliceImageZ;
104 viewer << DGtal::UpdateImagePosition<Space, KSpace>(6, Viewer3D<>::zDirection, 0.0, 0.0, -10.0);
105
106 viewer << p1 << p2 << p3;
107 viewer << Viewer3D<>::updateDisplay;
108
109
110 bool res = application.exec();
111 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
112 trace.endBlock();
113 return res ? 0 : 1;
114
115
116}
117// //
119
Structure representing an RGB triple with alpha component.
Definition Color.h:68
DGtal::uint32_t getRGB() const
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
virtual void setFillTransparency(unsigned char alpha)
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
double endBlock()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Aim: Define a simple default functor that just returns its argument.
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...
void initAddOneDim(const Dimension &newDim)
void initRemoveOneDim(const Dimension &dimRemoved)
int main()
Definition testBits.cpp:56