diff --git a/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp b/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp index ab2b3ebcaef959b0cf643c494df5202bbc5b2c82..8c06fa67231a2cbe01086a44a91aead8653e5c76 100644 --- a/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp +++ b/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp @@ -709,13 +709,16 @@ bool OpenDriveXmlParser::ReadLane (LaneSection* laneSection, TiXmlElement *node, lane->SetSuccessor(successor); } - //Proceed to the Road width - subNode=node->FirstChildElement("width"); - while (subNode) - { - ReadLaneWidth(lane, subNode); - subNode=subNode->NextSiblingElement("width"); - } + if(side!=0) + { + //Proceed to the Road width + subNode=node->FirstChildElement("width"); + while (subNode) + { + ReadLaneWidth(lane, subNode); + subNode=subNode->NextSiblingElement("width"); + } + } //Proceed to the Road Mark subNode=node->FirstChildElement("roadMark"); @@ -725,45 +728,48 @@ bool OpenDriveXmlParser::ReadLane (LaneSection* laneSection, TiXmlElement *node, subNode=subNode->NextSiblingElement("roadMark"); } - //Proceed to the Lane Material - subNode=node->FirstChildElement("material"); - while (subNode) - { - ReadLaneMaterial(lane, subNode); - subNode=subNode->NextSiblingElement("material"); - } - - //Proceed to the Lane Visibility - subNode=node->FirstChildElement("visibility"); - while (subNode) - { - ReadLaneVisibility(lane, subNode); - subNode=subNode->NextSiblingElement("visibility"); - } - - //Proceed to the Lane speed - subNode=node->FirstChildElement("speed"); - while (subNode) - { - ReadLaneSpeed(lane, subNode); - subNode=subNode->NextSiblingElement("speed"); - } - - //Proceed to the Lane access - subNode=node->FirstChildElement("access"); - while (subNode) - { - ReadLaneAccess(lane, subNode); - subNode=subNode->NextSiblingElement("access"); - } - - //Proceed to the Lane height - subNode=node->FirstChildElement("height"); - while (subNode) - { - ReadLaneHeight(lane, subNode); - subNode=subNode->NextSiblingElement("height"); - } + if(side!=0) + { + //Proceed to the Lane Material + subNode=node->FirstChildElement("material"); + while (subNode) + { + ReadLaneMaterial(lane, subNode); + subNode=subNode->NextSiblingElement("material"); + } + + //Proceed to the Lane Visibility + subNode=node->FirstChildElement("visibility"); + while (subNode) + { + ReadLaneVisibility(lane, subNode); + subNode=subNode->NextSiblingElement("visibility"); + } + + //Proceed to the Lane speed + subNode=node->FirstChildElement("speed"); + while (subNode) + { + ReadLaneSpeed(lane, subNode); + subNode=subNode->NextSiblingElement("speed"); + } + + //Proceed to the Lane access + subNode=node->FirstChildElement("access"); + while (subNode) + { + ReadLaneAccess(lane, subNode); + subNode=subNode->NextSiblingElement("access"); + } + + //Proceed to the Lane height + subNode=node->FirstChildElement("height"); + while (subNode) + { + ReadLaneHeight(lane, subNode); + subNode=subNode->NextSiblingElement("height"); + } + } return true; } diff --git a/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.cpp b/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.cpp index 34e2ebdd0d2def8a37804a2ca48ddc90b559da22..fc3053d3d764cea53311ef8543f23beaf07d0d78 100644 --- a/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.cpp +++ b/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.cpp @@ -567,7 +567,7 @@ bool OpenDriveXmlWriter::WriteLaneSections (TiXmlElement *node, LaneSection *lan } else if(lType==0) { - WriteLane(nodeLanesCenter, lLane); + WriteLane(nodeLanesCenter, lLane,true); } else if(lType<0 && nodeLanesRight!=NULL) { @@ -579,7 +579,7 @@ bool OpenDriveXmlWriter::WriteLaneSections (TiXmlElement *node, LaneSection *lan } //-------------- -bool OpenDriveXmlWriter::WriteLane (TiXmlElement *node, Lane* lane) +bool OpenDriveXmlWriter::WriteLane (TiXmlElement *node, Lane* lane, bool center) { //Write Lane attributes int id; @@ -621,13 +621,15 @@ bool OpenDriveXmlWriter::WriteLane (TiXmlElement *node, Lane* lane) nodeLaneLinkSuccessor->SetAttribute("id",successor); } - //Lane Width - unsigned int lLaneWidthCount = lane->GetLaneWidthCount(); - for(unsigned int i=0; i<lLaneWidthCount; i++) - { - WriteLaneWidth(nodeLane, lane->GetLaneWidth(i)); - } - + if(!center) + { + //Lane Width + unsigned int lLaneWidthCount = lane->GetLaneWidthCount(); + for(unsigned int i=0; i<lLaneWidthCount; i++) + { + WriteLaneWidth(nodeLane, lane->GetLaneWidth(i)); + } + } //Lane Road Mark unsigned int lLaneRoadMark = lane->GetLaneRoadMarkCount(); for(unsigned int i=0; i<lLaneRoadMark; i++) @@ -635,40 +637,43 @@ bool OpenDriveXmlWriter::WriteLane (TiXmlElement *node, Lane* lane) WriteLaneRoadMark(nodeLane, lane->GetLaneRoadMark(i)); } - //Lane Material - unsigned int lLaneMaterial = lane->GetLaneMaterialCount(); - for(unsigned int i=0; i<lLaneMaterial; i++) - { - WriteLaneMaterial(nodeLane, lane->GetLaneMaterial(i)); - } - - //Lane Visibility - unsigned int lLaneVisibility = lane->GetLaneVisibilityCount(); - for(unsigned int i=0; i<lLaneVisibility; i++) - { - WriteLaneVisibility(nodeLane, lane->GetLaneVisibility(i)); - } - - //Lane speed - unsigned int lLaneSpeed = lane->GetLaneSpeedCount(); - for(unsigned int i=0; i<lLaneSpeed; i++) - { - WriteLaneSpeed(nodeLane, lane->GetLaneSpeed(i)); - } - - //Lane access - unsigned int lLaneAccess = lane->GetLaneAccessCount(); - for(unsigned int i=0; i<lLaneAccess; i++) - { - WriteLaneAccess(nodeLane, lane->GetLaneAccess(i)); - } - - //Lane height - unsigned int lLaneHeight = lane->GetLaneHeightCount(); - for(unsigned int i=0; i<lLaneHeight; i++) - { - WriteLaneHeight(nodeLane, lane->GetLaneHeight(i)); - } + if(!center) + { + //Lane Material + unsigned int lLaneMaterial = lane->GetLaneMaterialCount(); + for(unsigned int i=0; i<lLaneMaterial; i++) + { + WriteLaneMaterial(nodeLane, lane->GetLaneMaterial(i)); + } + + //Lane Visibility + unsigned int lLaneVisibility = lane->GetLaneVisibilityCount(); + for(unsigned int i=0; i<lLaneVisibility; i++) + { + WriteLaneVisibility(nodeLane, lane->GetLaneVisibility(i)); + } + + //Lane speed + unsigned int lLaneSpeed = lane->GetLaneSpeedCount(); + for(unsigned int i=0; i<lLaneSpeed; i++) + { + WriteLaneSpeed(nodeLane, lane->GetLaneSpeed(i)); + } + + //Lane access + unsigned int lLaneAccess = lane->GetLaneAccessCount(); + for(unsigned int i=0; i<lLaneAccess; i++) + { + WriteLaneAccess(nodeLane, lane->GetLaneAccess(i)); + } + + //Lane height + unsigned int lLaneHeight = lane->GetLaneHeightCount(); + for(unsigned int i=0; i<lLaneHeight; i++) + { + WriteLaneHeight(nodeLane, lane->GetLaneHeight(i)); + } + } return true; } diff --git a/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.h b/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.h index 2b51002ed10b38128b3e2b601efdd36004d8fa66..f4bf2a4d48438eb02bbc9da6880cc78a19a737e9 100644 --- a/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.h +++ b/OpenRoadEd/OpenDrive/OpenDriveXmlWriter.h @@ -53,7 +53,7 @@ public: bool WriteLanes (TiXmlElement *node, Road* road); bool WriteLaneSections (TiXmlElement *node, LaneSection *laneSection); - bool WriteLane (TiXmlElement *node, Lane* lane); + bool WriteLane (TiXmlElement *node, Lane* lane,bool center=false); bool WriteLaneWidth(TiXmlElement *node, LaneWidth* laneWidth); bool WriteLaneRoadMark(TiXmlElement *node, LaneRoadMark* laneRoadMark); bool WriteLaneMaterial(TiXmlElement *node, LaneMaterial* laneMaterial);