From 7ec471c87e13615ee89b11166e0db938871bf705 Mon Sep 17 00:00:00 2001 From: "dmy@lab" Date: Wed, 21 Jan 2015 21:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B8=A9=E4=BA=86=E6=97=A0=E6=95=B0=E4=B8=AA?= =?UTF-8?q?=E5=9D=91=EF=BC=8C=E7=BB=88=E4=BA=8E=E6=8A=8A=E9=9B=B6=E9=98=BB?= =?UTF-8?q?=E6=8A=97=E6=B6=88=E9=99=A4=E7=9A=84=E5=8A=9F=E8=83=BD=E5=86=99?= =?UTF-8?q?=E5=A5=BD=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dmy@lab --- testHasttable/cimexporter.cpp | 10 ++++ testHasttable/elementreduction.cpp | 81 +++++++++++++++++++++++++++++- testHasttable/elementreduction.h | 4 ++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index 9d70039..b9a85a2 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -85,6 +85,7 @@ void CIMExporter::exportTo(const QString& path) writer<length<<"\r\n"; } //输出刀闸 @@ -99,6 +100,7 @@ void CIMExporter::exportTo(const QString& path) writer<fromNum<<"\t"; writer<toNum<<"\t"; writer<<"type"<<"\t"; + writer<id<<"\t"; writer<<0<<"\r\n"; } //输出负荷 @@ -147,6 +149,7 @@ void CIMExporter::exportTo(const QString& path) writer<fromNum<<"\t"; writer<toNum<<"\t"; writer<<"type"<<"\t"; + writer<id<<"\t"; writer<getMVA()<<"\r\n"; break; } @@ -178,6 +181,12 @@ void CIMExporter::idToNumber(QList &s)//把所有元件的标识进行编号 ite++ ) { + if(ite->dispose) + { + std::cout<id.toStdString()<<" dispose"<numberIt(_t.fromID); _t.toNum=this->numberIt(_t.toID); @@ -195,6 +204,7 @@ int CIMExporter::numberIt(const QString& id) { int n=this->number.keys().length()+1; this->number[id]=n; + std::cout<buildTree(element,root,linkage,idToBranch); this->visited.remove(this->branchList.at(2)->id); this->buildTree2(element,root,linkage,idToBranch); + this->merge(element,idToBranch); QFile file("1.xml"); if(file.open(QFile::WriteOnly)) { @@ -48,11 +49,87 @@ void ElementReduction::doIt() } //合并 + //从新给连接关系编号 } -void ElementReduction::merge() + +//void ElementReduction::re_establishConnection(QDomElement &element,QHash& idToBranch) +//{ +// QDomNodeList list=element.childNodes(); +// for(int i=0;iisZeroBranch) +// { +// branch->dispose=true; +// QDomNodeList child=node.childNodes(); +// for(int j=0;jmerge((QDomElement &)node,idToBranch); + +// } +//} + + +void ElementReduction::merge(QDomElement &element,QHash& idToBranch) { + QString parentID=idToBranch[element.tagName()]->id; + QStringList sep=parentID.split('-'); +// QString fromID=sep.at(0)+sep.at(1); + QString toID=sep.at(1)+sep.at(0); + idToBranch[element.tagName()]->toID=toID; + element.setAttribute("toID",toID); + //顺便编号 + //采用广度优先 + bool merged=true; + while(merged) + { + merged=false; + QDomNodeList list=element.childNodes(); + int length=list.length(); + for(int i=0;ifromID=toID; + node.setAttribute("fromID",toID); + if(branch->isZeroBranch) + { + branch->dispose=true; + while(node.childNodes().length()>0) + { + std::cout<<"append "<merge((QDomElement &)node,idToBranch); + } + } @@ -80,6 +157,7 @@ void ElementReduction::buildTree(QDomElement &element,QDomDocument &root,QHashid.toStdString()<id); + std::cout<<"create "<id.toStdString()<buildTree(newEle,root,linkage,idToBranch); } @@ -107,6 +185,7 @@ void ElementReduction::buildTree2(QDomElement &element,QDomDocument &root,QHash< } // std::cout<<"add "<id.toStdString()<id); +// std::cout<<"create "<id.toStdString()<buildTree2(newEle,root,linkage,idToBranch); } diff --git a/testHasttable/elementreduction.h b/testHasttable/elementreduction.h index d445249..67c5232 100644 --- a/testHasttable/elementreduction.h +++ b/testHasttable/elementreduction.h @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include "element/commontype.h" //把电阻等于0的元件都去掉 class ElementReduction @@ -16,6 +19,7 @@ public: void doIt(); ~ElementReduction(); private: + void merge(QDomElement &element, QHash& idToBranch); void buildTree(QDomElement &element, QDomDocument &root, QHash >& linkage, QHash& idToBranch); void buildTree2(QDomElement &element, QDomDocument &root, QHash >& linkage, QHash& idToBranch); void visit(BranchStruc* branch, QHash > &linkage);