44#include "DGtal/base/Common.h"
46#include "DGtal/helpers/StdDefs.h"
47#include "DGtal/topology/KhalimskySpaceND.h"
48#include "DGtal/topology/SurfelAdjacency.h"
49#include "DGtal/topology/DigitalSurface.h"
50#include "DGtal/topology/SetOfSurfels.h"
51#include "DGtal/topology/DigitalSurface2DSlice.h"
52#include "DGtal/topology/helpers/Surfaces.h"
54#include "DGtal/io/readers/VolReader.h"
55#include "DGtal/io/DrawWithDisplay3DModifier.h"
56#include "DGtal/io/viewers/Viewer3D.h"
57#include "DGtal/images/ImageSelector.h"
58#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
59#include "DGtal/io/Color.h"
60#include "DGtal/io/colormaps/GradientColorMap.h"
62#include "ConfigExamples.h"
70int main(
int argc,
char** argv )
73 QApplication application(argc,argv);
78 std::string inputFilename = examplesPath +
"samples/Al.100.vol";
89 trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
91 bool space_ok = ks.
init( image.domain().lowerBound(),
92 image.domain().upperBound(),
true );
95 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
103 MySurfelAdjacency surfAdj(
true );
112 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
115 image.
domain().lowerBound(),
116 image.domain().upperBound() );
118 trace.
info() <<
"Digital surface has " << digSurf.
size() <<
" surfels."
129 MyTracker* tracker1 = digSurf.
container().newTracker( surf );
130 MyTracker* tracker2 = digSurf.
container().newTracker( surf );
133 My2DSlice slice1( tracker1, *(ks.
sDirs( surf )) );
136 My2DSlice slice2( tracker2, *++(ks.
sDirs( surf )) );
142 ASSERT( slice1.start() == slice1.begin() );
143 ASSERT( slice1.cstart() == slice1.c() );
144 ASSERT( *slice1.begin() == surf );
145 ASSERT( *slice1.c() == surf );
146 ASSERT( *slice1.start() == surf );
147 ASSERT( *slice1.cstart() == surf );
148 ASSERT( *slice1.rcstart() == surf );
149 ASSERT( slice1.rcstart() == slice1.rc() );
150 ASSERT( *slice1.rc() == surf );
151 ASSERT( *(slice1.c()+1) == *(slice1.begin()+1) );
152 ASSERT( *(slice1.rc()+1) == *(slice1.rbegin()) );
159 it_end = theSetOfSurfels.end(); it != it_end; ++it )
169 viewer << Viewer3D<>::shiftSurfelVisu;
174 for ( My2DSlice::ConstIterator it = slice1.begin(),
175 it_end = slice1.end(); it != it_end; ++it )
177 Color col= cmap_grad(d);
189 for ( My2DSlice::ConstIterator it = slice2.begin(),
190 it_end = slice2.end(); it != it_end; ++it )
192 Color col= cmap_grad2(d);
199 viewer << Viewer3D<>::shiftSurfelVisu;
202 viewer << Viewer3D<>::updateDisplay;
205 return application.exec();
Structure representing an RGB triple with alpha component.
void green(const unsigned char aGreenValue)
void red(const unsigned char aRedValue)
void blue(const unsigned char aBlueValue)
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
const Domain & domain() const
Aim: Represents a 2-dimensional slice in a DigitalSurface. In a sense, it is a 4-connected contour,...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
const DigitalSurfaceContainer & container() const
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
DigitalSurfaceContainer::DigitalSurfaceTracker DigitalSurfaceTracker
ConstIterator begin() const
virtual void setFillColor(DGtal::Color aColor)
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void addColor(const Color &color)
Aim: implements association bewteen points lying in a digital domain and values.
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DirIterator sDirs(const SCell &p) const
Given a signed cell [p], returns an iterator to iterate over each coordinate the cell spans.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
void beginBlock(const std::string &keyword="")
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
MyDigitalSurface::SurfelSet SurfelSet
DGtal is the top-level namespace which contains all DGtal functions and types.
ImageContainerBySTLVector< Domain, Value > Type
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
std::string className() const
Return the style name used for drawing this object.
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
ImageContainerBySTLVector< Domain, Value > Image