36 #include <boost/program_options/options_description.hpp>
37 #include <boost/program_options/parsers.hpp>
38 #include <boost/program_options/variables_map.hpp>
40 #include <QtGui/qapplication.h>
41 #include "DGtal/base/Common.h"
42 #include "DGtal/io/readers/VolReader.h"
43 #include "DGtal/io/viewers/Viewer3D.h"
44 #include "DGtal/io/Display3D.h"
46 #include "DGtal/io/DrawWithDisplay3DModifier.h"
47 #include "DGtal/images/ImageSelector.h"
48 #include "DGtal/images/imagesSetsUtils/SetFromImage.h"
49 #include "DGtal/topology/DigitalSurface.h"
50 #include "DGtal/topology/DigitalSetBoundary.h"
51 #include "DGtal/topology/BreadthFirstVisitor.h"
52 #include "DGtal/geometry/surfaces/COBANaivePlane.h"
53 #include "DGtal/helpers/StdDefs.h"
54 #include "ConfigExamples.h"
59 using namespace DGtal;
60 namespace po = boost::program_options;
73 typedef SurfelSet::iterator SurfelSetIterator;
87 int main(
int argc,
char** argv )
91 po::options_description general_opt(
"Allowed options are: ");
92 general_opt.add_options()
93 (
"help,h",
"display this message")
94 (
"input-file,i", po::value<std::string>()->default_value( examplesPath +
"samples/Al.100.vol" ),
"the volume file (.vol)" )
95 (
"threshold,t", po::value<unsigned int>()->default_value(1),
"the value that defines the isosurface in the image (an integer between 0 and 255)." )
96 (
"width-num,w", po::value<unsigned int>()->default_value(1),
"the numerator of the rational width (a non-null integer)." )
97 (
"width-den,d", po::value<unsigned int>()->default_value(1),
"the denominator of the rational width (a non-null integer)." );
100 po::variables_map vm;
102 po::store(po::parse_command_line(argc, argv, general_opt), vm);
103 }
catch (
const std::exception & ex ) {
105 trace.
info() <<
"Error checking program options: "<< ex.what()<< endl;
108 if ( ! parseOK || vm.count(
"help") || ( argc <= 1 ) )
110 std::cout <<
"Usage: " << argv[0]
111 <<
" [-i <fileName.vol>] [-t <threshold>] [-w <num>] [-d <den>]" << std::endl
112 <<
"Segments the surface at given threshold within given volume into digital planes of rational width num/den." << std::endl
113 << general_opt << std::endl;
116 string inputFilename = vm[
"input-file"].as<std::string>();
117 unsigned int threshold = vm[
"threshold"].as<
unsigned int>();
118 unsigned int widthNum = vm[
"width-num"].as<
unsigned int>();
119 unsigned int widthDen = vm[
"width-den"].as<
unsigned int>();
123 QApplication application(argc,argv);
135 bool ok = ks.
init( set3d.domain().lowerBound(),
136 set3d.domain().upperBound(), true );
137 if ( ! ok ) std::cerr <<
"[KSpace.init] Failed." << std::endl;
147 std::set<Vertex> processedVertices;
148 std::vector<SegmentedPlane*> segmentedPlanes;
149 std::map<Vertex,SegmentedPlane*> v2plane;
153 unsigned int nb = digSurf.
size();
154 for ( ConstIterator it = digSurf.begin(), itE= digSurf.end(); it != itE; ++it )
158 if ( processedVertices.find( v ) != processedVertices.end() )
162 segmentedPlanes.push_back( ptrSegment );
164 ptrSegment->
plane.
init( axis, 500, widthNum, widthDen );
167 while ( ! visitor.finished() )
171 if ( processedVertices.find( v ) == processedVertices.end() )
178 processedVertices.insert( v );
179 v2plane[ v ] = ptrSegment;
189 ptrSegment->
color =
Color( random() % 256, random() % 256, random() % 256, 255 );
197 for ( std::map<Vertex,SegmentedPlane*>::const_iterator
198 it = v2plane.begin(), itE = v2plane.end();
202 viewer << ks.
unsigns( it->first );
204 viewer << Display3D::updateDisplay;
208 for ( std::vector<SegmentedPlane*>::iterator
209 it = segmentedPlanes.begin(), itE = segmentedPlanes.end();
212 segmentedPlanes.clear();
216 return application.exec();