|
|
@ -7,7 +7,9 @@ |
|
|
|
#include <cmath> |
|
|
|
#include <fstream> |
|
|
|
#include <sstream> |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
string ini = "--"; |
|
|
|
|
|
|
|
// Őë˝Ĺ
|
|
|
@ -85,11 +87,11 @@ void init_readxml() |
|
|
|
cnt = 0; |
|
|
|
} |
|
|
|
|
|
|
|
void producePin(TiXmlElement *pin) |
|
|
|
void producePin(tinyxml2::XMLElement *pin) |
|
|
|
{ |
|
|
|
pinidmap[pin->Attribute("id")] = pin->Attribute("name"); |
|
|
|
} |
|
|
|
string safegave(TiXmlElement *pEle, const char *t) |
|
|
|
string safegave(tinyxml2::XMLElement *pEle, const char *t) |
|
|
|
{ |
|
|
|
if (pEle->Attribute(t) == NULL) |
|
|
|
return ini; |
|
|
@ -103,7 +105,7 @@ string safegave(TiXmlElement *pEle, const char *t) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TiXmlElement *GetNodePointerByName(TiXmlElement *pRootEle, const char *strNodeName) |
|
|
|
tinyxml2::XMLElement *GetNodePointerByName(tinyxml2::XMLElement *pRootEle, const char *strNodeName) |
|
|
|
{ |
|
|
|
// if equal root node then return
|
|
|
|
if (0 == strcmp(strNodeName, pRootEle->Value())) |
|
|
@ -111,13 +113,13 @@ TiXmlElement *GetNodePointerByName(TiXmlElement *pRootEle, const char *strNodeNa |
|
|
|
return pRootEle; |
|
|
|
} |
|
|
|
|
|
|
|
TiXmlElement *pEle = pRootEle; |
|
|
|
tinyxml2::XMLElement *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); |
|
|
|
tinyxml2::XMLElement *res = GetNodePointerByName(pEle, strNodeName); |
|
|
|
if (res != NULL) |
|
|
|
return res; |
|
|
|
} |
|
|
@ -127,10 +129,10 @@ TiXmlElement *GetNodePointerByName(TiXmlElement *pRootEle, const char *strNodeNa |
|
|
|
|
|
|
|
return NULL; |
|
|
|
} |
|
|
|
TiXmlElement *GetNextNodePointerByName(TiXmlElement *pRootEle, const char *strNodeName) |
|
|
|
tinyxml2::XMLElement *GetNextNodePointerByName(tinyxml2::XMLElement *pRootEle, const char *strNodeName) |
|
|
|
{ |
|
|
|
// if equal root node then return
|
|
|
|
TiXmlElement *pEle; |
|
|
|
tinyxml2::XMLElement *pEle; |
|
|
|
for (pEle = pRootEle->NextSiblingElement(); pEle; pEle = pEle->NextSiblingElement()) |
|
|
|
{ |
|
|
|
// recursive find sub node return node pointer
|
|
|
@ -139,7 +141,7 @@ TiXmlElement *GetNextNodePointerByName(TiXmlElement *pRootEle, const char *strNo |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
void produceConnector(TiXmlElement *pcon) |
|
|
|
void produceConnector(tinyxml2::XMLElement *pcon) |
|
|
|
{ |
|
|
|
Connector con; |
|
|
|
con.id = pcon->Attribute("id"); |
|
|
@ -154,8 +156,8 @@ void produceConnector(TiXmlElement *pcon) |
|
|
|
|
|
|
|
connectors[connectorNum] = con; |
|
|
|
|
|
|
|
TiXmlElement *pEle; |
|
|
|
TiXmlElement *p; |
|
|
|
tinyxml2::XMLElement *pEle; |
|
|
|
tinyxml2::XMLElement *p; |
|
|
|
for (pEle = pcon->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement()) |
|
|
|
{ |
|
|
|
if (strcmp(pEle->Value(), "backshell") == 0) |
|
|
@ -185,14 +187,14 @@ void produceConnector(TiXmlElement *pcon) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void produceWire(TiXmlElement *pwire) |
|
|
|
void produceWire(tinyxml2::XMLElement *pwire) |
|
|
|
{ |
|
|
|
Pin sn, en; |
|
|
|
TiXmlElement *pconnection = GetNodePointerByName(pwire, "connection"); |
|
|
|
tinyxml2::XMLElement *pconnection = GetNodePointerByName(pwire, "connection"); |
|
|
|
if (pconnection != NULL) |
|
|
|
{ |
|
|
|
sn = pinmap[pconnection->Attribute("pinref")]; |
|
|
|
TiXmlElement *pconnection2 = GetNextNodePointerByName(pconnection, "connection"); |
|
|
|
tinyxml2::XMLElement *pconnection2 = GetNextNodePointerByName(pconnection, "connection"); |
|
|
|
if (pconnection2 != NULL) |
|
|
|
en = pinmap[pconnection2->Attribute("pinref")]; |
|
|
|
else |
|
|
@ -242,7 +244,7 @@ void produceWire(TiXmlElement *pwire) |
|
|
|
wire_node[p] = bd; |
|
|
|
} |
|
|
|
} |
|
|
|
void produce(TiXmlElement *pEle) |
|
|
|
void produce(tinyxml2::XMLElement *pEle) |
|
|
|
{ |
|
|
|
if (strcmp(pEle->Value(), "wire") == 0) |
|
|
|
produceWire(pEle); |
|
|
@ -250,7 +252,7 @@ void produce(TiXmlElement *pEle) |
|
|
|
produceConnector(pEle); |
|
|
|
return; |
|
|
|
} |
|
|
|
void ProduceNodePointerByName(TiXmlElement *pRootEle, const char *strNodeName) |
|
|
|
void ProduceNodePointerByName(tinyxml2::XMLElement *pRootEle, const char *strNodeName) |
|
|
|
{ |
|
|
|
// if equal root node then return
|
|
|
|
if (0 == strcmp(strNodeName, pRootEle->Value())) |
|
|
@ -259,7 +261,7 @@ void ProduceNodePointerByName(TiXmlElement *pRootEle, const char *strNodeName) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
TiXmlElement *pEle = pRootEle; |
|
|
|
tinyxml2::XMLElement *pEle = pRootEle; |
|
|
|
for (pEle = pRootEle->FirstChildElement(); pEle; pEle = pEle->NextSiblingElement()) |
|
|
|
{ |
|
|
|
// recursive find sub node return node pointer
|
|
|
@ -275,7 +277,7 @@ void ProduceNodePointerByName(TiXmlElement *pRootEle, const char *strNodeName) |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
void readxml(const char *xml, const char *connectorFile) |
|
|
|
void readxml(const string xml, const string connectorFile) |
|
|
|
{ |
|
|
|
init_readxml(); |
|
|
|
ifstream infile; |
|
|
@ -299,15 +301,17 @@ void readxml(const char *xml, const char *connectorFile) |
|
|
|
mp[fields[0]] = P(atof(fields[1].c_str()), atof(fields[2].c_str()), atof(fields[3].c_str())); |
|
|
|
} |
|
|
|
|
|
|
|
TiXmlDocument *pDoc = new TiXmlDocument(xml); |
|
|
|
if (!(pDoc->LoadFile())) |
|
|
|
tinyxml2::XMLDocument pDoc; |
|
|
|
tinyxml2::XMLError error = pDoc.LoadFile(xml.c_str()); |
|
|
|
if (error != tinyxml2::XMLError::XML_SUCCESS) |
|
|
|
return; |
|
|
|
|
|
|
|
// pDoc->Print();
|
|
|
|
// ťńľĂ¸ůÔŞËŘŁŹź´PersonsĄŁ
|
|
|
|
|
|
|
|
// cout<<"connectivity"<<endl<<endl;
|
|
|
|
TiXmlElement *RootElement = pDoc->RootElement(); |
|
|
|
TiXmlElement *connectivity = GetNodePointerByName(RootElement, "connectivity"); |
|
|
|
tinyxml2::XMLElement *RootElement = pDoc.RootElement(); |
|
|
|
tinyxml2::XMLElement *connectivity = GetNodePointerByName(RootElement, "connectivity"); |
|
|
|
// cout<<(connectivity->Value())<<endl;
|
|
|
|
// cout<<(connectivity->Attribute("id")==NULL)<<endl;
|
|
|
|
ProduceNodePointerByName(connectivity, "connector"); |
|
|
|