Commit 2cffdbb3 authored by CGoGN GIT Supervisor's avatar CGoGN GIT Supervisor

Bug importObj

Bug drawer (Windows)
Change defines DART VERTEX ... in const int
change Uint32 ... defines in PLY_xxx in ply lib
parent 1666cc81
...@@ -443,7 +443,7 @@ bool MeshTablesSurface<PFP>::importObj(const std::string& filename, std::vector< ...@@ -443,7 +443,7 @@ bool MeshTablesSurface<PFP>::importObj(const std::string& filename, std::vector<
oss >> str; oss >> str;
unsigned int ind = 0; unsigned int ind = 0;
while ( (str[ind]!='/')&& (ind<str.length()) ) while ( (ind<str.length()) && (str[ind]!='/'))
ind++; ind++;
if (ind > 0) if (ind > 0)
......
...@@ -63,6 +63,7 @@ extern "C" { ...@@ -63,6 +63,7 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
#include <stddef.h> #include <stddef.h>
#define PLY_ASCII 1 /* ascii PLY file */ #define PLY_ASCII 1 /* ascii PLY file */
#define PLY_BINARY_BE 2 /* binary PLY file, big endian */ #define PLY_BINARY_BE 2 /* binary PLY file, big endian */
#define PLY_BINARY_LE 3 /* binary PLY file, little endian */ #define PLY_BINARY_LE 3 /* binary PLY file, little endian */
...@@ -72,16 +73,16 @@ extern "C" { ...@@ -72,16 +73,16 @@ extern "C" {
/* scalar data types supported by PLY format */ /* scalar data types supported by PLY format */
#define StartType 0 #define PLY_StartType 0
#define Int8 1 #define PLY_Int8 1
#define Int16 2 #define PLY_Int16 2
#define Int32 3 #define PLY_Int32 3
#define Uint8 4 #define PLY_Uint8 4
#define Uint16 5 #define PLY_Uint16 5
#define Uint32 6 #define PLY_Uint32 6
#define Float32 7 #define PLY_Float32 7
#define Float64 8 #define PLY_Float64 8
#define EndType 9 #define PLY_EndType 9
#define PLY_SCALAR 0 #define PLY_SCALAR 0
#define PLY_LIST 1 #define PLY_LIST 1
...@@ -249,7 +250,6 @@ int matches_rule_name (char *); ...@@ -249,7 +250,6 @@ int matches_rule_name (char *);
int equal_strings(char *, char *); int equal_strings(char *, char *);
char *recreate_command_line (int, char *argv[]); char *recreate_command_line (int, char *argv[]);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -30,6 +30,19 @@ ...@@ -30,6 +30,19 @@
namespace CGoGN namespace CGoGN
{ {
const unsigned int EMBNULL = 0xffffffff;
const unsigned int NB_ORBITS = 6;
const unsigned int NB_THREAD = 16;
const unsigned int VERTEX = 0;
const unsigned int EDGE = 1;
const unsigned int ORIENTED_FACE= 2;
const unsigned int FACE = 3;
const unsigned int VOLUME = 4;
const unsigned int DART = 5;
struct Dart struct Dart
{ {
unsigned int index; unsigned int index;
......
...@@ -34,28 +34,28 @@ ...@@ -34,28 +34,28 @@
#include <map> #include <map>
#define EMBNULL 0xffffffff
#define NB_ORBITS 6
#define NB_THREAD 16
#define VERTEX (unsigned int)(0)
#define EDGE (unsigned int)(1)
#define ORIENTED_FACE (unsigned int)(2)
#define FACE (unsigned int)(3)
#define VOLUME (unsigned int)(4)
#define DART (unsigned int)(5)
#include "Container/attributeContainer.h" #include "Container/attributeContainer.h"
#include "Topology/generic/dart.h" #include "Topology/generic/dart.h"
#include "Topology/generic/marker.h" #include "Topology/generic/marker.h"
#include "Topology/generic/functor.h" #include "Topology/generic/functor.h"
namespace CGoGN namespace CGoGN
{ {
/*
const unsigned int EMBNULL = 0xffffffff;
const unsigned int NB_ORBITS = 6;
const unsigned int NB_THREAD = 16;
const unsigned int VERTEX = 0;
const unsigned int EDGE = 1;
const unsigned int ORIENTED_FACE= 2;
const unsigned int FACE = 3;
const unsigned int VOLUME = 4;
const unsigned int DART = 5;
*/
/** /**
* Class that allows to browse a map * Class that allows to browse a map
* This is a pure virtual class that can be overloaded in: * This is a pure virtual class that can be overloaded in:
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define _MARKER_H_ #define _MARKER_H_
#include "Utils/mark.h" #include "Utils/mark.h"
#include "Topology/generic/dart.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -37,9 +38,9 @@ protected: ...@@ -37,9 +38,9 @@ protected:
public: public:
Marker(Mark m, unsigned int cell): Mark(m), m_cell(cell) {} Marker(Mark m, unsigned int cell): Mark(m), m_cell(cell) {}
#ifndef DART //#ifndef DART
#define DART (unsigned int)(5) //#define DART (unsigned int)(5)
#endif //#endif
Marker(): Mark(0), m_cell(DART) {} // TODO trouver un moyen propre de faire ça Marker(): Mark(0), m_cell(DART) {} // TODO trouver un moyen propre de faire ça
Marker operator+(const Marker m) const Marker operator+(const Marker m) const
......
...@@ -34,20 +34,20 @@ char* PlyImportData::elem_names[] = { /* list of the elements in the object */ ...@@ -34,20 +34,20 @@ char* PlyImportData::elem_names[] = { /* list of the elements in the object */
}; };
PlyProperty PlyImportData::vert_props[] = { /* list of property information for a vertex */ PlyProperty PlyImportData::vert_props[] = { /* list of property information for a vertex */
{(char*) "x", Float32, Float32, offsetof(Vertex,x), 0, 0, 0, 0}, {(char*) "x", PLY_Float32, PLY_Float32, offsetof(Vertex,x), 0, 0, 0, 0},
{(char*) "y", Float32, Float32, offsetof(Vertex,y), 0, 0, 0, 0}, {(char*) "y", PLY_Float32, PLY_Float32, offsetof(Vertex,y), 0, 0, 0, 0},
{(char*) "z", Float32, Float32, offsetof(Vertex,z), 0, 0, 0, 0}, {(char*) "z", PLY_Float32, PLY_Float32, offsetof(Vertex,z), 0, 0, 0, 0},
{(char*) "r", Float32, Float32, offsetof(Vertex,r), 0, 0, 0, 0}, {(char*) "r", PLY_Float32, PLY_Float32, offsetof(Vertex,r), 0, 0, 0, 0},
{(char*) "g", Float32, Float32, offsetof(Vertex,g), 0, 0, 0, 0}, {(char*) "g", PLY_Float32, PLY_Float32, offsetof(Vertex,g), 0, 0, 0, 0},
{(char*) "b", Float32, Float32, offsetof(Vertex,b), 0, 0, 0, 0}, {(char*) "b", PLY_Float32, PLY_Float32, offsetof(Vertex,b), 0, 0, 0, 0},
{(char*) "nx", Float32, Float32, offsetof(Vertex,nx), 0, 0, 0, 0}, {(char*) "nx", PLY_Float32, PLY_Float32, offsetof(Vertex,nx), 0, 0, 0, 0},
{(char*) "ny", Float32, Float32, offsetof(Vertex,ny), 0, 0, 0, 0}, {(char*) "ny", PLY_Float32, PLY_Float32, offsetof(Vertex,ny), 0, 0, 0, 0},
{(char*) "nz", Float32, Float32, offsetof(Vertex,nz), 0, 0, 0, 0}, {(char*) "nz", PLY_Float32, PLY_Float32, offsetof(Vertex,nz), 0, 0, 0, 0},
}; };
PlyProperty PlyImportData::face_props[] = { /* list of property information for a face */ PlyProperty PlyImportData::face_props[] = { /* list of property information for a face */
{(char*) "vertex_indices", Int32, Int32, offsetof(Face,verts), {(char*) "vertex_indices", PLY_Int32, PLY_Int32, offsetof(Face,verts),
1, Uint8, Uint8, offsetof(Face,nverts)}, 1, PLY_Uint8, PLY_Uint8, offsetof(Face,nverts)},
}; };
......
...@@ -40,6 +40,7 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. ...@@ -40,6 +40,7 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
#include <string.h> #include <string.h>
#include "Algo/Import/ply.h" #include "Algo/Import/ply.h"
char *type_names[] = { /* names of scalar types */ char *type_names[] = { /* names of scalar types */
"invalid", "invalid",
"int8", "int16", "int32", "uint8", "uint16", "uint32", "float32", "float64", "int8", "int16", "int32", "uint8", "uint16", "uint32", "float32", "float64",
...@@ -1674,7 +1675,7 @@ void write_scalar_type (FILE *fp, int code) ...@@ -1674,7 +1675,7 @@ void write_scalar_type (FILE *fp, int code)
{ {
/* make sure this is a valid code */ /* make sure this is a valid code */
if (code <= StartType || code >= EndType) { if (code <= PLY_StartType || code >= PLY_EndType) {
fprintf (stderr, "write_scalar_type: bad data code = %d\n", code); fprintf (stderr, "write_scalar_type: bad data code = %d\n", code);
exit (-1); exit (-1);
} }
...@@ -1825,35 +1826,35 @@ double get_item_value(char *item, int type) ...@@ -1825,35 +1826,35 @@ double get_item_value(char *item, int type)
double double_value; double double_value;
switch (type) { switch (type) {
case Int8: case PLY_Int8:
pchar = (char *) item; pchar = (char *) item;
int_value = *pchar; int_value = *pchar;
return ((double) int_value); return ((double) int_value);
case Uint8: case PLY_Uint8:
puchar = (unsigned char *) item; puchar = (unsigned char *) item;
int_value = *puchar; int_value = *puchar;
return ((double) int_value); return ((double) int_value);
case Int16: case PLY_Int16:
pshort = (short int *) item; pshort = (short int *) item;
int_value = *pshort; int_value = *pshort;
return ((double) int_value); return ((double) int_value);
case Uint16: case PLY_Uint16:
pushort = (unsigned short int *) item; pushort = (unsigned short int *) item;
int_value = *pushort; int_value = *pushort;
return ((double) int_value); return ((double) int_value);
case Int32: case PLY_Int32:
pint = (int *) item; pint = (int *) item;
int_value = *pint; int_value = *pint;
return ((double) int_value); return ((double) int_value);
case Uint32: case PLY_Uint32:
puint = (unsigned int *) item; puint = (unsigned int *) item;
uint_value = *puint; uint_value = *puint;
return ((double) uint_value); return ((double) uint_value);
case Float32: case PLY_Float32:
pfloat = (float *) item; pfloat = (float *) item;
double_value = *pfloat; double_value = *pfloat;
return (double_value); return (double_value);
case Float64: case PLY_Float64:
pdouble = (double *) item; pdouble = (double *) item;
double_value = *pdouble; double_value = *pdouble;
return (double_value); return (double_value);
...@@ -1892,33 +1893,33 @@ void write_binary_item( ...@@ -1892,33 +1893,33 @@ void write_binary_item(
float float_val; float float_val;
switch (type) { switch (type) {
case Int8: case PLY_Int8:
char_val = int_val; char_val = int_val;
fwrite (&char_val, 1, 1, fp); fwrite (&char_val, 1, 1, fp);
break; break;
case Int16: case PLY_Int16:
short_val = int_val; short_val = int_val;
fwrite (&short_val, 2, 1, fp); fwrite (&short_val, 2, 1, fp);
break; break;
case Int32: case PLY_Int32:
fwrite (&int_val, 4, 1, fp); fwrite (&int_val, 4, 1, fp);
break; break;
case Uint8: case PLY_Uint8:
uchar_val = uint_val; uchar_val = uint_val;
fwrite (&uchar_val, 1, 1, fp); fwrite (&uchar_val, 1, 1, fp);
break; break;
case Uint16: case PLY_Uint16:
ushort_val = uint_val; ushort_val = uint_val;
fwrite (&ushort_val, 2, 1, fp); fwrite (&ushort_val, 2, 1, fp);
break; break;
case Uint32: case PLY_Uint32:
fwrite (&uint_val, 4, 1, fp); fwrite (&uint_val, 4, 1, fp);
break; break;
case Float32: case PLY_Float32:
float_val = (float) double_val; float_val = (float) double_val;
fwrite (&float_val, 4, 1, fp); fwrite (&float_val, 4, 1, fp);
break; break;
case Float64: case PLY_Float64:
fwrite (&double_val, 8, 1, fp); fwrite (&double_val, 8, 1, fp);
break; break;
default: default:
...@@ -1948,18 +1949,18 @@ void write_ascii_item( ...@@ -1948,18 +1949,18 @@ void write_ascii_item(
) )
{ {
switch (type) { switch (type) {
case Int8: case PLY_Int8:
case Int16: case PLY_Int16:
case Int32: case PLY_Int32:
fprintf (fp, "%d ", int_val); fprintf (fp, "%d ", int_val);
break; break;
case Uint8: case PLY_Uint8:
case Uint16: case PLY_Uint16:
case Uint32: case PLY_Uint32:
fprintf (fp, "%u ", uint_val); fprintf (fp, "%u ", uint_val);
break; break;
case Float32: case PLY_Float32:
case Float64: case PLY_Float64:
fprintf (fp, "%g ", double_val); fprintf (fp, "%g ", double_val);
break; break;
default: default:
...@@ -1992,42 +1993,42 @@ void get_stored_item( ...@@ -1992,42 +1993,42 @@ void get_stored_item(
) )
{ {
switch (type) { switch (type) {
case Int8: case PLY_Int8:
*int_val = *((char *) ptr); *int_val = *((char *) ptr);
*uint_val = *int_val; *uint_val = *int_val;
*double_val = *int_val; *double_val = *int_val;
break; break;
case Uint8: case PLY_Uint8:
*uint_val = *((unsigned char *) ptr); *uint_val = *((unsigned char *) ptr);
*int_val = *uint_val; *int_val = *uint_val;
*double_val = *uint_val; *double_val = *uint_val;
break; break;
case Int16: case PLY_Int16:
*int_val = *((short int *) ptr); *int_val = *((short int *) ptr);
*uint_val = *int_val; *uint_val = *int_val;
*double_val = *int_val; *double_val = *int_val;
break; break;
case Uint16: case PLY_Uint16:
*uint_val = *((unsigned short int *) ptr); *uint_val = *((unsigned short int *) ptr);
*int_val = *uint_val; *int_val = *uint_val;
*double_val = *uint_val; *double_val = *uint_val;
break; break;
case Int32: case PLY_Int32:
*int_val = *((int *) ptr); *int_val = *((int *) ptr);
*uint_val = *int_val; *uint_val = *int_val;
*double_val = *int_val; *double_val = *int_val;
break; break;
case Uint32: case PLY_Uint32:
*uint_val = *((unsigned int *) ptr); *uint_val = *((unsigned int *) ptr);
*int_val = *uint_val; *int_val = *uint_val;
*double_val = *uint_val; *double_val = *uint_val;
break; break;
case Float32: case PLY_Float32:
*double_val = *((float *) ptr); *double_val = *((float *) ptr);
*int_val = *double_val; *int_val = *double_val;
*uint_val = *double_val; *uint_val = *double_val;
break; break;
case Float64: case PLY_Float64:
*double_val = *((double *) ptr); *double_val = *((double *) ptr);
*int_val = *double_val; *int_val = *double_val;
*uint_val = *double_val; *uint_val = *double_val;
...@@ -2067,49 +2068,49 @@ void get_binary_item( ...@@ -2067,49 +2068,49 @@ void get_binary_item(
ptr = (void *) c; ptr = (void *) c;
switch (type) { switch (type) {
case Int8: case PLY_Int8:
fread (ptr, 1, 1, fp); fread (ptr, 1, 1, fp);
*int_val = *((char *) ptr); *int_val = *((char *) ptr);
*uint_val = *int_val; *uint_val = *int_val;
*double_val = *int_val; *double_val = *int_val;
break; break;
case Uint8: case PLY_Uint8:
fread (ptr, 1, 1, fp); fread (ptr, 1, 1, fp);
*uint_val = *((unsigned char *) ptr); *uint_val = *((unsigned char *) ptr);
*int_val = *uint_val; *int_val = *uint_val;
*double_val = *uint_val; *double_val = *uint_val;
break; break;
case Int16: case PLY_Int16:
fread (ptr, 2, 1, fp); fread (ptr, 2, 1, fp);
*int_val = *((short int *) ptr); *int_val = *((short int *) ptr);
*uint_val = *int_val; *uint_val = *int_val;
*double_val = *int_val; *double_val = *int_val;
break; break;
case Uint16: case PLY_Uint16:
fread (ptr, 2, 1, fp); fread (ptr, 2, 1, fp);
*uint_val = *((unsigned short int *) ptr); *uint_val = *((unsigned short int *) ptr);
*int_val = *uint_val; *int_val = *uint_val;
*double_val = *uint_val; *double_val = *uint_val;
break; break;
case Int32: case PLY_Int32:
fread (ptr, 4, 1, fp); fread (ptr, 4, 1, fp);
*int_val = *((int *) ptr); *int_val = *((int *) ptr);
*uint_val = *int_val; *uint_val = *int_val;
*double_val = *int_val; *double_val = *int_val;
break; break;
case Uint32: case PLY_Uint32:
fread (ptr, 4, 1, fp); fread (ptr, 4, 1, fp);
*uint_val = *((unsigned int *) ptr); *uint_val = *((unsigned int *) ptr);
*int_val = *uint_val; *int_val = *uint_val;
*double_val = *uint_val; *double_val = *uint_val;
break; break;
case Float32: case PLY_Float32:
fread (ptr, 4, 1, fp); fread (ptr, 4, 1, fp);
*double_val = *((float *) ptr); *double_val = *((float *) ptr);
*int_val = *double_val; *int_val = *double_val;
*uint_val = *double_val; *uint_val = *double_val;
break; break;
case Float64: case PLY_Float64:
fread (ptr, 8, 1, fp); fread (ptr, 8, 1, fp);
*double_val = *((double *) ptr); *double_val = *((double *) ptr);
*int_val = *double_val; *int_val = *double_val;
...@@ -2145,24 +2146,24 @@ void get_ascii_item( ...@@ -2145,24 +2146,24 @@ void get_ascii_item(
) )
{ {
switch (type) { switch (type) {
case Int8: case PLY_Int8:
case Uint8: case PLY_Uint8:
case Int16: case PLY_Int16:
case Uint16: case PLY_Uint16:
case Int32: case PLY_Int32:
*int_val = atoi (word); *int_val = atoi (word);
*uint_val = *int_val; *uint_val = *int_val;
*double_val = *int_val; *double_val = *int_val;
break; break;
case Uint32: case PLY_Uint32:
*uint_val = strtoul (word, (char **) NULL, 10); *uint_val = strtoul (word, (char **) NULL, 10);
*int_val = *uint_val; *int_val = *uint_val;
*double_val = *uint_val; *double_val = *uint_val;
break; break;
case Float32: case PLY_Float32:
case Float64: case PLY_Float64:
*double_val = atof (word); *double_val = atof (word);
*int_val = (int) *double_val; *int_val = (int) *double_val;
*uint_val = (unsigned int) *double_val; *uint_val = (unsigned int) *double_val;
...@@ -2206,34 +2207,34 @@ void store_item ( ...@@ -2206,34 +2207,34 @@ void store_item (
double *pdouble; double *pdouble;
switch (type) { switch (type) {
case Int8: case PLY_Int8:
*item = int_val; *item = int_val;
break; break;
case Uint8: case PLY_Uint8:
puchar = (unsigned char *) item; puchar = (unsigned char *) item;
*puchar = uint_val; *puchar = uint_val;
break; break;
case Int16: case PLY_Int16:
pshort = (short *) item; pshort = (short *) item;
*pshort = int_val;