改为只从头节点还是找

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-01-22 11:00:39 +08:00
parent 9f6e6d7bf7
commit 5017c73f09
5 changed files with 43 additions and 12 deletions

View File

@ -161,7 +161,15 @@ void CIMExporter::exportTo(const QString& path)
{ {
if(!usedLoad.contains(name)) if(!usedLoad.contains(name))
{ {
std::cout<<name.toLocal8Bit().data()<<"not used"<<std::endl; LoadMatchException except;
if(!except.contains(name))
{
std::cout<<name.toLocal8Bit().data()<<"not used"<<std::endl;
}
else
{
std::cout<<name.toLocal8Bit().data()<<"not used but excepted."<<std::endl;
}
} }
} }
this->topologyTest(); this->topologyTest();

View File

@ -20,6 +20,7 @@
#include <QVector> #include <QVector>
#include "topologytest.h" #include "topologytest.h"
#include "elementreduction.h" #include "elementreduction.h"
#include "loadmatchexception.h"
#include <cmath> #include <cmath>
//#include "elementhashtable.h" //#include "elementhashtable.h"
//class Substation; //class Substation;

View File

@ -12,6 +12,15 @@ ElementReduction::~ElementReduction()
} }
void ElementReduction::calibration(const QString &id,QHash<QString,BranchStruc *> &idToBranch,QHash<QString,QVector<BranchStruc *> > &linkage)
{
QString to=idToBranch[id]->toID;
if(linkage[to].length()==1)
{
idToBranch[id]->fromID.swap(idToBranch[id]->toID);
}
}
void ElementReduction::doIt() void ElementReduction::doIt()
{ {
QHash<QString,QVector<BranchStruc *> > linkage; QHash<QString,QVector<BranchStruc *> > linkage;
@ -22,23 +31,28 @@ void ElementReduction::doIt()
idToBranch[v->id]=v; idToBranch[v->id]=v;
linkage[v->fromID].push_back(v); linkage[v->fromID].push_back(v);
linkage[v->toID].push_back(v); linkage[v->toID].push_back(v);
std::cout<<v->fromID.toStdString()<<" "<<v->id.toStdString()<<" "<<v->toID.toStdString()<<std::endl;
} }
QDomDocument root; QDomDocument root;
QDomElement element=root.createElement(this->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"<<std::endl;
root.appendChild(element); root.appendChild(element);
this->buildTreeTo(element,root,linkage,idToBranch); this->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->buildTreeFrom(element,root,linkage,idToBranch);
this->merge(element,idToBranch); this->merge(element,idToBranch);
// QFile file("1.xml"); QFile file("1.xml");
// if(file.open(QFile::WriteOnly)) if(file.open(QFile::WriteOnly))
// { {
//// root.setContent(&file); // root.setContent(&file);
// QTextStream writer(&file); QTextStream writer(&file);
// root.save(writer,4); root.save(writer,4);
// file.close(); file.close();
// } }
//看看是不是每个都访问到了 //看看是不是每个都访问到了
foreach(BranchStruc* v,this->branchList) foreach(BranchStruc* v,this->branchList)
{ {
@ -121,12 +135,15 @@ void ElementReduction::buildTreeTo(QDomElement &element,QDomDocument &root,QHash
nextTo=branch->toID; nextTo=branch->toID;
QVector<BranchStruc *> nextVec; QVector<BranchStruc *> nextVec;
nextVec=linkage[nextTo]; nextVec=linkage[nextTo];
std::cout<<nextVec.length()<<" of "<<element.tagName().toStdString()<<std::endl;
foreach(BranchStruc *n,nextVec) foreach(BranchStruc *n,nextVec)
{ {
if(this->visited.contains(n->id)) if(this->visited.contains(n->id))
{ {
continue; continue;
} }
// std::cout<<element.tagName().toStdString()<<"to can connect to "<<n->id.toStdString()<<std::endl;
// std::cout<<"add "<<n->id.toStdString()<<std::endl; // std::cout<<"add "<<n->id.toStdString()<<std::endl;
QDomElement newEle=root.createElement(n->id); QDomElement newEle=root.createElement(n->id);
// std::cout<<"create "<<n->id.toStdString()<<std::endl; // std::cout<<"create "<<n->id.toStdString()<<std::endl;
@ -149,12 +166,15 @@ void ElementReduction::buildTreeFrom(QDomElement &element,QDomDocument &root,QHa
QString nextFrom=branch->fromID; QString nextFrom=branch->fromID;
QVector<BranchStruc *> nextFromVec; QVector<BranchStruc *> nextFromVec;
nextFromVec=linkage[nextFrom]; nextFromVec=linkage[nextFrom];
foreach(BranchStruc *n,nextFromVec) foreach(BranchStruc *n,nextFromVec)
{ {
if(this->visited.contains(n->id)) if(this->visited.contains(n->id))
{ {
continue; continue;
} }
std::cout<<element.tagName().toStdString()<<"from can connect to "<<n->id.toStdString()<<std::endl;
// std::cout<<"add "<<n->id.toStdString()<<std::endl; // std::cout<<"add "<<n->id.toStdString()<<std::endl;
QDomElement newEle=root.createElement(n->id); QDomElement newEle=root.createElement(n->id);
// std::cout<<"create "<<n->id.toStdString()<<std::endl; // std::cout<<"create "<<n->id.toStdString()<<std::endl;

View File

@ -19,6 +19,7 @@ public:
void doIt(); void doIt();
~ElementReduction(); ~ElementReduction();
private: private:
void calibration(const QString &id, QHash<QString, BranchStruc *> &idToBranch, QHash<QString, QVector<BranchStruc *> > &linkage);
void merge(QDomElement &element, QHash<QString,BranchStruc *>& idToBranch); void merge(QDomElement &element, QHash<QString,BranchStruc *>& idToBranch);
void buildTreeTo(QDomElement &element, QDomDocument &root, QHash<QString,QVector<BranchStruc *> >& linkage, QHash<QString,BranchStruc *>& idToBranch); void buildTreeTo(QDomElement &element, QDomDocument &root, QHash<QString,QVector<BranchStruc *> >& linkage, QHash<QString,BranchStruc *>& idToBranch);
void buildTreeFrom(QDomElement &element, QDomDocument &root, QHash<QString,QVector<BranchStruc *> >& linkage, QHash<QString,BranchStruc *>& idToBranch); void buildTreeFrom(QDomElement &element, QDomDocument &root, QHash<QString,QVector<BranchStruc *> >& linkage, QHash<QString,BranchStruc *>& idToBranch);

View File

@ -1,5 +1,6 @@
#727泰林东乙线,AC-671678,D:\Project\佛山项目\数据\搭网架参数文件\泰安\泰安负荷\727泰林东乙线,(FD-2096,), #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,) 709美的甲线,AC-671399,D:\Project\佛山项目\数据\搭网架参数文件\北滘\北滘负荷\709美的甲线、720美的乙线,(FD-2003,)
720美的乙线,AC-671401,D:\Project\佛山项目\数据\搭网架参数文件\北滘\北滘负荷\709美的甲线、720美的乙线,(FD-2003,) 720美的乙线,AC-671401,D:\Project\佛山项目\数据\搭网架参数文件\北滘\北滘负荷\709美的甲线、720美的乙线,(FD-2003,)