Răsfoiți Sursa

change tool/map_lanetoxdr. for object outline cornerRoad cornerLocal, add xml parser and writer code.

yuchuli 3 ani în urmă
părinte
comite
13df376dad

+ 95 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -1344,6 +1344,18 @@ bool OpenDriveXmlParser::ReadObjectOutlinesOutline(Object_outlines * pObject_out
         xoutline.SetlaneType(laneType);
     }
 
+    TiXmlElement *subNode = node->FirstChildElement("cornerRoad");
+    if (subNode)
+    {
+        ReadObjectOutlinesOutlinecornerRoad(&xoutline, subNode);
+    }
+
+    subNode = node->FirstChildElement("cornerLocal");
+    if (subNode)
+    {
+        ReadObjectOutlinesOutlinecornerRoad(&xoutline, subNode);
+    }
+
     pObject_outlines->SetObject_outlines_outline(xoutline);
 
     return true;
@@ -1409,7 +1421,90 @@ bool OpenDriveXmlParser::ReadObjectOutlinesOutline(Object * pObject,TiXmlElement
         poutline->SetlaneType(laneType);
     }
 
+    TiXmlElement *subNode = node->FirstChildElement("cornerRoad");
+    if (subNode)
+    {
+        ReadObjectOutlinesOutlinecornerRoad(poutline, subNode);
+    }
+
+    subNode = node->FirstChildElement("cornerLocal");
+    if (subNode)
+    {
+        ReadObjectOutlinesOutlinecornerRoad(poutline, subNode);
+    }
+
+
+    return true;
+}
+
+//--------------
+
+bool OpenDriveXmlParser::ReadObjectOutlinesOutlinecornerRoad(Object_outlines_outline *pObject_outline, TiXmlElement *node)
+{
+    double s,t,dz,height;
+    int id;
+
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryDoubleAttribute("s",&s);
+    checker+=node->QueryDoubleAttribute("t",&t);
+    checker+=node->QueryDoubleAttribute("dz",&dz);
+    checker+=node->QueryDoubleAttribute("height",&height);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Object outline cornerRoad attributes"<<endl;
+        return false;
+    }
 
+    pObject_outline->AddcornerRoad(s,t,dz,height);
+
+    Object_outlines_outline_cornerRoad * pcornerRoad = pObject_outline->GetLastAddedcornerRoad();
+
+    if(pcornerRoad == NULL)
+    {
+        std::cout<<" OpenDriveXmlParser::ReadObjectOutlinesOutlinecornerRoad pcorenerRoad is NULL"<<std::endl;
+        return false;
+    }
+
+    if(node->QueryIntAttribute("id",&id) == TIXML_SUCCESS)
+    {
+        pcornerRoad->Setid(id);
+    }
+
+    return true;
+}
+
+bool OpenDriveXmlParser::ReadObjectOutlinesOutlinecornerLocal(Object_outlines_outline *pObject_outline, TiXmlElement *node)
+{
+    double u,v,z,height;
+    int id;
+
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryDoubleAttribute("u",&u);
+    checker+=node->QueryDoubleAttribute("v",&v);
+    checker+=node->QueryDoubleAttribute("zz",&z);
+    checker+=node->QueryDoubleAttribute("height",&height);
+
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing Object outline cornerRoad attributes"<<endl;
+        return false;
+    }
+
+    pObject_outline->AddcornerLocal(u,v,z,height);
+
+    Object_outlines_outline_cornerLocal * pcornerLocal = pObject_outline->GetLastAddedcornerLocal();
+
+    if(pcornerLocal == NULL)
+    {
+        std::cout<<" OpenDriveXmlParser::ReadObjectOutlinesOutlinecornerLocal pcornerLocal is NULL"<<std::endl;
+        return false;
+    }
+
+    if(node->QueryIntAttribute("id",&id) == TIXML_SUCCESS)
+    {
+        pcornerLocal->Setid(id);
+    }
 
     return true;
 }

+ 2 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlParser.h

@@ -78,6 +78,8 @@ public:
     bool ReadObjectOutlines(Object * pObject,TiXmlElement *node);
     bool ReadObjectOutlinesOutline(Object_outlines * pObject_outlines,TiXmlElement *node);
     bool ReadObjectOutlinesOutline(Object * pObject,TiXmlElement *node);
+    bool ReadObjectOutlinesOutlinecornerRoad(Object_outlines_outline * pObject_outline,TiXmlElement * node);
+    bool ReadObjectOutlinesOutlinecornerLocal(Object_outlines_outline * pObject_outline,TiXmlElement * node);
 	bool ReadSignals (Road* road, TiXmlElement *node);
     bool ReadSignal(Road * road,TiXmlElement * node);
     bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);

