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);