29 #include "DGtal/base/Common.h"
30 #include "DGtal/helpers/StdDefs.h"
31 #include "DGtal/io/readers/GenericReader.h"
32 #include "DGtal/io/boards/Board3D.h"
33 #include "DGtal/io/DrawWithDisplay3DModifier.h"
34 #include "DGtal/io/readers/PointListReader.h"
36 #include "DGtal/images/ImageSelector.h"
38 #include <boost/program_options/options_description.hpp>
39 #include <boost/program_options/parsers.hpp>
40 #include <boost/program_options/variables_map.hpp>
43 using namespace DGtal;
78 namespace po = boost::program_options;
81 int main(
int argc,
char** argv )
84 po::options_description general_opt(
"Allowed options are: ");
85 general_opt.add_options()(
"help,h",
"display this message" )
86 (
"input,i", po::value<std::string>(),
"vol file (.vol, .longvol .p3d, .pgm3d and if WITH_ITK is selected: dicom, dcm, mha, mhd) or sdp (sequence of discrete points)." )
87 (
"output,o", po::value<std::string>(),
88 "Output OBJ filename (each grid point with value between [ @a thresholdMin, @a thresholdMax ] is exported as a unit cube ) " )
89 (
"thresholdMin,m", po::value<int>()->default_value( 0 ),
"threshold min to define binary shape" )
90 (
"thresholdMax,M", po::value<int>()->default_value( 255 ),
"threshold max to define binary shape" )
91 (
"rescaleInputMin", po::value<DGtal::int64_t>()->default_value( 0 ),
"min value used to rescale the input intensity (to avoid basic cast into 8 bits image)." )
92 (
"rescaleInputMax",po::value<DGtal::int64_t>()->default_value( 255 ),
93 "max value used to rescale the input intensity (to avoid "
94 "basic cast into 8 bits image)." );
100 po::store(po::parse_command_line(argc, argv, general_opt), vm);
101 }
catch(
const std::exception& ex)
104 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
107 if( !parseOK || vm.count(
"help")||argc<=1)
109 std::cout <<
"Usage: " << argv[0] <<
" [input-file]\n"
110 <<
"Convert a volume file into OBJ format\n"
111 << general_opt <<
"\n";
115 if(! vm.count(
"input"))
117 trace.
error() <<
" The input filename was defined" << endl;
120 if(! vm.count(
"output"))
122 trace.
error() <<
" The output filename was defined" << endl;
126 string inputFilename = vm[
"input"].as<std::string>();
127 string outputFilename = vm[
"output"].as<std::string>();
128 int thresholdMin = vm[
"thresholdMin"].as<
int>();
129 int thresholdMax = vm[
"thresholdMax"].as<
int>();
134 string extension = inputFilename.substr(inputFilename.find_last_of(
".") + 1);
145 trace.
info() <<
"Image loaded: "<<image<< std::endl;
148 unsigned char val= image( (*it) );
149 if(val<=thresholdMax && val >=thresholdMin){
158 for(
unsigned int i=0;i< vectVoxels.size(); i++){
159 board << vectVoxels.at(i);
164 board.saveOBJ(outputFilename);
Trace trace(traceWriterTerm)
const Domain & domain() const
typename Self::Domain Domain