Commit 493aa1ac authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

Added utility in viewer to export a mesh into all available exported types.

Added utility in viewer to do this in command-line using 2 arguments : for example "./viewer input.off output.ply"
A set of data is btw available here : http://canaris.u-strasbg.fr/~kenneth/share/DataGeometry/
parent 167905bb
......@@ -175,9 +175,10 @@ void Viewer::cb_Open()
void Viewer::cb_Save()
{
std::string filters("off (*.off)") ;
std::string filters("all (*.*);; off (*.off);; ply (*.ply);; plygen (*.plygen)") ;
std::string filename = selectFileSave("Save Mesh", "", filters) ;
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
exportMesh(filename) ;
}
void Viewer::importMesh(std::string& filename)
......@@ -224,6 +225,20 @@ void Viewer::importMesh(std::string& filename)
updateGLMatrices() ;
}
void Viewer::exportMesh(std::string& filename)
{
size_t pos = filename.rfind(".") ; // position of "." in filename
std::string extension = filename.substr(pos) ;
if (extension.compare(std::string(".off")) == 0)
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
else if (extension.compare(0, 4, std::string(".ply")) == 0)
Algo::Export::exportPLY<PFP>(myMap, position, filename.c_str(), allDarts) ;
else
std::cerr << "Cannot save file " << filename << " : unknown or unhandled extension" << std::endl ;
}
void Viewer::slot_drawVertices(bool b)
{
m_drawVertices = b ;
......@@ -278,10 +293,19 @@ int main(int argc, char **argv)
sqt.setGeometry(0, 0, 1000, 800) ;
sqt.show() ;
if(argc == 2)
if(argc >= 2)
{
std::string filename(argv[1]) ;
sqt.importMesh(filename) ;
if(argc >= 3)
{
std::string filenameExp(argv[2]) ;
std::cout << "Exporting " << filename << " as " << filenameExp << " ... "<< std::flush ;
sqt.exportMesh(filenameExp) ;
std::cout << "done!" << std::endl ;
return (0) ;
}
}
sqt.initGUI() ;
......
......@@ -112,6 +112,7 @@ public:
void cb_Open() ;
void cb_Save() ;
void exportMesh(std::string& filename) ;
void importMesh(std::string& filename) ;
public slots:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment