- improved support for double precision floating point attributes
This commit is contained in:
parent
adca0d032e
commit
eefdd5ddf6
|
@ -32,28 +32,31 @@
|
||||||
//#include<wrap/ply/io_mask.h>
|
//#include<wrap/ply/io_mask.h>
|
||||||
#include<wrap/io_trimesh/io_mask.h>
|
#include<wrap/io_trimesh/io_mask.h>
|
||||||
#include<wrap/io_trimesh/io_ply.h>
|
#include<wrap/io_trimesh/io_ply.h>
|
||||||
|
#include<wrap/io_trimesh/precision.h>
|
||||||
#include<vcg/container/simple_temporary_data.h>
|
#include<vcg/container/simple_temporary_data.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
namespace io {
|
namespace io {
|
||||||
|
|
||||||
|
|
||||||
template <class SaveMeshType>
|
|
||||||
class ExporterPLY
|
template <class SaveMeshType>
|
||||||
{
|
class ExporterPLY
|
||||||
|
{
|
||||||
// Si occupa di convertire da un tipo all'altro.
|
// Si occupa di convertire da un tipo all'altro.
|
||||||
// usata nella saveply per matchare i tipi tra stotype e memtype.
|
// usata nella saveply per matchare i tipi tra stotype e memtype.
|
||||||
// Ad es se in memoria c'e' un int e voglio salvare un float
|
// Ad es se in memoria c'e' un int e voglio salvare un float
|
||||||
// src sara in effetti un puntatore a int il cui valore deve
|
// src sara in effetti un puntatore a int il cui valore deve
|
||||||
// essere convertito al tipo di ritorno desiderato (stotype)
|
// essere convertito al tipo di ritorno desiderato (stotype)
|
||||||
|
|
||||||
template <class StoType>
|
template <class StoType>
|
||||||
static void PlyConv(int mem_type, void *src, StoType &dest)
|
static void PlyConv(int mem_type, void *src, StoType &dest)
|
||||||
{
|
{
|
||||||
switch (mem_type){
|
switch (mem_type){
|
||||||
case ply::T_FLOAT : dest = (StoType) (* ((float *) src)); break;
|
case ply::T_FLOAT : dest = (StoType) (* ((float *) src)); break;
|
||||||
case ply::T_DOUBLE: dest = (StoType) (* ((double *) src)); break;
|
case ply::T_DOUBLE: dest = (StoType) (* ((double *) src)); break;
|
||||||
|
@ -63,41 +66,46 @@ static void PlyConv(int mem_type, void *src, StoType &dest)
|
||||||
case ply::T_UCHAR : dest = (StoType) (* ((unsigned char *)src)); break;
|
case ply::T_UCHAR : dest = (StoType) (* ((unsigned char *)src)); break;
|
||||||
default : assert(0);
|
default : assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef ::vcg::ply::PropDescriptor PropDescriptor ;
|
typedef ::vcg::ply::PropDescriptor PropDescriptor ;
|
||||||
typedef typename SaveMeshType::VertexPointer VertexPointer;
|
typedef typename SaveMeshType::VertexPointer VertexPointer;
|
||||||
typedef typename SaveMeshType::ScalarType ScalarType;
|
typedef typename SaveMeshType::ScalarType ScalarType;
|
||||||
typedef typename SaveMeshType::VertexType VertexType;
|
typedef typename SaveMeshType::VertexType VertexType;
|
||||||
typedef typename SaveMeshType::FaceType FaceType;
|
typedef typename SaveMeshType::FaceType FaceType;
|
||||||
typedef typename SaveMeshType::FacePointer FacePointer;
|
typedef typename SaveMeshType::FacePointer FacePointer;
|
||||||
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
||||||
typedef typename SaveMeshType::FaceIterator FaceIterator;
|
typedef typename SaveMeshType::FaceIterator FaceIterator;
|
||||||
typedef typename SaveMeshType::EdgeIterator EdgeIterator;
|
typedef typename SaveMeshType::EdgeIterator EdgeIterator;
|
||||||
|
typedef typename SaveMeshType::ShotType::ScalarType ShotScalarType;
|
||||||
|
|
||||||
static int Save(SaveMeshType &m, const char * filename, bool binary=true)
|
static int Save(SaveMeshType &m, const char * filename, bool binary=true)
|
||||||
{
|
{
|
||||||
PlyInfo pi;
|
PlyInfo pi;
|
||||||
return Save(m,filename,binary,pi);
|
return Save(m,filename,binary,pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Save(SaveMeshType &m, const char * filename, int savemask, bool binary = true, CallBackPos *cb=0 )
|
static int Save(SaveMeshType &m, const char * filename, int savemask, bool binary = true, CallBackPos *cb=0 )
|
||||||
{
|
{
|
||||||
PlyInfo pi;
|
PlyInfo pi;
|
||||||
pi.mask=savemask;
|
pi.mask=savemask;
|
||||||
return Save(m,filename,binary,pi,cb);
|
return Save(m,filename,binary,pi,cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &pi, CallBackPos *cb=0) // V1.0
|
static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &pi, CallBackPos *cb=0) // V1.0
|
||||||
{
|
{
|
||||||
FILE * fpout;
|
FILE * fpout;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
const char * hbin = "binary_little_endian";
|
const char * hbin = "binary_little_endian";
|
||||||
const char * hasc = "ascii";
|
const char * hasc = "ascii";
|
||||||
const char * h;
|
const char * h;
|
||||||
|
//Coord ScalarType
|
||||||
|
const int DGT = vcg::tri::io::Precision<ScalarType>::digits();
|
||||||
|
const int DGTS = vcg::tri::io::Precision<ShotScalarType>::digits();
|
||||||
|
const int DGTVQ = vcg::tri::io::Precision<typename VertexType::QualityType>::digits();
|
||||||
|
const int DGTVR = vcg::tri::io::Precision<typename VertexType::RadiusType>::digits();
|
||||||
|
const int DGTFQ = vcg::tri::io::Precision<typename FaceType::QualityType>::digits();
|
||||||
bool multit = false;
|
bool multit = false;
|
||||||
|
|
||||||
if(binary) h=hbin;
|
if(binary) h=hbin;
|
||||||
|
@ -127,49 +135,44 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
|
|
||||||
if((pi.mask & Mask::IOM_CAMERA))
|
if((pi.mask & Mask::IOM_CAMERA))
|
||||||
{
|
{
|
||||||
fprintf(fpout,
|
const char* cmtp = vcg::tri::io::Precision<typename SaveMeshType::ShotType::ScalarType>::typeName();
|
||||||
"element camera 1\n"
|
fprintf(fpout,"element camera 1\n");
|
||||||
"property float view_px\n"
|
fprintf(fpout,"property %s view_px\n",cmtp);
|
||||||
"property float view_py\n"
|
fprintf(fpout,"property %s view_py\n",cmtp);
|
||||||
"property float view_pz\n"
|
fprintf(fpout,"property %s view_pz\n",cmtp);
|
||||||
"property float x_axisx\n"
|
fprintf(fpout,"property %s x_axisx\n",cmtp);
|
||||||
"property float x_axisy\n"
|
fprintf(fpout,"property %s x_axisy\n",cmtp);
|
||||||
"property float x_axisz\n"
|
fprintf(fpout,"property %s x_axisz\n",cmtp);
|
||||||
"property float y_axisx\n"
|
fprintf(fpout,"property %s y_axisx\n",cmtp);
|
||||||
"property float y_axisy\n"
|
fprintf(fpout,"property %s y_axisy\n",cmtp);
|
||||||
"property float y_axisz\n"
|
fprintf(fpout,"property %s y_axisz\n",cmtp);
|
||||||
"property float z_axisx\n"
|
fprintf(fpout,"property %s z_axisx\n",cmtp);
|
||||||
"property float z_axisy\n"
|
fprintf(fpout,"property %s z_axisy\n",cmtp);
|
||||||
"property float z_axisz\n"
|
fprintf(fpout,"property %s z_axisz\n",cmtp);
|
||||||
"property float focal\n"
|
fprintf(fpout,"property %s focal\n",cmtp);
|
||||||
"property float scalex\n"
|
fprintf(fpout,"property %s scalex\n",cmtp);
|
||||||
"property float scaley\n"
|
fprintf(fpout,"property %s scaley\n",cmtp);
|
||||||
"property float centerx\n"
|
fprintf(fpout,"property %s centerx\n",cmtp);
|
||||||
"property float centery\n"
|
fprintf(fpout,"property %s centery\n",cmtp);
|
||||||
"property int viewportx\n"
|
fprintf(fpout,"property int viewportx\n");
|
||||||
"property int viewporty\n"
|
fprintf(fpout,"property int viewporty\n");
|
||||||
"property float k1\n"
|
fprintf(fpout,"property %s k1\n",cmtp);
|
||||||
"property float k2\n"
|
fprintf(fpout,"property %s k2\n",cmtp);
|
||||||
"property float k3\n"
|
fprintf(fpout,"property %s k3\n",cmtp);
|
||||||
"property float k4\n"
|
fprintf(fpout,"property %s k4\n",cmtp);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fpout,
|
const char* vttp = vcg::tri::io::Precision<ScalarType>::typeName();
|
||||||
"element vertex %d\n"
|
fprintf(fpout,"element vertex %d\n",m.vn);
|
||||||
"property float x\n"
|
fprintf(fpout,"property %s x\n",vttp);
|
||||||
"property float y\n"
|
fprintf(fpout,"property %s y\n",vttp);
|
||||||
"property float z\n"
|
fprintf(fpout,"property %s z\n",vttp);
|
||||||
,m.vn
|
|
||||||
);
|
|
||||||
|
|
||||||
if( HasPerVertexNormal(m) &&( pi.mask & Mask::IOM_VERTNORMAL) )
|
if( HasPerVertexNormal(m) &&( pi.mask & Mask::IOM_VERTNORMAL) )
|
||||||
{
|
{
|
||||||
fprintf(fpout,
|
fprintf(fpout,"property %s nx\n",vttp);
|
||||||
"property float nx\n"
|
fprintf(fpout,"property %s ny\n",vttp);
|
||||||
"property float ny\n"
|
fprintf(fpout,"property %s nz\n",vttp);
|
||||||
"property float nz\n"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,16 +195,14 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
|
|
||||||
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) )
|
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) )
|
||||||
{
|
{
|
||||||
fprintf(fpout,
|
const char* vqtp = vcg::tri::io::Precision<typename VertexType::ScalarType>::typeName();
|
||||||
"property float quality\n"
|
fprintf(fpout,"property %s quality\n",vqtp);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( tri::HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) )
|
if( tri::HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) )
|
||||||
{
|
{
|
||||||
fprintf(fpout,
|
const char* rdtp = vcg::tri::io::Precision<typename VertexType::RadiusType>::typeName();
|
||||||
"property float radius\n"
|
fprintf(fpout,"property float radius\n",rdtp);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if( ( HasPerVertexTexCoord(m) && pi.mask & Mask::IOM_VERTTEXCOORD ) )
|
if( ( HasPerVertexTexCoord(m) && pi.mask & Mask::IOM_VERTTEXCOORD ) )
|
||||||
{
|
{
|
||||||
|
@ -257,9 +258,8 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
|
|
||||||
if( HasPerFaceQuality(m) && (pi.mask & Mask::IOM_FACEQUALITY) )
|
if( HasPerFaceQuality(m) && (pi.mask & Mask::IOM_FACEQUALITY) )
|
||||||
{
|
{
|
||||||
fprintf(fpout,
|
const char* fqtp = vcg::tri::io::Precision<typename SaveMeshType::FaceType::ScalarType>::typeName();
|
||||||
"property float quality\n"
|
fprintf(fpout,"property %s quality\n",fqtp);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0;i<pi.fdn;i++)
|
for(i=0;i<pi.fdn;i++)
|
||||||
|
@ -279,61 +279,61 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
{
|
{
|
||||||
if(binary)
|
if(binary)
|
||||||
{
|
{
|
||||||
float t[17];
|
ShotScalarType t[17];
|
||||||
|
|
||||||
t[ 0] = (float)m.shot.Extrinsics.Tra()[0];
|
t[ 0] = (ShotScalarType)m.shot.Extrinsics.Tra()[0];
|
||||||
t[ 1] = (float)m.shot.Extrinsics.Tra()[1];
|
t[ 1] = (ShotScalarType)m.shot.Extrinsics.Tra()[1];
|
||||||
t[ 2] = (float)m.shot.Extrinsics.Tra()[2];
|
t[ 2] = (ShotScalarType)m.shot.Extrinsics.Tra()[2];
|
||||||
t[ 3] = (float)m.shot.Extrinsics.Rot()[0][0];
|
t[ 3] = (ShotScalarType)m.shot.Extrinsics.Rot()[0][0];
|
||||||
t[ 4] = (float)m.shot.Extrinsics.Rot()[0][1];
|
t[ 4] = (ShotScalarType)m.shot.Extrinsics.Rot()[0][1];
|
||||||
t[ 5] = (float)m.shot.Extrinsics.Rot()[0][2];
|
t[ 5] = (ShotScalarType)m.shot.Extrinsics.Rot()[0][2];
|
||||||
t[ 6] = (float)m.shot.Extrinsics.Rot()[1][0];
|
t[ 6] = (ShotScalarType)m.shot.Extrinsics.Rot()[1][0];
|
||||||
t[ 7] = (float)m.shot.Extrinsics.Rot()[1][1];
|
t[ 7] = (ShotScalarType)m.shot.Extrinsics.Rot()[1][1];
|
||||||
t[ 8] = (float)m.shot.Extrinsics.Rot()[1][2];
|
t[ 8] = (ShotScalarType)m.shot.Extrinsics.Rot()[1][2];
|
||||||
t[ 9] = (float)m.shot.Extrinsics.Rot()[2][0];
|
t[ 9] = (ShotScalarType)m.shot.Extrinsics.Rot()[2][0];
|
||||||
t[10] = (float)m.shot.Extrinsics.Rot()[2][1];
|
t[10] = (ShotScalarType)m.shot.Extrinsics.Rot()[2][1];
|
||||||
t[11] = (float)m.shot.Extrinsics.Rot()[2][2];
|
t[11] = (ShotScalarType)m.shot.Extrinsics.Rot()[2][2];
|
||||||
t[12] = (float)m.shot.Intrinsics.FocalMm;
|
t[12] = (ShotScalarType)m.shot.Intrinsics.FocalMm;
|
||||||
t[13] = (float)m.shot.Intrinsics.PixelSizeMm[0];
|
t[13] = (ShotScalarType)m.shot.Intrinsics.PixelSizeMm[0];
|
||||||
t[14] = (float)m.shot.Intrinsics.PixelSizeMm[1];
|
t[14] = (ShotScalarType)m.shot.Intrinsics.PixelSizeMm[1];
|
||||||
t[15] = (float)m.shot.Intrinsics.CenterPx[0];
|
t[15] = (ShotScalarType)m.shot.Intrinsics.CenterPx[0];
|
||||||
t[16] = (float)m.shot.Intrinsics.CenterPx[1];
|
t[16] = (ShotScalarType)m.shot.Intrinsics.CenterPx[1];
|
||||||
fwrite(t,sizeof(float),17,fpout);
|
fwrite(t,sizeof(ShotScalarType),17,fpout);
|
||||||
|
|
||||||
fwrite( &m.shot.Intrinsics.ViewportPx[0],sizeof(int),2,fpout );
|
fwrite( &m.shot.Intrinsics.ViewportPx[0],sizeof(int),2,fpout );
|
||||||
|
|
||||||
t[ 0] = (float)m.shot.Intrinsics.k[0];
|
t[ 0] = (ShotScalarType)m.shot.Intrinsics.k[0];
|
||||||
t[ 1] = (float)m.shot.Intrinsics.k[1];
|
t[ 1] = (ShotScalarType)m.shot.Intrinsics.k[1];
|
||||||
t[ 2] = (float)m.shot.Intrinsics.k[2];
|
t[ 2] = (ShotScalarType)m.shot.Intrinsics.k[2];
|
||||||
t[ 3] = (float)m.shot.Intrinsics.k[3];
|
t[ 3] = (ShotScalarType)m.shot.Intrinsics.k[3];
|
||||||
fwrite(t,sizeof(float),4,fpout);
|
fwrite(t,sizeof(ShotScalarType),4,fpout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(fpout,"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d %d %g %g %g %g\n"
|
fprintf(fpout,"%.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %.*g %d %d %.*g %.*g %.*g %.*g\n"
|
||||||
,-m.shot.Extrinsics.Tra()[0]
|
,DGTS,-m.shot.Extrinsics.Tra()[0]
|
||||||
,-m.shot.Extrinsics.Tra()[1]
|
,DGTS,-m.shot.Extrinsics.Tra()[1]
|
||||||
,-m.shot.Extrinsics.Tra()[2]
|
,DGTS,-m.shot.Extrinsics.Tra()[2]
|
||||||
,m.shot.Extrinsics.Rot()[0][0]
|
,DGTS,m.shot.Extrinsics.Rot()[0][0]
|
||||||
,m.shot.Extrinsics.Rot()[0][1]
|
,DGTS,m.shot.Extrinsics.Rot()[0][1]
|
||||||
,m.shot.Extrinsics.Rot()[0][2]
|
,DGTS,m.shot.Extrinsics.Rot()[0][2]
|
||||||
,m.shot.Extrinsics.Rot()[1][0]
|
,DGTS,m.shot.Extrinsics.Rot()[1][0]
|
||||||
,m.shot.Extrinsics.Rot()[1][1]
|
,DGTS,m.shot.Extrinsics.Rot()[1][1]
|
||||||
,m.shot.Extrinsics.Rot()[1][2]
|
,DGTS,m.shot.Extrinsics.Rot()[1][2]
|
||||||
,m.shot.Extrinsics.Rot()[2][0]
|
,DGTS,m.shot.Extrinsics.Rot()[2][0]
|
||||||
,m.shot.Extrinsics.Rot()[2][1]
|
,DGTS,m.shot.Extrinsics.Rot()[2][1]
|
||||||
,m.shot.Extrinsics.Rot()[2][2]
|
,DGTS,m.shot.Extrinsics.Rot()[2][2]
|
||||||
,m.shot.Intrinsics.FocalMm
|
,DGTS,m.shot.Intrinsics.FocalMm
|
||||||
,m.shot.Intrinsics.PixelSizeMm[0]
|
,DGTS,m.shot.Intrinsics.PixelSizeMm[0]
|
||||||
,m.shot.Intrinsics.PixelSizeMm[1]
|
,DGTS,m.shot.Intrinsics.PixelSizeMm[1]
|
||||||
,m.shot.Intrinsics.CenterPx[0]
|
,DGTS,m.shot.Intrinsics.CenterPx[0]
|
||||||
,m.shot.Intrinsics.CenterPx[1]
|
,DGTS,m.shot.Intrinsics.CenterPx[1]
|
||||||
,m.shot.Intrinsics.ViewportPx[0]
|
,m.shot.Intrinsics.ViewportPx[0]
|
||||||
,m.shot.Intrinsics.ViewportPx[1]
|
,m.shot.Intrinsics.ViewportPx[1]
|
||||||
,m.shot.Intrinsics.k[0]
|
,DGTS,m.shot.Intrinsics.k[0]
|
||||||
,m.shot.Intrinsics.k[1]
|
,DGTS,m.shot.Intrinsics.k[1]
|
||||||
,m.shot.Intrinsics.k[2]
|
,DGTS,m.shot.Intrinsics.k[2]
|
||||||
,m.shot.Intrinsics.k[3]
|
,DGTS,m.shot.Intrinsics.k[3]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,17 +355,17 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
{
|
{
|
||||||
if(binary)
|
if(binary)
|
||||||
{
|
{
|
||||||
float t;
|
ScalarType t;
|
||||||
|
|
||||||
t = float(vp->P()[0]); fwrite(&t,sizeof(float),1,fpout);
|
t = ScalarType(vp->P()[0]); fwrite(&t,sizeof(ScalarType),1,fpout);
|
||||||
t = float(vp->P()[1]); fwrite(&t,sizeof(float),1,fpout);
|
t = ScalarType(vp->P()[1]); fwrite(&t,sizeof(ScalarType),1,fpout);
|
||||||
t = float(vp->P()[2]); fwrite(&t,sizeof(float),1,fpout);
|
t = ScalarType(vp->P()[2]); fwrite(&t,sizeof(ScalarType),1,fpout);
|
||||||
|
|
||||||
if( HasPerVertexNormal(m) && (pi.mask & Mask::IOM_VERTNORMAL) )
|
if( HasPerVertexNormal(m) && (pi.mask & Mask::IOM_VERTNORMAL) )
|
||||||
{
|
{
|
||||||
t = float(vp->N()[0]); fwrite(&t,sizeof(float),1,fpout);
|
t = ScalarType(vp->N()[0]); fwrite(&t,sizeof(ScalarType),1,fpout);
|
||||||
t = float(vp->N()[1]); fwrite(&t,sizeof(float),1,fpout);
|
t = ScalarType(vp->N()[1]); fwrite(&t,sizeof(ScalarType),1,fpout);
|
||||||
t = float(vp->N()[2]); fwrite(&t,sizeof(float),1,fpout);
|
t = ScalarType(vp->N()[2]); fwrite(&t,sizeof(ScalarType),1,fpout);
|
||||||
}
|
}
|
||||||
if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS) )
|
if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS) )
|
||||||
fwrite(&(vp->Flags()),sizeof(int),1,fpout);
|
fwrite(&(vp->Flags()),sizeof(int),1,fpout);
|
||||||
|
@ -374,10 +374,10 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
fwrite(&( vp->C() ),sizeof(char),4,fpout);
|
fwrite(&( vp->C() ),sizeof(char),4,fpout);
|
||||||
|
|
||||||
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) )
|
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) )
|
||||||
fwrite(&( vp->Q() ),sizeof(float),1,fpout);
|
fwrite(&( vp->Q() ),sizeof(typename VertexType::QualityType),1,fpout);
|
||||||
|
|
||||||
if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) )
|
if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) )
|
||||||
fwrite(&( vp->R() ),sizeof(float),1,fpout);
|
fwrite(&( vp->R() ),sizeof(typename VertexType::RadiusType),1,fpout);
|
||||||
|
|
||||||
if( HasPerVertexTexCoord(m) && (pi.mask & Mask::IOM_VERTTEXCOORD) )
|
if( HasPerVertexTexCoord(m) && (pi.mask & Mask::IOM_VERTTEXCOORD) )
|
||||||
{
|
{
|
||||||
|
@ -402,10 +402,10 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
}
|
}
|
||||||
else // ***** ASCII *****
|
else // ***** ASCII *****
|
||||||
{
|
{
|
||||||
fprintf(fpout,"%g %g %g " ,vp->P()[0],vp->P()[1],vp->P()[2]);
|
fprintf(fpout,"%.*g %.*g %.*g " ,DGT,vp->P()[0],DGT,vp->P()[1],DGT,vp->P()[2]);
|
||||||
|
|
||||||
if( HasPerVertexNormal(m) && (pi.mask & Mask::IOM_VERTNORMAL) )
|
if( HasPerVertexNormal(m) && (pi.mask & Mask::IOM_VERTNORMAL) )
|
||||||
fprintf(fpout,"%g %g %g " ,double(vp->N()[0]),double(vp->N()[1]),double(vp->N()[2]));
|
fprintf(fpout,"%.*g %.*g %.*g " ,DGT,vp->N()[0],DGT,vp->N()[1],DGT,vp->N()[2]);
|
||||||
|
|
||||||
if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS))
|
if( HasPerVertexFlags(m) && (pi.mask & Mask::IOM_VERTFLAGS))
|
||||||
fprintf(fpout,"%d ",vp->Flags());
|
fprintf(fpout,"%d ",vp->Flags());
|
||||||
|
@ -414,13 +414,13 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
fprintf(fpout,"%d %d %d %d ",vp->C()[0],vp->C()[1],vp->C()[2],vp->C()[3] );
|
fprintf(fpout,"%d %d %d %d ",vp->C()[0],vp->C()[1],vp->C()[2],vp->C()[3] );
|
||||||
|
|
||||||
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) )
|
if( HasPerVertexQuality(m) && (pi.mask & Mask::IOM_VERTQUALITY) )
|
||||||
fprintf(fpout,"%g ",vp->Q());
|
fprintf(fpout,"%.*g ",DGTVQ,vp->Q());
|
||||||
|
|
||||||
if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) )
|
if( HasPerVertexRadius(m) && (pi.mask & Mask::IOM_VERTRADIUS) )
|
||||||
fprintf(fpout,"%g ",vp->R());
|
fprintf(fpout,"%.*g ",DGTVR,vp->R());
|
||||||
|
|
||||||
if( HasPerVertexTexCoord(m) && (pi.mask & Mask::IOM_VERTTEXCOORD) )
|
if( HasPerVertexTexCoord(m) && (pi.mask & Mask::IOM_VERTTEXCOORD) )
|
||||||
fprintf(fpout,"%g %g",vp->T().u(),vp->T().v());
|
fprintf(fpout,"%f %f",vp->T().u(),vp->T().v());
|
||||||
|
|
||||||
for(i=0;i<pi.vdn;i++)
|
for(i=0;i<pi.vdn;i++)
|
||||||
{
|
{
|
||||||
|
@ -428,8 +428,8 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
int ti;
|
int ti;
|
||||||
switch (pi.VertexData[i].memtype1)
|
switch (pi.VertexData[i].memtype1)
|
||||||
{
|
{
|
||||||
case ply::T_FLOAT : tf=*( (float *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%g ",tf); break;
|
case ply::T_FLOAT : tf=*( (float *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%f ",tf); break;
|
||||||
case ply::T_DOUBLE : td=*( (double *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%g ",tf); break;
|
case ply::T_DOUBLE : td=*( (double *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%f ",tf); break;
|
||||||
case ply::T_INT : ti=*( (int *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%i ",ti); break;
|
case ply::T_INT : ti=*( (int *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%i ",ti); break;
|
||||||
case ply::T_SHORT : ti=*( (short *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%i ",ti); break;
|
case ply::T_SHORT : ti=*( (short *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%i ",ti); break;
|
||||||
case ply::T_CHAR : ti=*( (char *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%i ",ti); break;
|
case ply::T_CHAR : ti=*( (char *) (((char *)vp)+pi.VertexData[i].offset1)); fprintf(fpout,"%i ",ti); break;
|
||||||
|
@ -521,7 +521,7 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
}
|
}
|
||||||
|
|
||||||
if( HasPerFaceQuality(m) && (pi.mask & Mask::IOM_FACEQUALITY) )
|
if( HasPerFaceQuality(m) && (pi.mask & Mask::IOM_FACEQUALITY) )
|
||||||
fwrite( &(fp->Q()),sizeof(float),1,fpout);
|
fwrite( &(fp->Q()),sizeof(typename FaceType::ScalarType),1,fpout);
|
||||||
|
|
||||||
|
|
||||||
for(i=0;i<pi.fdn;i++)
|
for(i=0;i<pi.fdn;i++)
|
||||||
|
@ -551,7 +551,7 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
{
|
{
|
||||||
fprintf(fpout,"%d ",fp->VN()*2);
|
fprintf(fpout,"%d ",fp->VN()*2);
|
||||||
for(int k=0;k<fp->VN();++k)
|
for(int k=0;k<fp->VN();++k)
|
||||||
fprintf(fpout,"%g %g "
|
fprintf(fpout,"%f %f "
|
||||||
,fp->V(k)->T().u()
|
,fp->V(k)->T().u()
|
||||||
,fp->V(k)->T().v()
|
,fp->V(k)->T().v()
|
||||||
);
|
);
|
||||||
|
@ -560,7 +560,7 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
{
|
{
|
||||||
fprintf(fpout,"%d ",fp->VN()*2);
|
fprintf(fpout,"%d ",fp->VN()*2);
|
||||||
for(int k=0;k<fp->VN()*2;++k)
|
for(int k=0;k<fp->VN()*2;++k)
|
||||||
fprintf(fpout,"%g %g "
|
fprintf(fpout,"%f %f "
|
||||||
,fp->WT(k).u()
|
,fp->WT(k).u()
|
||||||
,fp->WT(k).v()
|
,fp->WT(k).v()
|
||||||
);
|
);
|
||||||
|
@ -594,7 +594,7 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
}
|
}
|
||||||
|
|
||||||
if( HasPerFaceQuality(m) && (pi.mask & Mask::IOM_FACEQUALITY) )
|
if( HasPerFaceQuality(m) && (pi.mask & Mask::IOM_FACEQUALITY) )
|
||||||
fprintf(fpout,"%g ",fp->Q());
|
fprintf(fpout,"%.*g ",DGTFQ,fp->Q());
|
||||||
|
|
||||||
for(i=0;i<pi.fdn;i++)
|
for(i=0;i<pi.fdn;i++)
|
||||||
{
|
{
|
||||||
|
@ -640,10 +640,10 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
|
||||||
}
|
}
|
||||||
fclose(fpout);
|
fclose(fpout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ErrorMsg(int error)
|
static const char *ErrorMsg(int error)
|
||||||
{
|
{
|
||||||
static std::vector<std::string> ply_error_msg;
|
static std::vector<std::string> ply_error_msg;
|
||||||
if(ply_error_msg.empty())
|
if(ply_error_msg.empty())
|
||||||
{
|
{
|
||||||
|
@ -673,7 +673,7 @@ static const char *ErrorMsg(int error)
|
||||||
|
|
||||||
if(error>PlyInfo::E_MAXPLYINFOERRORS || error<0) return "Unknown error";
|
if(error>PlyInfo::E_MAXPLYINFOERRORS || error<0) return "Unknown error";
|
||||||
else return ply_error_msg[error].c_str();
|
else return ply_error_msg[error].c_str();
|
||||||
};
|
};
|
||||||
|
|
||||||
static int GetExportMaskCapability()
|
static int GetExportMaskCapability()
|
||||||
{
|
{
|
||||||
|
@ -700,12 +700,12 @@ static const char *ErrorMsg(int error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // end class
|
}; // end class
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace tri
|
} // end namespace tri
|
||||||
} // end namespace io
|
} // end namespace io
|
||||||
} // end namespace vcg
|
} // end namespace vcg
|
||||||
//@}
|
//@}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -152,7 +152,7 @@ struct LoadPly_Camera
|
||||||
float k4;
|
float k4;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _VERTDESC_LAST_ 29
|
#define _VERTDESC_LAST_ 30
|
||||||
static const PropDescriptor &VertDesc(int i)
|
static const PropDescriptor &VertDesc(int i)
|
||||||
{
|
{
|
||||||
static const PropDescriptor pv[_VERTDESC_LAST_]={
|
static const PropDescriptor pv[_VERTDESC_LAST_]={
|
||||||
|
@ -186,7 +186,7 @@ static const PropDescriptor &VertDesc(int i)
|
||||||
/*26*/ {"vertex", "ny", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,n) + 1*sizeof(ScalarType),0,0,0,0,0 ,0},
|
/*26*/ {"vertex", "ny", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,n) + 1*sizeof(ScalarType),0,0,0,0,0 ,0},
|
||||||
/*27*/ {"vertex", "nz", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,n) + 2*sizeof(ScalarType),0,0,0,0,0 ,0},
|
/*27*/ {"vertex", "nz", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,n) + 2*sizeof(ScalarType),0,0,0,0,0 ,0},
|
||||||
/*28*/ {"vertex", "radius", ply::T_DOUBLE, ply::T_FLOAT, offsetof(LoadPly_VertAux<ScalarType>,radius),0,0,0,0,0 ,0},
|
/*28*/ {"vertex", "radius", ply::T_DOUBLE, ply::T_FLOAT, offsetof(LoadPly_VertAux<ScalarType>,radius),0,0,0,0,0 ,0},
|
||||||
|
/*29*/ {"vertex", "quality", ply::T_DOUBLE, PlyType<ScalarType>(),offsetof(LoadPly_VertAux<ScalarType>,q),0,0,0,0,0 ,0}
|
||||||
};
|
};
|
||||||
return pv[i];
|
return pv[i];
|
||||||
}
|
}
|
||||||
|
@ -453,6 +453,9 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi )
|
||||||
if( pf.AddToRead(VertDesc(4))!=-1 ||
|
if( pf.AddToRead(VertDesc(4))!=-1 ||
|
||||||
pf.AddToRead(VertDesc(11))!=-1 )
|
pf.AddToRead(VertDesc(11))!=-1 )
|
||||||
pi.mask |= Mask::IOM_VERTQUALITY;
|
pi.mask |= Mask::IOM_VERTQUALITY;
|
||||||
|
else
|
||||||
|
if (pf.AddToRead(VertDesc(29))!=-1)
|
||||||
|
pi.mask |= Mask::IOM_VERTQUALITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vcg::tri::HasPerVertexColor(m) )
|
if(vcg::tri::HasPerVertexColor(m) )
|
||||||
|
@ -1118,6 +1121,7 @@ static bool LoadMask(const char * filename, int &mask, PlyInfo &pi)
|
||||||
if( pf.AddToRead(VertDesc(11))!=-1 ) mask |= Mask::IOM_VERTQUALITY;
|
if( pf.AddToRead(VertDesc(11))!=-1 ) mask |= Mask::IOM_VERTQUALITY;
|
||||||
if( pf.AddToRead(VertDesc(15))!=-1 ) mask |= Mask::IOM_VERTRADIUS;
|
if( pf.AddToRead(VertDesc(15))!=-1 ) mask |= Mask::IOM_VERTRADIUS;
|
||||||
if( pf.AddToRead(VertDesc(28))!=-1 ) mask |= Mask::IOM_VERTRADIUS;
|
if( pf.AddToRead(VertDesc(28))!=-1 ) mask |= Mask::IOM_VERTRADIUS;
|
||||||
|
if( pf.AddToRead(VertDesc(29))!=-1 ) mask |= Mask::IOM_VERTQUALITY;
|
||||||
if( pf.AddToRead(VertDesc( 5))!=-1 &&
|
if( pf.AddToRead(VertDesc( 5))!=-1 &&
|
||||||
pf.AddToRead(VertDesc( 6))!=-1 &&
|
pf.AddToRead(VertDesc( 6))!=-1 &&
|
||||||
pf.AddToRead(VertDesc( 7))!=-1 ) mask |= Mask::IOM_VERTCOLOR;
|
pf.AddToRead(VertDesc( 7))!=-1 ) mask |= Mask::IOM_VERTCOLOR;
|
||||||
|
|
Loading…
Reference in New Issue