mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-15 00:54:38 +00:00
Added first draft of the meshlab document xml saving classes
This commit is contained in:
parent
0ea66f18ff
commit
4d098cb1cf
@ -72,7 +72,8 @@ HEADERS += filterparameter.h \
|
||||
mlparameter.h \
|
||||
xmlfilterinfo.h \
|
||||
mlexception.h \
|
||||
../../../vcglib/wrap/gl/trimesh.h
|
||||
../../../vcglib/wrap/gl/trimesh.h \
|
||||
meshlabdocumentxml.h
|
||||
SOURCES += filterparameter.cpp \
|
||||
interfaces.cpp \
|
||||
filterscript.cpp \
|
||||
@ -82,4 +83,5 @@ SOURCES += filterparameter.cpp \
|
||||
scriptinterface.cpp \
|
||||
mlparameter.cpp \
|
||||
xmlfilterinfo.cpp \
|
||||
$$GLEWCODE
|
||||
$$GLEWCODE \
|
||||
meshlabdocumentxml.cpp
|
||||
|
||||
70
src/common/meshlabdocumentxml.cpp
Normal file
70
src/common/meshlabdocumentxml.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
#include <QFileInfo>
|
||||
#include <QtXml>
|
||||
#include "meshmodel.h"
|
||||
#include "meshlabdocumentxml.h"
|
||||
|
||||
bool MeshDocumentToXMLFile(MeshDocument &md, QString filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
QTextStream qstream(&file);
|
||||
QDomDocument doc = MeshDocumentToXML(md);
|
||||
doc.save(qstream,1);
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
QDomElement Matrix44fToXML(vcg::Matrix44f &m, QDomDocument &doc)
|
||||
{
|
||||
QDomElement matrixElem = doc.createElement("MLMatrix44");
|
||||
QString Row[4];
|
||||
for(int i=0;i<4;++i)
|
||||
Row[i] =QString("%1 %2 %3 %4\n").arg(m[i][0]).arg(m[i][1]).arg(m[i][2]).arg(m[i][3]);
|
||||
|
||||
matrixElem.setNodeValue(Row[0]+Row[1]+Row[2]+Row[3]);
|
||||
|
||||
return matrixElem;
|
||||
}
|
||||
|
||||
bool MeshDocumentFromXML(MeshDocument &, QDomDocument &doc)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QDomElement MeshModelToXML(MeshModel *mp, QDomDocument &doc)
|
||||
{
|
||||
QDomElement meshElem = doc.createElement("MLMesh");
|
||||
meshElem.setAttribute("name",mp->label());
|
||||
meshElem.appendChild(Matrix44fToXML(mp->cm.Tr,doc));
|
||||
return meshElem;
|
||||
}
|
||||
|
||||
QDomDocument MeshDocumentToXML(MeshDocument &md)
|
||||
{
|
||||
QDomDocument ddoc("MeshLabDocument");
|
||||
QDomElement mgroot = ddoc.createElement("MeshGroup");
|
||||
|
||||
foreach(MeshModel *mmp, md.meshList)
|
||||
{
|
||||
QDomElement meshElem = MeshModelToXML(mmp, ddoc);
|
||||
mgroot.appendChild(meshElem);
|
||||
}
|
||||
ddoc.appendChild(mgroot);
|
||||
|
||||
// tag.setAttribute(QString("name"),(*ii).first);
|
||||
// RichParameterSet &par=(*ii).second;
|
||||
// QList<RichParameter*>::iterator jj;
|
||||
// RichParameterXMLVisitor v(doc);
|
||||
// for(jj=par.paramList.begin();jj!=par.paramList.end();++jj)
|
||||
// {
|
||||
// (*jj)->accept(v);
|
||||
// tag.appendChild(v.parElem);
|
||||
// }
|
||||
// root.appendChild(tag);
|
||||
// }
|
||||
//
|
||||
return ddoc;
|
||||
}
|
||||
7
src/common/meshlabdocumentxml.h
Normal file
7
src/common/meshlabdocumentxml.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef __MESHLABDOC_XML_H
|
||||
#define __MESHLABDOC_XML_H
|
||||
|
||||
QDomDocument MeshDocumentToXML(MeshDocument &md);
|
||||
bool MeshDocumentToXMLFile(MeshDocument &md, QString filename);
|
||||
|
||||
#endif // __MESHLABDOC_XML_H
|
||||
Loading…
x
Reference in New Issue
Block a user