+ 56 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -1423,6 +1423,62 @@ bool OpenDriveXmlWriter::WriteObjectOutlinesOutline(TiXmlElement *node, Object_o
     {
         nodeObjectOutlinesOutline->SetAttribute("laneType",laneType);
     }
+
+    unsigned int ncornerRoadCount = pObject_outlines_outline->GetcornerRoadCount();
+    unsigned int i;
+    for(i=0;i<ncornerRoadCount;i++)
+    {
+        Object_outlines_outline_cornerRoad * pcornerRoad = pObject_outlines_outline->GetcornerRoad(i);
+        WriteObjectOutlinesOutlinecornerRoad(nodeObjectOutlinesOutline,pcornerRoad);
+    }
+
+    unsigned int ncornerLocalCount = pObject_outlines_outline->GetcornerLocalCount();
+    for(i=0;i<ncornerLocalCount;i++)
+    {
+        Object_outlines_outline_cornerLocal * pcornerLocal = pObject_outlines_outline->GetcornerLocal(i);
+        WriteObjectOutlinesOutlinecornerLocal(nodeObjectOutlinesOutline,pcornerLocal);
+    }
+    return true;
+}
+
+//--------------
+
+bool OpenDriveXmlWriter::WriteObjectOutlinesOutlinecornerRoad(TiXmlElement *node, Object_outlines_outline_cornerRoad *pObject_outlines_outline_cornerRoad)
+{
+    TiXmlElement* nodecornerRoad = new TiXmlElement("cornerRoad");
+    node->LinkEndChild(nodecornerRoad);
+
+    nodecornerRoad->SetDoubleAttribute("s",pObject_outlines_outline_cornerRoad->Gets());
+    nodecornerRoad->SetDoubleAttribute("t",pObject_outlines_outline_cornerRoad->Gett());
+    nodecornerRoad->SetDoubleAttribute("dz",pObject_outlines_outline_cornerRoad->Getdz());
+    nodecornerRoad->SetDoubleAttribute("height",pObject_outlines_outline_cornerRoad->Getheight());
+
+    int id;
+    if(pObject_outlines_outline_cornerRoad->Getid(id) == 1)
+    {
+        nodecornerRoad->SetAttribute("id",id);
+    }
+
+    return true;
+}
+
+//--------------
+
+bool OpenDriveXmlWriter::WriteObjectOutlinesOutlinecornerLocal(TiXmlElement *node, Object_outlines_outline_cornerLocal *pObject_outlines_outline_cornerLocal)
+{
+    TiXmlElement* nodecornerLocal = new TiXmlElement("cornerLocal");
+    node->LinkEndChild(nodecornerLocal);
+
+    nodecornerLocal->SetDoubleAttribute("u",pObject_outlines_outline_cornerLocal->Getu());
+    nodecornerLocal->SetDoubleAttribute("v",pObject_outlines_outline_cornerLocal->Getv());
+    nodecornerLocal->SetDoubleAttribute("z",pObject_outlines_outline_cornerLocal->Getz());
+    nodecornerLocal->SetDoubleAttribute("height",pObject_outlines_outline_cornerLocal->Getheight());
+
+    int id;
+    if(pObject_outlines_outline_cornerLocal->Getid(id) == 1)
+    {
+        nodecornerLocal->SetAttribute("id",id);
+    }
     return true;
 }
 

+ 2 - 0
src/common/common/xodr/OpenDrive/OpenDriveXmlWriter.h

@@ -76,6 +76,8 @@ public:
     bool WriteObjectMaterial(TiXmlElement * node,Object_material * pObject_material);
     bool WriteObjectOutlines(TiXmlElement * node,Object_outlines * pObject_outlines);
     bool WriteObjectOutlinesOutline(TiXmlElement * node,Object_outlines_outline * pObject_outlines_outline);
+    bool WriteObjectOutlinesOutlinecornerRoad(TiXmlElement * node,Object_outlines_outline_cornerRoad * pObject_outlines_outline_cornerRoad);
+    bool WriteObjectOutlinesOutlinecornerLocal(TiXmlElement * node,Object_outlines_outline_cornerLocal * pObject_outlines_outline_cornerLocal);
 	bool WriteSignals (TiXmlElement *node, Road* road);
     bool WriteSignal(TiXmlElement * node, Signal * pSignal);
     bool WriteSignal_positionInertial(TiXmlElement * node, signal_positionInertial * pSignal_positionInertial);

+ 27 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline.cpp

@@ -83,11 +83,18 @@ void DialogRoadObject_outline::CreateView()
     mpPBDelete = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Delete",this);
     mpPBChange = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Change",this);
 
+    nVIndex++;
+
+    mpPBcornerRoad = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"cornerRoad",this);
+    mpPBcornerLocal = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"cornerLocal",this);
+
 
     connect(mpCBOutline,SIGNAL(currentIndexChanged(int)),this,SLOT(CurrentOutline(int)));
     connect(mpPBAdd,SIGNAL(clicked(bool)),this,SLOT(onClickAdd()));
     connect(mpPBDelete,SIGNAL(clicked(bool)),this,SLOT(onClickDelete()));
     connect(mpPBChange,SIGNAL(clicked(bool)),this,SLOT(onClickChange()));
