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<
oss >> str;
unsigned int ind = 0;
while ( (str[ind]!='/')&& (ind<str.length()) )
while ( (ind<str.length()) && (str[ind]!='/'))
ind++;
if (ind > 0)
......
......@@ -63,6 +63,7 @@ extern "C" {
#include <stdio.h>
#include <stddef.h>
#define PLY_ASCII 1 /* ascii PLY file */
#define PLY_BINARY_BE 2 /* binary PLY file, big endian */
#define PLY_BINARY_LE 3 /* binary PLY file, little endian */
......@@ -72,16 +73,16 @@ extern "C" {
/* scalar data types supported by PLY format */
#define StartType 0
#define Int8 1
#define Int16 2
#define Int32 3
#define Uint8 4
#define Uint16 5
#define Uint32 6
#define Float32 7
#define Float64 8
#define EndType 9
#define PLY_StartType 0
#define PLY_Int8 1
#define PLY_Int16 2
#define PLY_Int32 3
#define PLY_Uint8 4
#define PLY_Uint16 5
#define PLY_Uint32 6
#define PLY_Float32 7
#define PLY_Float64 8
#define PLY_EndType 9
#define PLY_SCALAR 0
#define PLY_LIST 1
......@@ -249,7 +250,6 @@ int matches_rule_name (char *);
int equal_strings(char *, char *);
char *recreate_command_line (int, char *argv[]);
#ifdef __cplusplus
}
#endif
......
......@@ -30,6 +30,19 @@
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
{
unsigned int index;
......
......@@ -34,28 +34,28 @@
#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 "Topology/generic/dart.h"
#include "Topology/generic/marker.h"
#include "Topology/generic/functor.h"
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
* This is a pure virtual class that can be overloaded in:
......
......@@ -26,6 +26,7 @@
#define _MARKER_H_
#include "Utils/mark.h"
#include "Topology/generic/dart.h"
namespace CGoGN
{
......@@ -37,9 +38,9 @@ protected:
public:
Marker(Mark m, unsigned int cell): Mark(m), m_cell(cell) {}
#ifndef DART
#define DART (unsigned int)(5)
#endif
//#ifndef DART
//#define DART (unsigned int)(5)
//#endif
Marker(): Mark(0), m_cell(DART) {} // TODO trouver un moyen propre de faire ça
Marker operator+(const Marker m) const
......
......@@ -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 */
{(char*) "x", Float32, Float32, offsetof(Vertex,x), 0, 0, 0, 0},
{(char*) "y", Float32, Float32, offsetof(Vertex,y), 0, 0, 0, 0},
{(char*) "z", Float32, Float32, offsetof(Vertex,z), 0, 0, 0, 0},
{(char*) "r", Float32, Float32, offsetof(Vertex,r), 0, 0, 0, 0},
{(char*) "g", Float32, Float32, offsetof(Vertex,g), 0, 0, 0, 0},
{(char*) "b", Float32, Float32, offsetof(Vertex,b), 0, 0, 0, 0},
{(char*) "nx", Float32, Float32, offsetof(Vertex,nx), 0, 0, 0, 0},
{(char*) "ny", Float32, Float32, offsetof(Vertex,ny), 0, 0, 0, 0},
{(char*) "nz", Float32, Float32, offsetof(Vertex,nz), 0, 0, 0, 0},
{(char*) "x", PLY_Float32, PLY_Float32, offsetof(Vertex,x), 0, 0, 0, 0},
{(char*) "y", PLY_Float32, PLY_Float32, offsetof(Vertex,y), 0, 0, 0, 0},
{(char*) "z", PLY_Float32, PLY_Float32, offsetof(Vertex,z), 0, 0, 0, 0},
{(char*) "r", PLY_Float32, PLY_Float32, offsetof(Vertex,r), 0, 0, 0, 0},
{(char*) "g", PLY_Float32, PLY_Float32, offsetof(Vertex,g), 0, 0, 0, 0},
{(char*) "b", PLY_Float32, PLY_Float32, offsetof(Vertex,b), 0, 0, 0, 0},
{(char*) "nx", PLY_Float32, PLY_Float32, offsetof(Vertex,nx), 0, 0, 0, 0},
{(char*) "ny", PLY_Float32, PLY_Float32, offsetof(Vertex,ny), 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 */
{(char*) "vertex_indices", Int32, Int32, offsetof(Face,verts),
1, Uint8, Uint8, offsetof(Face,nverts)},
{(char*) "vertex_indices", PLY_Int32, PLY_Int32, offsetof(Face,verts),
1, PLY_Uint8, PLY_Uint8, offsetof(Face,nverts)},
};
......
......@@ -40,6 +40,7 @@ WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
#include <string.h>
#include "Algo/Import/ply.h"
char *type_names[] = { /* names of scalar types */
"invalid",
"int8", "int16", "int32", "uint8", "uint16", "uint32", "float32", "float64",
......@@ -1674,7 +1675,7 @@ void write_scalar_type (FILE *fp, int 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);
exit (-1);
}
......@@ -1825,35 +1826,35 @@ double get_item_value(char *item, int type)
double double_value;
switch (type) {
case Int8:
case PLY_Int8:
pchar = (char *) item;
int_value = *pchar;
return ((double) int_value);
case Uint8:
case PLY_Uint8:
puchar = (unsigned char *) item;
int_value = *puchar;
return ((double) int_value);
case Int16:
case PLY_Int16:
pshort = (short int *) item;
int_value = *pshort;
return ((double) int_value);
case Uint16:
case PLY_Uint16:
pushort = (unsigned short int *) item;
int_value = *pushort;
return ((double) int_value);
case Int32:
case PLY_Int32:
pint = (int *) item;
int_value = *pint;
return ((double) int_value);
case Uint32:
case PLY_Uint32:
puint = (unsigned int *) item;
uint_value = *puint;
return ((double) uint_value);
case Float32:
case PLY_Float32:
pfloat = (float *) item;
double_value = *pfloat;
return (double_value);
case Float64:
case PLY_Float64:
pdouble = (double *) item;
double_value = *pdouble;
return (double_value);
......@@ -1892,33 +1893,33 @@ void write_binary_item(
float float_val;
switch (type) {
case Int8:
case PLY_Int8:
char_val = int_val;
fwrite (&char_val, 1, 1, fp);
break;
case Int16:
case PLY_Int16:
short_val = int_val;
fwrite (&short_val, 2, 1, fp);
break;
case Int32:
case PLY_Int32:
fwrite (&int_val, 4, 1, fp);
break;
case Uint8:
case PLY_Uint8:
uchar_val = uint_val;
fwrite (&uchar_val, 1, 1, fp);
break;
case Uint16:
case PLY_Uint16:
ushort_val = uint_val;
fwrite (&ushort_val, 2, 1, fp);
break;
case Uint32:
case PLY_Uint32:
fwrite (&uint_val, 4, 1, fp);
break;
case Float32:
case PLY_Float32:
float_val = (float) double_val;
fwrite (&float_val, 4, 1, fp);
break;
case Float64:
case PLY_Float64:
fwrite (&double_val, 8, 1, fp);
break;
default:
......@@ -1948,18 +1949,18 @@ void write_ascii_item(
)
{
switch (type) {
case Int8:
case Int16:
case Int32:
case PLY_Int8:
case PLY_Int16:
case PLY_Int32:
fprintf (fp, "%d ", int_val);
break;
case Uint8:
case Uint16:
case Uint32:
case PLY_Uint8:
case PLY_Uint16:
case PLY_Uint32:
fprintf (fp, "%u ", uint_val);
break;
case Float32:
case Float64:
case PLY_Float32:
case PLY_Float64:
fprintf (fp, "%g ", double_val);
break;
default:
......@@ -1992,42 +1993,42 @@ void get_stored_item(
)
{
switch (type) {
case Int8:
case PLY_Int8:
*int_val = *((char *) ptr);
*uint_val = *int_val;
*double_val = *int_val;
break;
case Uint8:
case PLY_Uint8:
*uint_val = *((unsigned char *) ptr);
*int_val = *uint_val;
*double_val = *uint_val;
break;
case Int16:
case PLY_Int16:
*int_val = *((short int *) ptr);
*uint_val = *int_val;
*double_val = *int_val;
break;
case Uint16:
case PLY_Uint16:
*uint_val = *((unsigned short int *) ptr);
*int_val = *uint_val;
*double_val = *uint_val;
break;
case Int32:
case PLY_Int32:
*int_val = *((int *) ptr);
*uint_val = *int_val;
*double_val = *int_val;
break;
case Uint32:
case PLY_Uint32:
*uint_val = *((unsigned int *) ptr);
*int_val = *uint_val;
*double_val = *uint_val;
break;
case Float32:
case PLY_Float32:
*double_val = *((float *) ptr);
*int_val = *double_val;
*uint_val = *double_val;
break;
case Float64:
case PLY_Float64:
*double_val = *((double *) ptr);
*int_val = *double_val;
*uint_val = *double_val;
......@@ -2067,49 +2068,49 @@ void get_binary_item(
ptr = (void *) c;
switch (type) {
case Int8:
case PLY_Int8:
fread (ptr, 1, 1, fp);
*int_val = *((char *) ptr);
*uint_val = *int_val;
*double_val = *int_val;
break;
case Uint8:
case PLY_Uint8:
fread (ptr, 1, 1, fp);
*uint_val = *((unsigned char *) ptr);
*int_val = *uint_val;
*double_val = *uint_val;
break;
case Int16:
case PLY_Int16:
fread (ptr, 2, 1, fp);
*int_val = *((short int *) ptr);
*uint_val = *int_val;
*double_val = *int_val;
break;
case Uint16:
case PLY_Uint16:
fread (ptr, 2, 1, fp);
*uint_val = *((unsigned short int *) ptr);
*int_val = *uint_val;
*double_val = *uint_val;
break;
case Int32:
case PLY_Int32:
fread (ptr, 4, 1, fp);
*int_val = *((int *) ptr);
*uint_val = *int_val;
*double_val = *int_val;
break;
case Uint32:
case PLY_Uint32:
fread (ptr, 4, 1, fp);
*uint_val = *((unsigned int *) ptr);
*int_val = *uint_val;
*double_val = *uint_val;
break;
case Float32:
case PLY_Float32:
fread (ptr, 4, 1, fp);
*double_val = *((float *) ptr);
*int_val = *double_val;
*uint_val = *double_val;
break;
case Float64:
case PLY_Float64:
fread (ptr, 8, 1, fp);
*double_val = *((double *) ptr);
*int_val = *double_val;
......@@ -2145,24 +2146,24 @@ void get_ascii_item(
)
{
switch (type) {
case Int8:
case Uint8:
case Int16:
case Uint16:
case Int32:
case PLY_Int8:
case PLY_Uint8:
case PLY_Int16:
case PLY_Uint16:
case PLY_Int32:
*int_val = atoi (word);
*uint_val = *int_val;
*double_val = *int_val;
break;
case Uint32:
case PLY_Uint32:
*uint_val = strtoul (word, (char **) NULL, 10);
*int_val = *uint_val;
*double_val = *uint_val;
break;
case Float32:
case Float64:
case PLY_Float32:
case PLY_Float64:
*double_val = atof (word);
*int_val = (int) *double_val;
*uint_val = (unsigned int) *double_val;
......@@ -2206,34 +2207,34 @@ void store_item (
double *pdouble;
switch (type) {
case Int8:
case PLY_Int8:
*item = int_val;
break;
case Uint8:
case PLY_Uint8:
puchar = (unsigned char *) item;
*puchar = uint_val;
break;
case Int16:
case PLY_Int16:
pshort = (short *) item;
*pshort = int_val;
break;
case Uint16:
case PLY_Uint16:
pushort = (unsigned short *) item;
*pushort = uint_val;
break;
case Int32:
case PLY_Int32:
pint = (int *) item;
*pint = int_val;
break;
case Uint32:
case PLY_Uint32:
puint = (unsigned int *) item;
*puint = uint_val;
break;
case Float32:
case PLY_Float32:
pfloat = (float *) item;
*pfloat = (float) double_val;
break;
case Float64:
case PLY_Float64:
pdouble = (double *) item;
*pdouble = double_val;
break;
......@@ -2291,12 +2292,12 @@ int get_prop_type(char *type_name)
int i;
/* try to match the type name */
for (i = StartType + 1; i < EndType; i++)
for (i = PLY_StartType + 1; i < PLY_EndType; i++)
if (equal_strings (type_name, type_names[i]))
return (i);
/* see if we can match an old type name */
for (i = StartType + 1; i < EndType; i++)
for (i = PLY_StartType + 1; i < PLY_EndType; i++)
if (equal_strings (type_name, old_type_names[i]))
return (i);
......@@ -2332,8 +2333,8 @@ void add_property (PlyFile *plyfile, char **words, int nwords)
prop->is_list = PLY_LIST;
}
else if (equal_strings (words[1], "string")) { /* string */
prop->count_external = Int8;
prop->external_type = Int8;
prop->count_external = PLY_Int8;
prop->external_type = PLY_Int8;
prop->name = strdup (words[2]);
prop->is_list = PLY_STRING;
}
......@@ -3317,3 +3318,4 @@ int matches_rule_name (char *name)
return (0);
}
......@@ -78,6 +78,9 @@ void Drawer::begin(GLenum mode)
void Drawer::end()
{
if (m_begins.empty())
return;
m_begins.back().nb = m_dataPos.size() - m_begins.back().begin;
}
......@@ -124,6 +127,9 @@ void Drawer::endList()
{
unsigned int nbElts = m_dataPos.size();
if (nbElts == 0)
return;
m_vboPos->bind();
glBufferData(GL_ARRAY_BUFFER, nbElts * sizeof(Geom::Vec3f), &(m_dataPos[0]), GL_STREAM_DRAW);
......
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