diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index 2f36b70..ed1783c 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -161,7 +161,15 @@ void CIMExporter::exportTo(const QString& path) { if(!usedLoad.contains(name)) { - std::cout<topologyTest(); diff --git a/testHasttable/cimexporter.h b/testHasttable/cimexporter.h index caccfe4..2b19142 100644 --- a/testHasttable/cimexporter.h +++ b/testHasttable/cimexporter.h @@ -20,6 +20,7 @@ #include #include "topologytest.h" #include "elementreduction.h" +#include "loadmatchexception.h" #include //#include "elementhashtable.h" //class Substation; diff --git a/testHasttable/elementreduction.cpp b/testHasttable/elementreduction.cpp index 3139324..c11f883 100644 --- a/testHasttable/elementreduction.cpp +++ b/testHasttable/elementreduction.cpp @@ -12,6 +12,15 @@ ElementReduction::~ElementReduction() } +void ElementReduction::calibration(const QString &id,QHash &idToBranch,QHash > &linkage) +{ + QString to=idToBranch[id]->toID; + if(linkage[to].length()==1) + { + idToBranch[id]->fromID.swap(idToBranch[id]->toID); + } +} + void ElementReduction::doIt() { QHash > linkage; @@ -22,23 +31,28 @@ void ElementReduction::doIt() idToBranch[v->id]=v; linkage[v->fromID].push_back(v); linkage[v->toID].push_back(v); + std::cout<fromID.toStdString()<<" "<id.toStdString()<<" "<toID.toStdString()<branchList.at(2)->id); + +// QDomElement element=root.createElement(this->branchList.at(2)->id); + QDomElement element=root.createElement("AC-671677"); + this->calibration("AC-671677",idToBranch,linkage); + std::cout<<"start "<<"AC-671677"<buildTreeTo(element,root,linkage,idToBranch); - this->visited.remove(this->branchList.at(2)->id); +// this->visited.remove(this->branchList.at(2)->id); 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); + 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) { @@ -121,12 +135,15 @@ void ElementReduction::buildTreeTo(QDomElement &element,QDomDocument &root,QHash nextTo=branch->toID; QVector nextVec; nextVec=linkage[nextTo]; + std::cout<visited.contains(n->id)) { continue; } +// std::cout<id.toStdString()<id.toStdString()<id); // std::cout<<"create "<id.toStdString()<fromID; QVector nextFromVec; nextFromVec=linkage[nextFrom]; + foreach(BranchStruc *n,nextFromVec) { + if(this->visited.contains(n->id)) { continue; } + std::cout<id.toStdString()<id.toStdString()<id); // std::cout<<"create "<id.toStdString()< &idToBranch, QHash > &linkage); void merge(QDomElement &element, QHash& idToBranch); void buildTreeTo(QDomElement &element, QDomDocument &root, QHash >& linkage, QHash& idToBranch); void buildTreeFrom(QDomElement &element, QDomDocument &root, QHash >& linkage, QHash& idToBranch); diff --git a/testHasttable/task.txt b/testHasttable/task.txt index ef64386..4f210ee 100644 --- a/testHasttable/task.txt +++ b/testHasttable/task.txt @@ -1,5 +1,6 @@ #727ֶ̩,AC-671678,D:\Project\ɽĿ\\ܲļ\̩\̩\727ֶ̩,(FD-2096,), -721Դ,AC-591821,D:\Project\ɽĿ\\ܲļ\\򸺺\721Դ,(FD-2014,FD-2019,FD-2000,) +#721Դ,AC-591821,D:\Project\ɽĿ\\ܲļ\\򸺺\721Դ,(FD-2014,FD-2019,FD-2000,) +726Ƹּ,AC-671677,D:\Project\ɽĿ\\ܲļ\̩\̩\726Ƹּ,(FD-2038) 709ļ,AC-671399,D:\Project\ɽĿ\\ܲļ\\򸺺\709ļߡ720,(FD-2003,) 720,AC-671401,D:\Project\ɽĿ\\ܲļ\\򸺺\709ļߡ720,(FD-2003,)