+    connect(mpPBcornerRoad,SIGNAL(clicked(bool)),this,SLOT(onClickcornerRoad()));
+    connect(mpPBcornerLocal,SIGNAL(clicked(bool)),this,SLOT(onClickcornerLocal()));
 }
 
 void DialogRoadObject_outline::UpdateCB()
@@ -102,6 +109,17 @@ void DialogRoadObject_outline::UpdateCB()
     {
         mpCBOutline->addItem(QString("Outline ")+ QString::number(i));
     }
+
+    if(nOutlineCount == 0)
+    {
+        mpPBcornerLocal->setEnabled(false);
+        mpPBcornerRoad->setEnabled(false);
+    }
+    else
+    {
+        mpPBcornerLocal->setEnabled(true);
+        mpPBcornerRoad->setEnabled(true);
+    }
 }
 
 void DialogRoadObject_outline::CurrentOutline(int index)
@@ -340,3 +358,12 @@ void DialogRoadObject_outline::onClickChange()
     QMessageBox::information(this,"Info","Change outline successfully.",QMessageBox::YesAll);
 }
 
+void DialogRoadObject_outline::onClickcornerRoad()
+{
+
+}
+
+void DialogRoadObject_outline::onClickcornerLocal()
+{
+
+}

+ 5 - 0
src/tool/map_lanetoxodr/dialogroadobject_outline.h

@@ -31,6 +31,8 @@ private slots:
     void onClickAdd();
     void onClickDelete();
     void onClickChange();
+    void onClickcornerRoad();
+    void onClickcornerLocal();
 
 private:
     QComboBox * mpCBOutline;
@@ -40,6 +42,9 @@ private:
     QComboBox * mpCBclosed;
     QComboBox * mpCBlaneType;
 
+    QPushButton * mpPBcornerRoad;
+    QPushButton * mpPBcornerLocal;
+
     QPushButton * mpPBAdd;
     QPushButton * mpPBDelete;
     QPushButton * mpPBChange;

+ 22 - 0
src/tool/map_lanetoxodr/dialogroadobject_outlines.cpp

@@ -88,9 +88,16 @@ void DialogRoadObject_Outlines::CreateView()
     mpPBReset = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Reset",this);
     mpPBChange = ViewCreate::CreatePB(startpos_x+2*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"Change",this);
 
+    nVIndex++;
+    mpPBcornerRoad = ViewCreate::CreatePB(startpos_x+0*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"cornerRoad",this);
+    mpPBcornerLocal = ViewCreate::CreatePB(startpos_x+1*nPBSpace,startpos_y+nVIndex*nVSpace,nPBWidth,nHeight,"cornerLocal",this);
+
+
     connect(mpPBSet,SIGNAL(clicked(bool)),this,SLOT(onClickSet()));
     connect(mpPBReset,SIGNAL(clicked(bool)),this,SLOT(onClickReset()));
     connect(mpPBChange,SIGNAL(clicked(bool)),this,SLOT(onClickChange()));
+    connect(mpPBcornerRoad,SIGNAL(clicked(bool)),this,SLOT(onClickcornerRoad()));
+    connect(mpPBcornerLocal,SIGNAL(clicked(bool)),this,SLOT(onClickcornerLocal()));
 }
 
 void DialogRoadObject_Outlines::onClickSet()
@@ -193,6 +200,9 @@ void DialogRoadObject_Outlines::UpdateStatus()
     if(mpObject == 0)return;
     Object * pObject = mpObject;
 
+    mpPBcornerLocal->setEnabled(false);
+    mpPBcornerRoad->setEnabled(false);
+
     Object_outlines * pObject_outlines = pObject->Getoutlines();
     if(pObject_outlines == NULL)
     {
@@ -206,6 +216,8 @@ void DialogRoadObject_Outlines::UpdateStatus()
     else
     {
         mpLEstatus->setText("HAVE outlines");
+        mpPBcornerLocal->setEnabled(true);
+        mpPBcornerRoad->setEnabled(true);
         Object_outlines_outline xoutline;
         if(pObject_outlines->GetObject_outlines_outline(xoutline) == 1)
         {
@@ -277,3 +289,13 @@ void DialogRoadObject_Outlines::UpdateStatus()
         }
     }
 }
+
+void DialogRoadObject_Outlines::onClickcornerRoad()
+{
+
+}
+
+void DialogRoadObject_Outlines::onClickcornerLocal()
+{
+
+}

+ 5 - 0
src/tool/map_lanetoxodr/dialogroadobject_outlines.h

@@ -40,6 +40,8 @@ private slots:
     void onClickSet();
     void onClickReset();
     void onClickChange();
+    void onClickcornerRoad();
+    void onClickcornerLocal();
 
 private:
     QLineEdit * mpLEstatus;
@@ -49,6 +51,9 @@ private:
     QComboBox * mpCBclosed;
     QComboBox * mpCBlaneType;
 
+    QPushButton * mpPBcornerRoad;
+    QPushButton * mpPBcornerLocal;
+
     QPushButton * mpPBSet;
     QPushButton * mpPBReset;
     QPushButton * mpPBChange;