From deb5402d35fc3bd0c1955ba9e0d23a4efe191ee1 Mon Sep 17 00:00:00 2001 From: granzuglia Date: Wed, 8 Nov 2006 22:25:35 +0000 Subject: [PATCH] fixed the terrible bug (QDomDocument&) node.toElement() --- wrap/io_trimesh/import_dae.h | 6 ---- wrap/io_trimesh/util_dae.h | 66 ++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/wrap/io_trimesh/import_dae.h b/wrap/io_trimesh/import_dae.h index c8272632..bfc63270 100644 --- a/wrap/io_trimesh/import_dae.h +++ b/wrap/io_trimesh/import_dae.h @@ -172,8 +172,6 @@ namespace io { m.face[ff].WT(0).u() = wt.at(indtx * 2).toFloat(); m.face[ff].WT(0).v() = wt.at(indtx * 2 + 1).toFloat(); m.face[ff].WT(0).n() = 1; - vcg::TCoord2 ttt = m.face[ff].WT(0); - int hh = 0; } /*int indcl; @@ -203,8 +201,6 @@ namespace io { m.face[ff].WT(1).u() = wt.at(indtx * 2).toFloat(); m.face[ff].WT(1).v() = wt.at(indtx * 2 + 1).toFloat(); m.face[ff].WT(1).n() = 1; - vcg::TCoord2 ttt = m.face[ff].WT(1); - int hh = 0; } /*if (!wcsrc.isNull()) @@ -233,8 +229,6 @@ namespace io { m.face[ff].WT(2).u() = wt.at(indtx * 2).toFloat(); m.face[ff].WT(2).v() = wt.at(indtx * 2 + 1).toFloat(); m.face[ff].WT(2).n() = 1; - vcg::TCoord2 ttt = m.face[ff].WT(2); - int hh = 0; } /*if (!wcsrc.isNull()) diff --git a/wrap/io_trimesh/util_dae.h b/wrap/io_trimesh/util_dae.h index 154777d1..4e70a4e7 100644 --- a/wrap/io_trimesh/util_dae.h +++ b/wrap/io_trimesh/util_dae.h @@ -102,15 +102,8 @@ namespace io { assert(url_st.size() != 0); } - inline static QDomNode findNodeBySpecificAttributeValue(const QDomNode& n,const QString& tag,const QString& attrname,const QString& attrvalue) + inline static QDomNode findNodeBySpecificAttributeValue(const QDomNodeList& ndl,const QString& attrname,const QString& attrvalue) { - QDomNode ndl = n.toElement(); - return findNodeBySpecificAttributeValue((QDomDocument&) ndl,tag,attrname,attrvalue); - } - - inline static QDomNode findNodeBySpecificAttributeValue(const QDomDocument& n,const QString& tag,const QString& attrname,const QString& attrvalue) - { - QDomNodeList ndl = n.elementsByTagName(tag); int ndl_size = ndl.size(); assert(ndl_size != 0); int ind = 0; @@ -123,15 +116,29 @@ namespace io { return QDomNode(); } + inline static QDomNode findNodeBySpecificAttributeValue(const QDomNode& n,const QString& tag,const QString& attrname,const QString& attrvalue) + { + return findNodeBySpecificAttributeValue(n.toElement().elementsByTagName(tag),attrname,attrvalue); + } + + inline static QDomNode findNodeBySpecificAttributeValue(const QDomDocument& n,const QString& tag,const QString& attrname,const QString& attrvalue) + { + return findNodeBySpecificAttributeValue(n.elementsByTagName(tag),attrname,attrvalue); + } + + inline static bool isThereTag(const QDomNodeList& list) + { + return ((list.size() > 0) ? true : false); + } + inline static bool isThereTag(const QDomNode& n,const QString& tagname) { - QDomNode ndl = n.toElement(); - return isThereTag((QDomDocument&) n,tagname); + return isThereTag(n.toElement().elementsByTagName(tagname)); } inline static bool isThereTag(const QDomDocument& n,const QString& tagname) { - return ((n.toElement().elementsByTagName(tagname).size() > 0)? true : false); + return isThereTag(n.elementsByTagName(tagname)); } @@ -162,6 +169,8 @@ namespace io { } + /*inline static bool removeChildNode(QDomNodeList*/ + inline static bool removeChildNodeList(QDomNodeList& nodelst,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") { for(int jj = 0;jj < nodelst.size();++jj) @@ -171,13 +180,8 @@ namespace io { return true; } - inline static bool removeChildNode(QDomNode& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") - { - return removeChildNode((QDomDocument&) node.toElement(),tag,attribname,attribvalue); - } - inline static bool removeChildNode(QDomDocument& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") - //inline static bool removeChildNode(QDomNode node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") + inline static bool removeChildNode(QDomNode& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") { QDomNodeList clst = node.childNodes(); for(int ii = 0;ii < clst.size();++ii) @@ -204,6 +208,34 @@ namespace io { return true; } + //inline static bool removeChildNode(QDomDocument& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") + ////inline static bool removeChildNode(QDomNode node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") + //{ + // QDomNodeList clst = node.childNodes(); + // for(int ii = 0;ii < clst.size();++ii) + // { + // QDomNode oldchild = node.childNodes().at(ii); + // if (tag != "") + // { + // if ((attribname != "") && (attribvalue != "")) + // { + // if (clst.at(ii).toElement().attribute(attribname) == attribvalue) + // node.removeChild(oldchild); + // } + // else + // { + // QString nm = clst.at(ii).nodeName(); + // if (clst.at(ii).nodeName() == tag) + // { + // node.removeChild(oldchild); + // } + // } + // } + // else node.removeChild(oldchild); + // } + // return true; + //} + /*inline static bool removeChildNode(QDomDocument node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") { QDomNodeList clst = node.childNodes();