From 5017c73f09d3fb5e74121964fb2cf840e4ce7314 Mon Sep 17 00:00:00 2001 From: "dmy@lab" Date: Thu, 22 Jan 2015 11:00:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8F=AA=E4=BB=8E=E5=A4=B4?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E8=BF=98=E6=98=AF=E6=89=BE?= 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/cimexporter.h | 1 + testHasttable/elementreduction.cpp | 40 ++++++++++++++++++++++-------- testHasttable/elementreduction.h | 1 + testHasttable/task.txt | 3 ++- 5 files changed, 43 insertions(+), 12 deletions(-) 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,)