diff --git a/wrap/io_trimesh/import_ply.h b/wrap/io_trimesh/import_ply.h index 36abda50..2d9d17c4 100644 --- a/wrap/io_trimesh/import_ply.h +++ b/wrap/io_trimesh/import_ply.h @@ -154,6 +154,7 @@ Initial commit #include #include #include +#include #include #include @@ -221,6 +222,15 @@ struct LoadPly_TristripAux unsigned char data[MAX_USER_DATA]; }; + +// Yet another auxiliary data structure for loading some strange ply files +// the original stanford range data... +struct LoadPly_RangeGridAux { + unsigned char num_pts; + int pts[5]; + }; + + // Struttura ausiliaria per la lettura del file ply template struct LoadPly_VertAux @@ -325,6 +335,16 @@ static const PropDescriptor &TristripDesc(int i) return qf[i]; } +// Descriptor for the Stanford Data Repository Range Maps. +// In practice a grid with some invalid elements. Coords are saved only for good elements +static const PropDescriptor &RangeDesc(int i) +{ + static const PropDescriptor range_props[1] = { + {"range_grid","vertex_indices", ply::T_INT, ply::T_INT, offsetof(LoadPly_RangeGridAux,pts), 1, 0, ply::T_UCHAR, ply::T_UCHAR, offsetof(LoadPly_RangeGridAux,num_pts)}, + }; + return range_props[i]; +} + static const PropDescriptor &CameraDesc(int i) { @@ -429,6 +449,12 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi ) LoadPly_TristripAux tsa; LoadPly_VertAux va; + LoadPly_RangeGridAux rga; + std::vector RangeGridAuxVec; + int RangeGridCols=0; + int RangeGridRows=0; + + pi.mask = 0; bool multit = false; // true if texture has a per face int spec the texture index @@ -481,11 +507,14 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi ) for(ii=_FACEDESC_FIRST_;ii< _FACEDESC_LAST_;++ii) if( pf.AddToRead(FaceDesc(ii))!=-1 ) break; - if(ii==_FACEDESC_LAST_) if(pf.AddToRead(TristripDesc(0))==-1) // Se fallisce tutto si prova a vedere se ci sono tristrip alla levoy. + if(ii==_FACEDESC_LAST_) + if(pf.AddToRead(TristripDesc(0))==-1) // Se fallisce tutto si prova a vedere se ci sono tristrip alla levoy. + if(pf.AddToRead(RangeDesc(0))==-1) // Se fallisce tutto si prova a vedere se ci sono rangemap alla levoy. { pi.status = PlyInfo::E_NO_FACE; //return pi.status; no face is not a critical error. let's continue. } + } // Descrittori facoltativi dei flags @@ -875,6 +904,55 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi ) } } } + else if( !strcmp( pf.ElemName(i),"range_grid") )//////////////////// LETTURA RANGEMAP DI STANFORD + { + //qDebug("Starting Reading of Range Grid"); + if(RangeGridCols==0) // not initialized. + { + for(int co=0;co