Commit f639e248 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey
Browse files

Merge cgogn:~thery/CGoGN

Resolved Conflicts:
	src/Algo/Import/ply.c
parents e3c67250 64fa7f53
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
#include "Algo/Import/import.h" #include "Algo/Import/import.h"
#include "Algo/Export/export.h" #include "Algo/Export/export.h"
using namespace CGoGN ; using namespace CGoGN ;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// // interface // // interface
...@@ -198,7 +200,7 @@ void MyQT::createMap(int n) ...@@ -198,7 +200,7 @@ void MyQT::createMap(int n)
{ {
if (dm.isMarked(d) && (!myMap.isBoundaryMarked(d))) if (dm.isMarked(d) && (!myMap.isBoundaryMarked(d)))
{ {
int n = random(); int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f; float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f; float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f; float b = float((n>>16)&0x7f)/255.0 + 0.25f;
...@@ -276,7 +278,7 @@ void MyQT::cb_keyPress(int keycode) ...@@ -276,7 +278,7 @@ void MyQT::cb_keyPress(int keycode)
{ {
if (!myMap.isBoundaryMarked(d)) if (!myMap.isBoundaryMarked(d))
{ {
int n = random(); int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f; float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f; float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f; float b = float((n>>16)&0x7f)/255.0 + 0.25f;
...@@ -391,7 +393,7 @@ void MyQT::importMesh(std::string& filename) ...@@ -391,7 +393,7 @@ void MyQT::importMesh(std::string& filename)
{ {
if (dm.isMarked(d) && (!myMap.isBoundaryMarked(d))) if (dm.isMarked(d) && (!myMap.isBoundaryMarked(d)))
{ {
int n = random(); int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f; float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f; float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f; float b = float((n>>16)&0x7f)/255.0 + 0.25f;
......
...@@ -121,6 +121,8 @@ protected: ...@@ -121,6 +121,8 @@ protected:
int per_vertex_color_float32, per_vertex_color_uint8 ; int per_vertex_color_float32, per_vertex_color_uint8 ;
int has_normals; int has_normals;
char *old_locale;
}; };
} // namespace CGoGN } // namespace CGoGN
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Utils/os_spec.h" #include "Utils/os_spec.h"
#include "Algo/Import/importPlyData.h" #include "Algo/Import/importPlyData.h"
#include <stdlib.h> #include <stdlib.h>
#include <locale.h>
namespace CGoGN namespace CGoGN
{ {
...@@ -64,6 +65,8 @@ PlyImportData::PlyImportData(): ...@@ -64,6 +65,8 @@ PlyImportData::PlyImportData():
per_vertex_color_uint8(0), per_vertex_color_uint8(0),
has_normals(0) has_normals(0)
{ {
old_locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
} }
PlyImportData::~PlyImportData() PlyImportData::~PlyImportData()
...@@ -89,6 +92,7 @@ PlyImportData::~PlyImportData() ...@@ -89,6 +92,7 @@ PlyImportData::~PlyImportData()
// } // }
// need to free *vert_other,*face_other ???? // need to free *vert_other,*face_other ????
setlocale(LC_NUMERIC, old_locale);
} }
......
...@@ -2070,12 +2070,14 @@ void get_binary_item( ...@@ -2070,12 +2070,14 @@ void get_binary_item(
{ {
char c[8]; char c[8];
void *ptr; void *ptr;
short word;
char *byte;
int my_endianness;
ptr = (void *) c; ptr = c;
word = 1 ;
short int word = 1 ; byte = (char *) &word ;
char *byte = (char *) &word ; my_endianness = byte[0] ? PLY_BINARY_LE : PLY_BINARY_BE ;
int my_endianness = byte[0] ? PLY_BINARY_LE : PLY_BINARY_BE ;
switch (type) { switch (type) {
case PLY_Int8: case PLY_Int8:
...@@ -2095,9 +2097,11 @@ void get_binary_item( ...@@ -2095,9 +2097,11 @@ void get_binary_item(
case PLY_Int16: case PLY_Int16:
if (my_endianness != file_type) if (my_endianness != file_type)
{ {
if (fread (ptr+1, 1, 1, fp) != 1) unsigned char *cptr;
cptr = (unsigned char*) ptr;
if (fread (cptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1) if (fread (cptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
} }
else else
...@@ -2110,9 +2114,11 @@ void get_binary_item( ...@@ -2110,9 +2114,11 @@ void get_binary_item(
case PLY_Uint16: case PLY_Uint16:
if (my_endianness != file_type) if (my_endianness != file_type)
{ {
if (fread (ptr+1, 1, 1, fp) != 1) unsigned char *cptr;
cptr = (unsigned char*) ptr;
if (fread (cptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1) if (fread (cptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
} }
else else
...@@ -2125,13 +2131,15 @@ void get_binary_item( ...@@ -2125,13 +2131,15 @@ void get_binary_item(
case PLY_Int32: case PLY_Int32:
if (my_endianness != file_type) if (my_endianness != file_type)
{ {
if (fread (ptr+3, 1, 1, fp) != 1) unsigned char *cptr;
cptr = (unsigned char*) ptr;
if (fread (cptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1) if (fread (cptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1) if (fread (cptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1) if (fread (cptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
} }
else else
...@@ -2144,13 +2152,15 @@ void get_binary_item( ...@@ -2144,13 +2152,15 @@ void get_binary_item(
case PLY_Uint32: case PLY_Uint32:
if (my_endianness != file_type) if (my_endianness != file_type)
{ {
if (fread (ptr+3, 1, 1, fp) != 1) unsigned char *cptr;
cptr = (unsigned char*) ptr;
if (fread (cptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1) if (fread (cptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1) if (fread (cptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1) if (fread (cptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
} }
else else
...@@ -2163,13 +2173,15 @@ void get_binary_item( ...@@ -2163,13 +2173,15 @@ void get_binary_item(
case PLY_Float32: case PLY_Float32:
if (my_endianness != file_type) if (my_endianness != file_type)
{ {
if (fread (ptr+3, 1, 1, fp) != 1) unsigned char *cptr;
cptr = (unsigned char*) ptr;
if (fread (cptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1) if (fread (cptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1) if (fread (cptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1) if (fread (cptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
} }
else else
...@@ -2182,21 +2194,23 @@ void get_binary_item( ...@@ -2182,21 +2194,23 @@ void get_binary_item(
case PLY_Float64: case PLY_Float64:
if (my_endianness != file_type) if (my_endianness != file_type)
{ {
if (fread (ptr+7, 1, 1, fp) != 1) unsigned char *cptr;
cptr = (unsigned char*) ptr;
if (fread (cptr+7, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+6, 1, 1, fp) != 1) if (fread (cptr+6, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+5, 1, 1, fp) != 1) if (fread (cptr+5, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+4, 1, 1, fp) != 1) if (fread (cptr+4, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+3, 1, 1, fp) != 1) if (fread (cptr+3, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+2, 1, 1, fp) != 1) if (fread (cptr+2, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr+1, 1, 1, fp) != 1) if (fread (cptr+1, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
if (fread (ptr, 1, 1, fp) != 1) if (fread (cptr, 1, 1, fp) != 1)
fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type); fprintf (stderr, "get_binary_item: problem occured in fread in switch(%d)\n", type);
} }
else else
......
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