33 #include <QtGui/qapplication.h> 
   34 #include "DGtal/base/Common.h" 
   36 #include "DGtal/helpers/StdDefs.h" 
   37 #include "DGtal/topology/KhalimskySpaceND.h" 
   38 #include "DGtal/topology/SurfelAdjacency.h" 
   39 #include "DGtal/topology/DigitalSurface.h" 
   40 #include "DGtal/topology/SetOfSurfels.h" 
   41 #include "DGtal/topology/DigitalSurface2DSlice.h" 
   42 #include "DGtal/topology/helpers/Surfaces.h" 
   44 #include "DGtal/io/viewers/Viewer3D.h" 
   45 #include "DGtal/io/readers/VolReader.h" 
   46 #include "DGtal/io/DrawWithDisplay3DModifier.h" 
   47 #include "DGtal/images/ImageSelector.h" 
   48 #include "DGtal/images/ImageHelper.h" 
   49 #include "DGtal/kernel/sets/DigitalSetInserter.h" 
   50 #include "DGtal/io/Color.h" 
   52 #include "DGtal/geometry/curves/GridCurve.h" 
   54 #include "ConfigExamples.h" 
   57 #include <boost/program_options/options_description.hpp> 
   58 #include <boost/program_options/parsers.hpp> 
   59 #include <boost/program_options/variables_map.hpp> 
   61 namespace po = boost::program_options;
 
   65 using namespace DGtal;
 
   69 int main( 
int argc, 
char** argv )
 
   74   po::options_description general_opt(
"Allowed options are");
 
   75   general_opt.add_options()
 
   76     (
"help,h", 
"display this message")
 
   77     (
"range,r",  po::value<string>()->default_value(
"gridcurve"), 
 
   78      " Either <gridcurve> (default), <inner>, <outer>, <incident> " ); 
 
   81   po::store(po::parse_command_line(argc, argv, general_opt), vm);  
 
   85       trace.
info()<< 
"exampleGridCurve3d" << std::endl
 
   86                   << 
"Basic usage: "<<std::endl
 
   87                   << argv[0] << 
" " << std::endl
 
   88                   << general_opt << 
"\n";
 
   93   string type = vm[
"range"].as<
string>(); 
 
   99   std::string inputFilename = examplesPath + 
"samples/cat10.vol"; 
 
  104   trace.
info() << set3d.size() << 
" voxels." << std::endl; 
 
  108   trace.
beginBlock( 
"Construct the Khalimsky space from the image domain." );
 
  121   MySurfelAdjacency surfAdj( 
true ); 
 
  128   MySetOfSurfels theSetOfSurfels( ks, surfAdj );
 
  131                                    image.
domain().lowerBound(), 
 
  132                                    image.
domain().upperBound() );
 
  133   MyDigitalSurface digSurf( theSetOfSurfels );
 
  134   trace.
info() << digSurf.size() << 
" surfels." << std::endl;
 
  138   trace.
beginBlock( 
"Extracting slice and constructing a grid curve. " );
 
  143   Surfel surf = *digSurf.
begin();
 
  144   MyTracker* tracker = digSurf.container().newTracker( surf );
 
  148   My2DSlice slice( tracker, *(ks.
sDirs( surf )) ); 
 
  153   gc.initFromSCellsRange( slice.begin(), slice.end() ); 
 
  160   QApplication application(argc,argv);
 
  165   viewer << 
SetMode3D( surf.className(), 
"Transparent");
 
  167          it_end = theSetOfSurfels.end(); it != it_end; ++it )
 
  172   viewer << Viewer3D::shiftSurfelVisu; 
 
  173   viewer << 
SetMode3D( surf.className(), 
"");
 
  176   if (type == 
"gridcurve")
 
  180   else if (type == 
"inner")
 
  182       viewer << gc.getInnerPointsRange(); 
 
  184   else if (type == 
"outer")
 
  186       viewer << gc.getOuterPointsRange(); 
 
  188   else if (type == 
"incident")
 
  190       viewer << gc.getIncidentPointsRange(); 
 
  194       trace.
info() << 
"Display type not known. Use option -h" << std::endl; 
 
  197   viewer << Viewer3D::updateDisplay;
 
  200   return application.exec();