34 #include <QtGui/qapplication.h>
35 #include "DGtal/base/Common.h"
37 #include "DGtal/helpers/StdDefs.h"
38 #include "DGtal/topology/KhalimskySpaceND.h"
39 #include "DGtal/topology/SurfelAdjacency.h"
40 #include "DGtal/topology/DigitalSurface.h"
41 #include "DGtal/topology/SetOfSurfels.h"
42 #include "DGtal/topology/DigitalSurface2DSlice.h"
43 #include "DGtal/topology/helpers/Surfaces.h"
45 #include "DGtal/io/viewers/Viewer3D.h"
46 #include "DGtal/io/readers/VolReader.h"
47 #include "DGtal/io/DrawWithDisplay3DModifier.h"
48 #include "DGtal/images/ImageSelector.h"
49 #include "DGtal/images/imagesSetsUtils/SetFromImage.h"
50 #include "DGtal/io/Color.h"
51 #include "DGtal/io/colormaps/GradientColorMap.h"
53 #include "ConfigExamples.h"
57 using namespace DGtal;
61 int main(
int argc,
char** argv )
64 QApplication application(argc,argv);
69 std::string inputFilename = examplesPath +
"samples/Al.100.vol";
81 trace.
beginBlock(
"Construct the Khalimsky space from the image domain." );
83 bool space_ok = ks.
init( image.domain().lowerBound(),
84 image.domain().upperBound(), true );
87 trace.
error() <<
"Error in the Khamisky space construction."<<std::endl;
95 MySurfelAdjacency surfAdj(
true );
104 MySetOfSurfels theSetOfSurfels( ks, surfAdj );
107 image.domain().lowerBound(),
108 image.domain().upperBound() );
109 MyDigitalSurface digSurf( theSetOfSurfels );
110 trace.
info() <<
"Digital surface has " << digSurf.size() <<
" surfels."
120 Surfel surf = *digSurf.
begin();
121 MyTracker* tracker1 = digSurf.container().newTracker( surf );
122 MyTracker* tracker2 = digSurf.container().newTracker( surf );
125 My2DSlice slice1( tracker1, *(ks.
sDirs( surf )) );
128 My2DSlice slice2( tracker2, *++(ks.
sDirs( surf )) );
134 ASSERT( slice1.start() == slice1.begin() );
135 ASSERT( slice1.cstart() == slice1.c() );
136 ASSERT( *slice1.begin() == surf );
137 ASSERT( *slice1.c() == surf );
138 ASSERT( *slice1.start() == surf );
139 ASSERT( *slice1.cstart() == surf );
140 ASSERT( *slice1.rcstart() == surf );
141 ASSERT( slice1.rcstart() == slice1.rc() );
142 ASSERT( *slice1.rc() == surf );
143 ASSERT( *(slice1.c()+1) == *(slice1.begin()+1) );
144 ASSERT( *(slice1.rc()+1) == *(slice1.rbegin()) );
149 viewer <<
SetMode3D( surf.className(),
"Transparent");
151 it_end = theSetOfSurfels.end(); it != it_end; ++it )
157 cmap_grad.addColor(
Color( 255, 0, 0 ) );
158 cmap_grad.addColor(
Color( 255, 255, 10 ) );
161 viewer << Viewer3D::shiftSurfelVisu;
162 viewer <<
SetMode3D( surf.className(),
"");
163 viewer.setFillColor(
Color(180, 200, 25, 255));
166 for ( My2DSlice::ConstIterator it = slice1.begin(),
167 it_end = slice1.end(); it != it_end; ++it )
169 Color col= cmap_grad(d);
177 cmap_grad2.addColor(
Color( 255, 0, 0 ) );
178 cmap_grad2.addColor(
Color( 255, 255, 10 ) );
181 for ( My2DSlice::ConstIterator it = slice2.begin(),
182 it_end = slice2.end(); it != it_end; ++it )
184 Color col= cmap_grad2(d);
191 viewer << Viewer3D::shiftSurfelVisu;
192 viewer.setFillColor(
Color(18, 200, 25, 255));
194 viewer << Viewer3D::updateDisplay;
197 return application.exec();