drastically augmented the save function performance

This commit is contained in:
granzuglia 2006-11-05 21:52:25 +00:00
parent 1510076b65
commit 0812a3d1bc
1 changed files with 6 additions and 1 deletions

View File

@ -264,7 +264,9 @@ public:
arrayposnode.setAttribute("id","vcg-mesh-positions-array"); arrayposnode.setAttribute("id","vcg-mesh-positions-array");
QString arrp; QString arrp;
arrp.reserve(8 * m.vert.size());
QString arrn; QString arrn;
arrn.reserve(8 * m.vert.size());
int nvert = 0; int nvert = 0;
for(SaveMeshType::VertexIterator it = m.vert.begin();it != m.vert.end();++it) for(SaveMeshType::VertexIterator it = m.vert.begin();it != m.vert.end();++it)
{ {
@ -272,6 +274,8 @@ public:
{ {
arrp.append(QString::number(it->P().X()) + " " +QString::number(it->P().Y()) + " " + QString::number(it->P().Z()) + " "); arrp.append(QString::number(it->P().X()) + " " +QString::number(it->P().Y()) + " " + QString::number(it->P().Z()) + " ");
arrn.append(QString::number(it->N().X()) + " " + QString::number(it->N().Y()) + " " + QString::number(it->N().Z())+ " "); arrn.append(QString::number(it->N().X()) + " " + QString::number(it->N().Y()) + " " + QString::number(it->N().Z())+ " ");
//arrp.append(QString::number(it->P().X()).append(" ").append(QString::number(it->P().Y())).append(" ").append(QString::number(it->P().Z())).append(" "));
//arrp.append(QString::number(it->N().X()).append(" ").append(QString::number(it->N().Y())).append(" ").append(QString::number(it->N().Z())).append(" "));
++nvert; ++nvert;
} }
} }
@ -365,6 +369,7 @@ public:
QDomElement poly = info->doc->createElement("p"); QDomElement poly = info->doc->createElement("p");
QString triangles_tess; QString triangles_tess;
int nface = 0; int nface = 0;
triangles_tess.reserve(9*m.face.size());
for(SaveMeshType::FaceIterator itf = m.face.begin();itf != m.face.end();++itf) for(SaveMeshType::FaceIterator itf = m.face.begin();itf != m.face.end();++itf)
{ {
if (!(itf->IsD())) if (!(itf->IsD()))
@ -374,7 +379,7 @@ public:
int ind_v = (*itf).V(ii) - &(m.vert[0]); int ind_v = (*itf).V(ii) - &(m.vert[0]);
if (triangles_tess == "") if (triangles_tess == "")
triangles_tess = QString::number(ind_v); triangles_tess = QString::number(ind_v);
else triangles_tess = triangles_tess + " " + QString::number(ind_v); else triangles_tess = triangles_tess.append(" ").append(QString::number(ind_v));
} }
++nface; ++nface;
} }