Commit c635365a authored by untereiner's avatar untereiner

Merge cgogn:~vanhoey/CGoGN

parents 2fc41558 e3c67250
......@@ -185,7 +185,7 @@ void Viewer::cb_Open()
void Viewer::cb_Save()
{
std::string filters("all (*.*);; map (*.map);; off (*.off);; ply (*.ply);; plygen (*.plygen)") ;
std::string filters("all (*.*);; map (*.map);; off (*.off);; ply (*.ply)") ;
std::string filename = selectFileSave("Save Mesh", "", filters) ;
exportMesh(filename) ;
......@@ -237,7 +237,7 @@ void Viewer::importMesh(std::string& filename)
updateGLMatrices() ;
}
void Viewer::exportMesh(std::string& filename)
void Viewer::exportMesh(std::string& filename, bool askExportMode)
{
size_t pos = filename.rfind(".") ; // position of "." in filename
std::string extension = filename.substr(pos) ;
......@@ -246,9 +246,13 @@ void Viewer::exportMesh(std::string& filename)
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
else if (extension.compare(0, 4, std::string(".ply")) == 0)
{
int ascii = 0 ;
if (askExportMode)
Utils::QT::inputValues(Utils::QT::VarCombo("binary mode;ascii mode",ascii,"Save in")) ;
std::vector<PFP::TVEC3*> attributes ;
attributes.push_back(&position) ;
Algo::Export::exportPLYnew<PFP>(myMap, attributes, filename.c_str(), true, allDarts) ;
Algo::Export::exportPLYnew<PFP>(myMap, attributes, filename.c_str(), !ascii, allDarts) ;
}
else if (extension == std::string(".map"))
myMap.saveMapBin(filename) ;
......@@ -325,7 +329,7 @@ int main(int argc, char **argv)
{
std::string filenameExp(argv[2]) ;
std::cout << "Exporting " << filename << " as " << filenameExp << " ... "<< std::flush ;
sqt.exportMesh(filenameExp) ;
sqt.exportMesh(filenameExp, false) ;
std::cout << "done!" << std::endl ;
return (0) ;
......
......@@ -46,6 +46,7 @@
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/qtInputs.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
......@@ -117,7 +118,7 @@ public:
void cb_Save() ;
void importMesh(std::string& filename) ;
void exportMesh(std::string& filename);
void exportMesh(std::string& filename, bool askExportMode = true);
public slots:
void slot_drawVertices(bool b) ;
......
......@@ -1642,9 +1642,11 @@ void binary_get_element(PlyFile *plyfile, char *elem_ptr)
else if (prop->is_list == PLY_STRING) { /* string */
int len;
char *str;
fread (&len, sizeof(int), 1, fp);
if (fread (&len, sizeof(int), 1, fp) != sizeof(int))
fprintf (stderr, "binary_get_element: problem occured in fread\n");
str = (char *) myalloc (len);
fread (str, len, 1, fp);
if (fread (str, len, 1, fp) != len)
fprintf (stderr, "binary_get_element: problem occured in fread\n");
if (store_it) {
char **str_ptr;
item = elem_data + prop->offset;
......@@ -2077,13 +2079,15 @@ void get_binary_item(
switch (type) {
case PLY_Int8:
fread (ptr, 1, 1, fp);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*int_val = *((char *) ptr);
*uint_val = *int_val;
*double_val = *int_val;
break;
case PLY_Uint8:
fread (ptr, 1, 1, fp);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*uint_val = *((unsigned char *) ptr);
*int_val = *uint_val;
*double_val = *uint_val;
......@@ -2091,11 +2095,14 @@ void get_binary_item(
case PLY_Int16:
if (my_endianness != file_type)
{
fread (ptr+1, 1, 1, fp);
fread (ptr+0, 1, 1, fp);
if (fread (ptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
}
else
fread (ptr, 2, 1, fp);
if (fread (ptr, 1, 2, fp) != 2)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*int_val = *((short*) ptr) ;
*uint_val = *int_val;
*double_val = *int_val;
......@@ -2103,11 +2110,14 @@ void get_binary_item(
case PLY_Uint16:
if (my_endianness != file_type)
{
fread (ptr+1, 1, 1, fp);
fread (ptr+0, 1, 1, fp);
if (fread (ptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
}
else
fread (ptr, 2, 1, fp);
if (fread (ptr, 1, 2, fp) != 2)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*uint_val = *((unsigned short*) ptr) ;
*int_val = *uint_val;
*double_val = *uint_val;
......@@ -2115,13 +2125,18 @@ void get_binary_item(
case PLY_Int32:
if (my_endianness != file_type)
{
fread (ptr+3, 1, 1, fp);
fread (ptr+2, 1, 1, fp);
fread (ptr+1, 1, 1, fp);
fread (ptr+0, 1, 1, fp);
if (fread (ptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
}
else
fread (ptr, 4, 1, fp);
if (fread (ptr, 1, 4, fp) != 4)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*int_val = *((int*) ptr) ;
*uint_val = *int_val;
*double_val = *int_val;
......@@ -2129,13 +2144,18 @@ void get_binary_item(
case PLY_Uint32:
if (my_endianness != file_type)
{
fread (ptr+3, 1, 1, fp);
fread (ptr+2, 1, 1, fp);
fread (ptr+1, 1, 1, fp);
fread (ptr+0, 1, 1, fp);
if (fread (ptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
}
else
fread (ptr, 4, 1, fp);
if (fread (ptr, 1, 4, fp) != 4)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*uint_val = *((unsigned int*) ptr) ;
*int_val = *uint_val;
*double_val = *uint_val;
......@@ -2143,13 +2163,18 @@ void get_binary_item(
case PLY_Float32:
if (my_endianness != file_type)
{
fread (ptr+3, 1, 1, fp);
fread (ptr+2, 1, 1, fp);
fread (ptr+1, 1, 1, fp);
fread (ptr+0, 1, 1, fp);
if (fread (ptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
}
else
fread (ptr, 4, 1, fp);
if (fread (ptr, 1, 4, fp) != 4)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*double_val = *((float*) ptr) ;
*int_val = *double_val;
*uint_val = *double_val;
......@@ -2157,17 +2182,26 @@ void get_binary_item(
case PLY_Float64:
if (my_endianness != file_type)
{
fread (ptr+7, 1, 1, fp);
fread (ptr+6, 1, 1, fp);
fread (ptr+5, 1, 1, fp);
fread (ptr+4, 1, 1, fp);
fread (ptr+3, 1, 1, fp);
fread (ptr+2, 1, 1, fp);
fread (ptr+1, 1, 1, fp);
fread (ptr+0, 1, 1, fp);
if (fread (ptr+7, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+6, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+5, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+4, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
}
else
fread (ptr, 8, 1, fp);
if (fread (ptr, 1, 8, fp) != 8)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
*double_val = *((double*) ptr) ;
*int_val = *double_val;
*uint_val = *double_val;
......
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