mini-changes at various importer exporters, to maximize compatibility

This commit is contained in:
mtarini 2010-03-13 00:52:17 +00:00
parent 9768533095
commit 54ca153009
8 changed files with 499 additions and 453 deletions

View File

@ -28,6 +28,9 @@
#include <QtGui/QImage>
#include <QtCore/QVector>
#include <QDateTime>
template<typename POINTTYPE>
struct CoordNumber{public: static unsigned int coord() { return 0; }};
@ -762,8 +765,6 @@ namespace Tags
}
};
#include <QDateTime>
class CreatedTag : public XMLLeafTag//added
{
public:
@ -1155,4 +1156,4 @@ public:
//}
};
} //Collada
#endif
#endif

View File

@ -316,7 +316,7 @@ namespace io {
}
if (res.last() == "")
res.removeLast();
// int emptyCount = res.removeAll(QString(""));
// if(emptyCount>0) qDebug("- - - - - - - - valueStringList: Removed %i null strings when parsing tag %s",emptyCount,qPrintable(tag));
// for(int i =0;i<res.size();++i)

View File

@ -74,4 +74,4 @@ XMLInteriorNode::~XMLInteriorNode()
void XMLInteriorNode::applyProcedure(XMLVisitor& v)
{
v(*this);
}
}

View File

@ -207,10 +207,10 @@ public:
_stream.setAutoFormatting(autoformatting);
}
~XMLDocumentWriter()
virtual ~XMLDocumentWriter()
{
_file.close();
}
};
#endif
#endif

View File

@ -165,6 +165,7 @@ namespace io {
//vert
capability |= vcg::tri::io::Mask::IOM_VERTNORMAL;
capability |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;
//face
capability |= vcg::tri::io::Mask::IOM_FACECOLOR;
@ -181,7 +182,16 @@ namespace io {
*/
static int Save(SaveMeshType &m, const char * filename, int mask, CallBackPos *cb=0)
{
if(m.vn == 0) return E_NOTVEXTEXVALID;
// texture coord and normal: cannot be saved BOTH per vertex and per wedge
if (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD &&
mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD ) {
mask &= ~vcg::tri::io::Mask::IOM_VERTTEXCOORD;
}
if (mask & vcg::tri::io::Mask::IOM_WEDGCOLOR &&
mask & vcg::tri::io::Mask::IOM_VERTCOLOR ) {
mask &= ~vcg::tri::io::Mask::IOM_VERTCOLOR;
}
if(m.vn == 0) return E_NOTVEXTEXVALID;
// Commented out this control. You should be allowed to save a point cloud.
// if(m.fn == 0) return E_NOTFACESVALID;
@ -216,7 +226,7 @@ namespace io {
{
VertexId[vi-m.vert.begin()]=numvert;
//saves normal per vertex
if((mask & Mask::IOM_VERTNORMAL) || (mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD) )
if (mask & Mask::IOM_WEDGNORMAL )
{
if(AddNewNormalVertex(NormalVertex,(*vi).N(),curNormalIndex))
{
@ -224,7 +234,16 @@ namespace io {
curNormalIndex++;
}
}
if (mask & Mask::IOM_VERTNORMAL ) {
fprintf(fp,"vn %f %f %f\n",(*vi).N()[0],(*vi).N()[1],(*vi).N()[2]);
}
if (mask & Mask::IOM_VERTTEXCOORD ) {
fprintf(fp,"vt %f %f\n",(*vi).T().P()[0],(*vi).T().P()[1]);
}
//if (mask & Mask::IOM_VERTCOLOR ) {
// fprintf(fp,"vc %f %f %f\n",(*vi).T().P()[0],(*vi).T().P()[1]);
//}
//saves vertex
fprintf(fp,"v %f %f %f\n",(*vi).P()[0],(*vi).P()[1],(*vi).P()[2]);
@ -265,10 +284,10 @@ namespace io {
}
}
//saves texture coord
for(unsigned int k=0;k<3;k++)
//saves texture coord x wedge
if(HasPerWedgeTexCoord(m) && (mask & Mask::IOM_WEDGTEXCOORD))
for(unsigned int k=0;k<3;k++)
{
if(HasPerWedgeTexCoord(m) && (mask & Mask::IOM_WEDGTEXCOORD))
{
if(AddNewTextureCoord(CoordIndexTexture,(*fi).WT(k),curTexCoordIndex))
{
@ -278,6 +297,7 @@ namespace io {
}
}
fprintf(fp,"f ");
for(unsigned int k=0;k<3;k++)
{
@ -289,10 +309,14 @@ namespace io {
int vt = -1;
if(mask & Mask::IOM_WEDGTEXCOORD)
vt = GetIndexVertexTexture(CoordIndexTexture,(*fi).WT(k));//index of vertex texture per face
if (mask & Mask::IOM_VERTTEXCOORD)
vt = vInd;
int vn = -1;
if((mask & Mask::IOM_VERTNORMAL) || (mask & Mask::IOM_WEDGNORMAL) )
if(mask & Mask::IOM_WEDGNORMAL )
vn = GetIndexVertexNormal(m, NormalVertex, (*fi).V(k)->cN());//index of vertex normal per face.
if (mask & Mask::IOM_VERTNORMAL)
vn = vInd;
//writes elements on file obj
WriteFacesElement(fp,vInd,vt,vn);

View File

@ -704,7 +704,7 @@ static Matrix44f getTransfMatrixFromNode(const QDomElement parentNode)
QDomDocument* doc = new QDomDocument(filename);
info.doc = doc;
QFile file(filename);
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
return E_CANTOPEN;
if (!doc->setContent(&file))
@ -805,7 +805,7 @@ static Matrix44f getTransfMatrixFromNode(const QDomElement parentNode)
bool bHasPerVertexNormal = false;
bool bHasPerVertexText = false;
QDomDocument* doc = new QDomDocument(filename);
QDomDocument* doc = new QDomDocument(filename);
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
return false;

File diff suppressed because it is too large Load Diff

View File

@ -762,7 +762,7 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi )
if( pi.mask & Mask::IOM_VERTTEXCOORD )
{
(*vi).T().P().X() = va.u;
(*vi).T().P().Y() = va.v;
(*vi).T().P().Y() = 1.0-va.v; // because "v" attr comes from "t"
}
if( pi.mask & Mask::IOM_VERTCOLOR )