31 #include "DGtal/base/Common.h"
33 #include "DGtal/io/readers/MeshReader.h"
34 #include "DGtal/io/writers/MeshWriter.h"
35 #include "DGtal/io/Display3D.h"
36 #include "DGtal/shapes/Mesh.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;
69 namespace po = boost::program_options;
72 int main(
int argc,
char** argv )
75 po::options_description general_opt(
"Allowed options are: ");
76 general_opt.add_options()
77 (
"help,h",
"display this message")
78 (
"input,i", po::value<std::string>(),
"ofs file (.ofs) " )
79 (
"output,o", po::value<std::string>(),
"ofs file (.off) " );
85 po::store(po::parse_command_line(argc, argv, general_opt), vm);
86 }
catch(
const std::exception& ex){
88 trace.
info()<<
"Error checking program options: "<< ex.what()<< endl;
91 if( !parseOK || vm.count(
"help")||argc<=1)
93 std::cout <<
"Usage: " << argv[0] <<
" [input] [output]\n"
94 <<
"Convert OFS file into OFF mesh format"
95 << general_opt <<
"\n";
99 if(! vm.count(
"input")||! vm.count(
"output"))
101 trace.
error() <<
" Input and output filename are needed to be defined" << endl;
106 string inputFilename = vm[
"input"].as<std::string>();
107 string outputFilename = vm[
"output"].as<std::string>();
111 bool import = anImportedMesh << inputFilename;
112 bool exported = anImportedMesh >> outputFilename;
113 if(!
import || !exported){
114 trace.
info() <<
"Conversion failed: " << (exported?
"Reading OFS failed. ":
"Export OFF failed. ") << std::endl;
Trace trace(traceWriterTerm)