DGtalTools  1.2.0
ofs2off.cpp
1 
30 #include <iostream>
31 #include "DGtal/base/Common.h"
32 
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"
37 
38 #include "CLI11.hpp"
39 
40 
41 using namespace std;
42 using namespace DGtal;
43 
74 int main( int argc, char** argv )
75 {
76 // parse command line using CLI ----------------------------------------------
77  CLI::App app;
78  std::string inputFileName;
79  std::string outputFileName {"result.off"};
80 
81  app.description("Convert OFS file into OFF mesh format.");
82  app.add_option("-i,--input,1", inputFileName, "ofs file (.ofs)." )
83  ->required()
84  ->check(CLI::ExistingFile);
85  app.add_option("-o,--output,2", outputFileName, "ofs file (.off)");
86 
87  app.get_formatter()->column_width(40);
88  CLI11_PARSE(app, argc, argv);
89  // END parse command line using CLI ----------------------------------------------
90 
91  // We store the colors
92  Mesh<Z3i::RealPoint> anImportedMesh(true);
93  bool import = anImportedMesh << inputFileName;
94  bool exported = anImportedMesh >> outputFileName;
95  if(!import || !exported){
96  trace.info() << "Conversion failed: " << (exported? "Reading OFS failed. ": "Export OFF failed. ") << std::endl;
97  return 0;
98  }
99  trace.info() << "[done]. "<< std::endl;
100  return 0;
101 }
Definition: ATu0v1.h:57