#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier #include "ReadXML.h" string ini = "--"; map, Bund> wire_node; vector wire_pairs; map mp; map wiremap; map pinidmap; map pinmap; int cnt = 0; // 针脚 Pin::Pin(string name1, string id1) { name = name1; id = id1; } Pin::Pin(string name1, string id1, P coord1) { name = name1; id = id1; coord = coord1; } Pin::Pin() { name = id = ""; } // 逻辑上的导线 Wire::Wire(string name1, Pin sn1, Pin en1) { name = name1; sn = sn1; en = en1; } Wire::Wire() { name = ""; } // 逻辑上的线束 Bund::Bund() { dia = length = 0; } // void init_readxml() // { // wire_node.clear(); // wire_pairs.clear(); // mp.clear(); // wiremap.clear(); // pinidmap.clear(); // pinmap.clear(); // cnt = 0; // } // // void producePin(TiXmlElement* pin){ // pinidmap[pin->Attribute("id")]=pin->Attribute("name"); //} // string safegave(TiXmlElement* pEle,const char * t){ // if(pEle->Attribute(t)==NULL)return ini; // else { // string v=pEle->Attribute(t); // if(v=="")return ini; // else return v; // } //} // // TiXmlElement* GetNodePointerByName(TiXmlElement* pRootEle, const char* strNodeName) //{ // // if equal root node then return // if (0 == strcmp(strNodeName, pRootEle->Value())) // { // return pRootEle; // } // // TiXmlElement* pEle = pRootEle; // for (pEle = pRootEle->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement()) // { // // recursive find sub node return node pointer // if (0 != strcmp(pEle->Value(), strNodeName)) // { // TiXmlElement* res=GetNodePointerByName(pEle,strNodeName); // if(res!=NULL)return res; // } // else return pEle; // } // // return NULL; //} // TiXmlElement* GetNextNodePointerByName(TiXmlElement* pRootEle, const char* strNodeName) //{ // // if equal root node then return // TiXmlElement* pEle; // for (pEle = pRootEle->NextSiblingElement(); pEle; pEle = pEle->NextSiblingElement()) // { // // recursive find sub node return node pointer // if (0 == strcmp(pEle->Value(), strNodeName))return pEle; // } // return NULL; //} // void produceConnector(TiXmlElement* pcon){ // Connector con; // con.id=pcon->Attribute("id"); // con.name=pcon->Attribute("name"); // con.partnumber=pcon->Attribute("partnumber"); // con.coord=mp[con.name]; // con.dir=P(0,0,0); // connectorNum++; // con.ID=connectorNum; // con.coord.type=3; // con.coord.ref=connectorNum; // // connectors[connectorNum]=con; // // TiXmlElement* pEle; // TiXmlElement* p; // for (pEle = pcon->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement()){ // if(strcmp(pEle->Value(), "backshell")==0){ // for(p=pEle->FirstChildElement();p;p = p->NextSiblingElement()){ // if(strcmp(p->Value(), "termination")==0){ // string id=p->Attribute("id"); // string name=p->Attribute("name"); // // pinmap[id]=Pin(name,id,con.coord); // break; // } // } // break; // } // } // for (pEle = pcon->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement()){ // if(strcmp(pEle->Value(), "pin")==0){ // string id=pEle->Attribute("id"); // string name=pEle->Attribute("name"); // pinmap[id]=Pin(name,id,con.coord); // } // } // // //} // // void produceWire(TiXmlElement* pwire){ // Pin sn,en; // TiXmlElement* pconnection=GetNodePointerByName(pwire,"connection"); // if(pconnection!=NULL){ // sn=pinmap[pconnection->Attribute("pinref")]; // TiXmlElement* pconnection2=GetNextNodePointerByName(pconnection,"connection"); // if(pconnection2!=NULL)en=pinmap[pconnection2->Attribute("pinref")]; // else en=sn; // } // Wire wire; // wire.sn=sn; // wire.en=en; // wire.name=pwire->Attribute("name"); // if(pwire->Attribute("outsidediameter")!=NULL){ // wire.diameter=atof(pwire->Attribute("outsidediameter")); // } // else if(pwire->Attribute("wirecsa")!=NULL){ // wire.diameter=atof(pwire->Attribute("wirecsa"))*2; // } // else wire.diameter=0.4; // wiremap[wire.name]=wire; // if(sn.coord==P(0,0,0)||en.coord==P(0,0,0)||sn.coord==en.coord)return; // // pair p=make_pair(sn.coord,en.coord); // pair pr=make_pair(en.coord,sn.coord); // if(wire_node.find(p)!=wire_node.end()){ // Bund bd=wire_node[p]; // bd.wirelist.push_back(wire); // bd.d.push_back(wire.diameter); // wire_node[p]=bd; // } // else if(wire_node.find(pr)!=wire_node.end()){ // Bund bd=wire_node[pr]; // bd.wirelist.push_back(wire); // bd.d.push_back(wire.diameter); // wire_node[pr]=bd; // } // else { // Bund bd; // bd.start=sn.coord; // bd.goal=en.coord; // bd.wirelist.push_back(wire); // bd.d.push_back(wire.diameter); // wire_node[p]=bd; // // } // //} // void produce(TiXmlElement* pEle){ // if(strcmp(pEle->Value(),"wire")==0)produceWire(pEle); // else produceConnector(pEle); // return; //} // void ProduceNodePointerByName(TiXmlElement* pRootEle, const char* strNodeName) //{ // // if equal root node then return // if (0 == strcmp(strNodeName, pRootEle->Value())) // { // produce(pRootEle); // return; // } // // TiXmlElement* pEle = pRootEle; // for (pEle = pRootEle->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement()) // { // // recursive find sub node return node pointer // if (0 != strcmp(pEle->Value(), strNodeName)) // { // ProduceNodePointerByName(pEle,strNodeName); // } // else { // produce(pEle); // } // } // // return; //} // void readxml(const char * xml,const char * connectorFile){ // init_readxml(); // ifstream infile; // infile.open(connectorFile);//XXXX是csv的路径 // // string s; // // while(getline(infile,s)) // { // //cout< fields; //声明一个字符串向量 // string field; // while (getline(sin, field, ',')) //将字符串流sin中的字符读入到field字符串中,以逗号为分隔符 // { // fields.push_back(field); //将刚刚读取的字符串添加到向量fields中 // } // //cout<LoadFile()))return; // //pDoc->Print(); // //获得根元素,即Persons。 // // //cout<<"connectivity"<RootElement(); // TiXmlElement * connectivity=GetNodePointerByName(RootElement, "connectivity"); // //cout<<(connectivity->Value())<Attribute("id")==NULL)< ,Bund>::iterator it=wire_node.begin();it!=wire_node.end();it++){ // wire_pairs.push_back(it->second); // // } // for(int i=0;i