fix typo + fix crash when loading tetramesh with double precision positions

This commit is contained in:
T.Alderighi 2018-05-25 11:58:32 +02:00
parent eb97fef7bd
commit 8d3548eb0c
2 changed files with 24 additions and 19 deletions

View File

@ -205,7 +205,7 @@ private:
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
ForEachTetra(*_m, [] (TetraType & t) {
ForEachTetra(*_m, [&] (TetraType & t) {
if (!t.IsD())
{
if (!t.IsS()) //draw as normal
@ -251,7 +251,7 @@ private:
glPolygonMode(GL_FRONT,GL_FILL);
}
ForEachTetra(*_m, [] (TetraType & t) {
ForEachTetra(*_m, [&] (TetraType & t) {
_DrawTetra<dm,nm,cm>(t);
});

View File

@ -141,16 +141,21 @@ public:
static const PropDescriptor &VertDesc(int i)
{
const static PropDescriptor pv[9]={
{"vertex", "x", ply::T_FLOAT, PlyType<ScalarType>(), offsetof(LoadPly_VertAux<ScalarType>,p),0,0,0,0,0},
{"vertex", "y", ply::T_FLOAT, PlyType<ScalarType>(), offsetof(LoadPly_VertAux<ScalarType>,p) + sizeof(ScalarType),0,0,0,0,0},
{"vertex", "z", ply::T_FLOAT, PlyType<ScalarType>(), offsetof(LoadPly_VertAux<ScalarType>,p) + 2 * sizeof(ScalarType),0,0,0,0,0},
{"vertex", "flags", ply::T_INT, ply::T_INT, offsetof(LoadPly_VertAux<ScalarType>,flags),0,0,0,0,0},
{"vertex", "quality", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_VertAux<ScalarType>,q),0,0,0,0,0},
{"vertex", "red" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,r),0,0,0,0,0},
{"vertex", "green", ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,g),0,0,0,0,0},
{"vertex", "blue" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,b),0,0,0,0,0},
{"vertex", "alpha" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,a),0,0,0,0,0},
const static PropDescriptor pv[13]={
/*00*/ {"vertex", "x", ply::T_FLOAT, PlyType<ScalarType>(), offsetof(LoadPly_VertAux<ScalarType>,p),0,0,0,0,0},
/*01*/ {"vertex", "y", ply::T_FLOAT, PlyType<ScalarType>(), offsetof(LoadPly_VertAux<ScalarType>,p) + sizeof(ScalarType),0,0,0,0,0},
/*02*/ {"vertex", "z", ply::T_FLOAT, PlyType<ScalarType>(), offsetof(LoadPly_VertAux<ScalarType>,p) + 2 * sizeof(ScalarType),0,0,0,0,0},
/*03*/ {"vertex", "flags", ply::T_INT, ply::T_INT, offsetof(LoadPly_VertAux<ScalarType>,flags),0,0,0,0,0},
/*04*/ {"vertex", "quality", ply::T_FLOAT, ply::T_FLOAT, offsetof(LoadPly_VertAux<ScalarType>,q),0,0,0,0,0},
/*05*/ {"vertex", "red" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,r),0,0,0,0,0},
/*06*/ {"vertex", "green", ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,g),0,0,0,0,0},
/*07*/ {"vertex", "blue" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,b),0,0,0,0,0},
/*08*/ {"vertex", "alpha" , ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_VertAux<ScalarType>,a),0,0,0,0,0},
// DOUBLE
/*09*/ {"vertex", "x", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,p),0,0,0,0,0 ,0},
/*10*/ {"vertex", "y", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,p) + sizeof(ScalarType) ,0,0,0,0,0 ,0},
/*11*/ {"vertex", "z", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,p) + 2*sizeof(ScalarType),0,0,0,0,0 ,0},
/*12*/ {"vertex", "quality", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,q),0,0,0,0,0 ,0}
};
return pv[i];
}
@ -224,10 +229,10 @@ public:
pi.header = pf.GetHeader();
// Descrittori dati standard (vertex coord e faces)
if( pf.AddToRead(VertDesc(0)) == -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return -1; }
if( pf.AddToRead(VertDesc(1)) == -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return -1; }
if( pf.AddToRead(VertDesc(2)) == -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return -1; }
if( pf.AddToRead(TetraDesc(0))== -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return -1; }
if( pf.AddToRead(VertDesc(0)) == -1 && pf.AddToRead(VertDesc(9)) == -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
if( pf.AddToRead(VertDesc(1)) == -1 && pf.AddToRead(VertDesc(10)) == -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
if( pf.AddToRead(VertDesc(2)) == -1 && pf.AddToRead(VertDesc(11)) == -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
if( pf.AddToRead(TetraDesc(0)) == -1 ) { pi.status = PlyInfo::E_NO_VERTEX; return pi.status; }
// Descrittori facoltativi dei flags
if( pf.AddToRead(VertDesc(3)) != -1 )