DGtal  1.0.0
test3DImage3DView.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/math/BasicMathFunctions.h"
#include "ConfigTest.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
Include dependency graph for test3DImage3DView.cpp:

Go to the source code of this file.


int main (int argc, char **argv)

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France

Functions for testing class Viewer3D.

This file is part of the DGtal library.

Definition in file test3DImage3DView.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 

Definition at line 67 of file test3DImage3DView.cpp.

68 {
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 ");
77  Point p1( 0, 0, 0 );
78  Point p2( 125, 188, 0 );
79  Point p3( 30, 30, 30 );
81  std::string filename = testPath + "samples/lobsterCroped.vol";
82  hueFct huefct;
84  viewer.setFillTransparency(150);
85  Image3D image3d = VolReader<Image3D>::importVol(filename);
86  viewer << SetMode3D(image3d.className(), "BoundingBox");
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()));
97  Image3D::Value, functors::Identity > SliceImageAdapter;
99  functors::Projector<DGtal::Z3i::Space> aSliceFunctorZ(5); aSliceFunctorZ.initAddOneDim(2);
101  SliceImageAdapter sliceImageZ(image3d, domain2D, aSliceFunctorZ, idV);
103  viewer << sliceImageZ;
104  viewer << DGtal::UpdateImagePosition<Space, KSpace>(6, Viewer3D<>::zDirection, 0.0, 0.0, -10.0);
106  viewer << p1 << p2 << p3;
107  viewer << Viewer3D<>::updateDisplay;
110  bool res = application.exec();
111  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
112  trace.endBlock();
113  return res ? 0 : 1;
116 }
void beginBlock(const std::string &keyword="")
virtual void setFillTransparency(unsigned char alpha)
Trace trace
Definition: Common.h:144
double endBlock()
void initRemoveOneDim(const Dimension &dimRemoved)
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...
Aim: Define a simple default functor that just returns its argument.
std::ostream & emphase()
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
Aim: implements a const image adapter with a given domain (i.e. a subdomain) and 2 functors : g for d...
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::functors::Projector< S >::initAddOneDim(), DGtal::functors::Projector< S >::initRemoveOneDim(), DGtal::Display3D< TSpace, TKSpace >::setFillTransparency(), DGtal::Viewer3D< TSpace, TKSpace >::show(), and DGtal::trace.