diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index b9a85a2..2f36b70 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -11,7 +11,7 @@ void CIMExporter::add(const QPair& fromTo,Line* line) lineStru.fromID=fromTo.first; lineStru.toID=fromTo.second; lineStru.id=line->ac->getID(); - lineStru.isZeroBranch=false; + lineStru.isZeroBranch=std::fabs(line->length)<1e-5; lineStru.dispose=false; this->line.push_back(lineStru); @@ -85,7 +85,7 @@ void CIMExporter::exportTo(const QString& path) writer<length<<"\r\n"; } //输出刀闸 @@ -100,7 +100,7 @@ void CIMExporter::exportTo(const QString& path) writer<fromNum<<"\t"; writer<toNum<<"\t"; writer<<"type"<<"\t"; - writer<id<<"\t"; +// writer<id<<"\t"; writer<<0<<"\r\n"; } //输出负荷 @@ -149,7 +149,7 @@ void CIMExporter::exportTo(const QString& path) writer<fromNum<<"\t"; writer<toNum<<"\t"; writer<<"type"<<"\t"; - writer<id<<"\t"; +// writer<id<<"\t"; writer<getMVA()<<"\r\n"; break; } @@ -204,7 +204,7 @@ int CIMExporter::numberIt(const QString& id) { int n=this->number.keys().length()+1; this->number[id]=n; - std::cout< #include "topologytest.h" #include "elementreduction.h" +#include //#include "elementhashtable.h" //class Substation; class CIMExporter diff --git a/testHasttable/elementreduction.cpp b/testHasttable/elementreduction.cpp index 76f4c32..95b5ccc 100644 --- a/testHasttable/elementreduction.cpp +++ b/testHasttable/elementreduction.cpp @@ -26,19 +26,19 @@ void ElementReduction::doIt() QDomDocument root; QDomElement element=root.createElement(this->branchList.at(2)->id); root.appendChild(element); - this->buildTree(element,root,linkage,idToBranch); + this->buildTreeTo(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)) - { -// root.setContent(&file); - QTextStream writer(&file); + this->buildTreeFrom(element,root,linkage,idToBranch); + this->merge(element,idToBranch); +// QFile file("1.xml"); +// if(file.open(QFile::WriteOnly)) +// { +//// root.setContent(&file); +// QTextStream writer(&file); - root.save(writer,4); - file.close(); - } +// root.save(writer,4); +// file.close(); +// } //看看是不是每个都访问到了 foreach(BranchStruc* v,this->branchList) { @@ -54,36 +54,11 @@ void ElementReduction::doIt() } -//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); @@ -98,10 +73,6 @@ void ElementReduction::merge(QDomElement &element,QHash& for(int i=0;i& } -void ElementReduction::buildTree(QDomElement &element,QDomDocument &root,QHash >& linkage,QHash& idToBranch) +void ElementReduction::buildTreeTo(QDomElement &element,QDomDocument &root,QHash >& linkage,QHash& idToBranch) { QString id=element.tagName(); @@ -157,13 +128,13 @@ void ElementReduction::buildTree(QDomElement &element,QDomDocument &root,QHashid.toStdString()<id); - std::cout<<"create "<id.toStdString()<id.toStdString()<buildTree(newEle,root,linkage,idToBranch); + this->buildTreeTo(newEle,root,linkage,idToBranch); } } -void ElementReduction::buildTree2(QDomElement &element,QDomDocument &root,QHash >& linkage,QHash& idToBranch) +void ElementReduction::buildTreeFrom(QDomElement &element,QDomDocument &root,QHash >& linkage,QHash& idToBranch) { QString id=element.tagName(); @@ -187,93 +158,8 @@ void ElementReduction::buildTree2(QDomElement &element,QDomDocument &root,QHash< QDomElement newEle=root.createElement(n->id); // std::cout<<"create "<id.toStdString()<buildTree2(newEle,root,linkage,idToBranch); + this->buildTreeFrom(newEle,root,linkage,idToBranch); } } -void ElementReduction::visit(BranchStruc* branch,QHash >& linkage) -{ - std::cout<<"visit "<id.toStdString()<visited.contains(branch->id)) -// { -// std::cout<<"visited "<id.toStdString()<visited[branch->id]=0; - QString next; - next=branch->toID; - QVector nextVec; - nextVec=linkage[next]; -// std::cout<<"next length"<dispose) - { -// std::cout<<"disposed "<id.toStdString()<isZeroBranch)//是0阻抗 - { - std::cout<<"merge "<id.toStdString()<<" and "<id.toStdString()<toID=v->toID; - v->dispose=true; - foreach(BranchStruc* change,linkage[branch->toID]) - { - if(change->id==branch->id) - { - continue; - } - change->fromID=branch->toID; - } - } -// std::cout<<"start to visit next"<id!=branch->id) - { - this->visit(v,linkage);//深度优先 - } - - } -} - -void ElementReduction::visit2(BranchStruc* branch,QHash >& linkage) -{ -// std::cout<<"visit "<id.toStdString()<visited.contains(branch->id)) - { - std::cout<<"visited "<id.toStdString()<visited[branch->id]=0; - QString next; - next=branch->fromID; - QVector nextVec; - nextVec=linkage[next]; -// std::cout<<"next length"<dispose) - { -// std::cout<<"disposed "<id.toStdString()<isZeroBranch)//是0阻抗 - { - std::cout<<"merge "<id.toStdString()<<" and "<id.toStdString()<fromID=v->fromID; - v->dispose=true; - foreach(BranchStruc* change,linkage[branch->fromID]) - { - if(change->id==branch->id) - { - continue; - } - change->toID=branch->fromID; - } - } -// std::cout<<"start to visit next"<visit(v,linkage);//深度优先 - } -} diff --git a/testHasttable/elementreduction.h b/testHasttable/elementreduction.h index 67c5232..14d0912 100644 --- a/testHasttable/elementreduction.h +++ b/testHasttable/elementreduction.h @@ -20,10 +20,8 @@ public: ~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); - void visit2(BranchStruc* branch, QHash > &linkage); + void buildTreeTo(QDomElement &element, QDomDocument &root, QHash >& linkage, QHash& idToBranch); + void buildTreeFrom(QDomElement &element, QDomDocument &root, QHash >& linkage, QHash& idToBranch); const QList& branchList; QHash visited; };