possibility to export double attributes in ply
This commit is contained in:
parent
23082f1994
commit
d4718bde6a
|
|
@ -211,7 +211,7 @@ namespace vcg {
|
|||
);
|
||||
}
|
||||
for(size_t i=0;i<pi.VertDescriptorVec.size();i++)
|
||||
fprintf(fpout,"property %s %s\n",pi.VertDescriptorVec[i].stotypename(),pi.VertDescriptorVec[i].propname);
|
||||
fprintf(fpout,"property %s %s\n",pi.VertDescriptorVec[i].stotypename(),pi.VertDescriptorVec[i].propname.c_str());
|
||||
|
||||
fprintf(fpout,
|
||||
"element face %d\n"
|
||||
|
|
@ -278,7 +278,7 @@ namespace vcg {
|
|||
}
|
||||
|
||||
for(size_t i=0;i<pi.FaceDescriptorVec.size();i++)
|
||||
fprintf(fpout,"property %s %s\n",pi.FaceDescriptorVec[i].stotypename(),pi.FaceDescriptorVec[i].propname);
|
||||
fprintf(fpout,"property %s %s\n",pi.FaceDescriptorVec[i].stotypename(),pi.FaceDescriptorVec[i].propname.c_str());
|
||||
// Saving of edges is enabled if requested
|
||||
if( m.en>0 && (pi.mask & Mask::IOM_EDGEINDEX) )
|
||||
fprintf(fpout,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ Initial commit
|
|||
#define __VCGLIB_IOTRIMESH_IO_PLY
|
||||
|
||||
|
||||
#include <vcg/complex/allocate.h>
|
||||
|
||||
/**
|
||||
@name Load and Save in Ply format
|
||||
*/
|
||||
|
|
@ -66,25 +68,52 @@ class PlyInfo
|
|||
public:
|
||||
typedef ::vcg::ply::PropDescriptor PropDescriptor ;
|
||||
|
||||
void AddPerElemFloatAttribute(int elemType, const char *attrName, const char * propName=0)
|
||||
void addPerElemScalarAttribute(int elemType, vcg::ply::PlyTypes propertyType, const std::string& attrName, std::string propName="")
|
||||
{
|
||||
static const char *elemStr[2]={"vertex","face"};
|
||||
std::vector<PropDescriptor> *elemDescVec[2]={&(this->VertDescriptorVec), &(this->FaceDescriptorVec)};
|
||||
std::vector<std::string > *elemNameVec[2]={&(this->VertAttrNameVec), &(this->FaceAttrNameVec)};
|
||||
if(propName=="")
|
||||
propName=attrName;
|
||||
|
||||
if(propName==0) propName=attrName;
|
||||
elemDescVec[elemType]->push_back(PropDescriptor());
|
||||
elemNameVec[elemType]->push_back(attrName);
|
||||
elemDescVec[elemType]->back().elemname=elemStr[elemType];
|
||||
elemDescVec[elemType]->back().propname=strdup(propName);
|
||||
elemDescVec[elemType]->back().stotype1 = vcg::ply::T_FLOAT;
|
||||
elemDescVec[elemType]->back().memtype1 = vcg::ply::T_FLOAT;
|
||||
if (elemType == 0){ //vertex
|
||||
VertDescriptorVec.push_back(PropDescriptor());
|
||||
VertAttrNameVec.push_back(attrName);
|
||||
VertDescriptorVec.back().elemname="vertex";
|
||||
VertDescriptorVec.back().propname=propName;
|
||||
VertDescriptorVec.back().stotype1 = propertyType;
|
||||
VertDescriptorVec.back().memtype1 = propertyType;
|
||||
}
|
||||
else if (elemType == 1){ //face
|
||||
FaceDescriptorVec.push_back(PropDescriptor());
|
||||
FaceAttrNameVec.push_back(attrName);
|
||||
FaceDescriptorVec.back().elemname="face";
|
||||
FaceDescriptorVec.back().propname=propName;
|
||||
FaceDescriptorVec.back().stotype1 = propertyType;
|
||||
FaceDescriptorVec.back().memtype1 = propertyType;
|
||||
}
|
||||
}
|
||||
|
||||
void AddPerVertexFloatAttribute(const char *attrName, const char *propName=0) {
|
||||
void AddPerElemFloatAttribute(int elemType, const std::string& attrName, std::string propName="")
|
||||
{
|
||||
addPerElemScalarAttribute(elemType, vcg::ply::T_FLOAT, attrName, propName);
|
||||
}
|
||||
|
||||
void AddPerElemDoubleAttribute(int elemType, const std::string& attrName, std::string propName="")
|
||||
{
|
||||
addPerElemScalarAttribute(elemType, vcg::ply::T_DOUBLE, attrName, propName);
|
||||
}
|
||||
|
||||
void addPerVertexScalarAttribute(const std::string& attrName, vcg::ply::PlyTypes attrType, std::string propName="") {
|
||||
addPerElemScalarAttribute(0,attrType, attrName,propName);
|
||||
}
|
||||
|
||||
void AddPerVertexFloatAttribute(const std::string& attrName, std::string propName="") {
|
||||
AddPerElemFloatAttribute(0,attrName,propName);
|
||||
}
|
||||
void AddPerFaceFloatAttribute(const char *attrName, const char *propName=0) {
|
||||
|
||||
void addPerFaceScalarAttribute(const std::string& attrName, vcg::ply::PlyTypes attrType, std::string propName="") {
|
||||
addPerElemScalarAttribute(1,attrType, attrName,propName);
|
||||
}
|
||||
|
||||
void AddPerFaceFloatAttribute(const std::string& attrName, std::string propName="") {
|
||||
AddPerElemFloatAttribute(1,attrName,propName);
|
||||
}
|
||||
|
||||
|
|
@ -92,9 +121,10 @@ public:
|
|||
/* Note that saving a per vertex point3 attribute is a mess.
|
||||
* Actually require to allocate 3 float attribute and save them. And they are never deallocated... */
|
||||
template<class MeshType>
|
||||
void AddPerVertexPoint3fAttribute(MeshType &m, const char *attrName, const char *propName="")
|
||||
void AddPerVertexPoint3fAttribute(MeshType &m, const std::string& attrName, std::string propName="")
|
||||
{
|
||||
if(propName==0) propName=attrName;
|
||||
if(propName=="")
|
||||
propName=attrName;
|
||||
|
||||
const char *attrxyz[3] = {
|
||||
strdup((std::string(attrName)+std::string("_x")).c_str()),
|
||||
|
|
|
|||
|
|
@ -112,33 +112,27 @@ typedef FILE * GZFILE;
|
|||
#endif
|
||||
|
||||
|
||||
// Messaggio di errore
|
||||
//extern const char * ply_error_msg[];
|
||||
|
||||
// TIPO FILE
|
||||
|
||||
|
||||
// Descrittore esterno di propieta'
|
||||
// Ply Property descriptor
|
||||
class PropDescriptor
|
||||
{
|
||||
public:
|
||||
const char * elemname; // Nome dell'elemento
|
||||
const char * propname; // Nome della propieta'
|
||||
int stotype1; // Tipo dell'elemento su file (se lista tipo degli elementi della lista)
|
||||
int memtype1; // Tipo dell'elemento in memoria (se lista tipo degli elementi della lista)
|
||||
size_t offset1; // Offset del valore in memoria
|
||||
int islist; // 1 se lista, 0 altrimenti
|
||||
int alloclist; // 1 se alloca lista, 0 se preallocata
|
||||
int stotype2; // Tipo del numero di elementi della lista su file
|
||||
int memtype2; // Tipo del numero di elementi della lista in memoria
|
||||
std::string elemname; // name of the element (e.g. vertex)
|
||||
std::string propname; // name of the property (e.g. x, y, red...)
|
||||
int stotype1; // Type of the property in the file
|
||||
int memtype1; // Type of the property in memory
|
||||
size_t offset1; // Offset in memory
|
||||
bool islist; // true if the property is a list
|
||||
bool alloclist; // 1 se alloca lista, 0 se preallocata
|
||||
int stotype2; // Type of the number of elements of the list in the file
|
||||
int memtype2; // Type of the number of elements of the list in memory
|
||||
size_t offset2; // Offset valore memoria
|
||||
|
||||
int format; // duplicazione del formato
|
||||
|
||||
size_t stotypesize() const; // per sapere quanto e'grande un dato descrittore sul file
|
||||
size_t memtypesize() const; // per sapere quanto e'grande un dato descrittore in memoria
|
||||
const char *memtypename() const;
|
||||
const char *stotypename() const;
|
||||
const char* memtypename() const;
|
||||
const char* stotypename() const;
|
||||
};
|
||||
|
||||
// Reading Callback (used to copy a data prop)
|
||||
|
|
@ -273,7 +267,7 @@ public:
|
|||
// Come sopra ma con descrittore
|
||||
inline int AddToRead( const PropDescriptor & p )
|
||||
{
|
||||
return AddToRead(p.elemname,p.propname,p.stotype1,
|
||||
return AddToRead(p.elemname.c_str(),p.propname.c_str(),p.stotype1,
|
||||
p.memtype1,p.offset1,p.islist,p.alloclist,p.stotype2,
|
||||
p.memtype2,p.offset2
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue