Skip to content

Commit

Permalink
refractor: removed default namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jannikbusse committed Dec 5, 2023
1 parent aba4480 commit 6df43e2
Show file tree
Hide file tree
Showing 17 changed files with 258 additions and 259 deletions.
42 changes: 21 additions & 21 deletions src/connection/closeRoadConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @param phi2 angle of end point
* @return int error code
*/
int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1, double x2, double y2, double phi2)
int closeRoadConnection(std::vector<geometry> &geo, double x1, double y1, double phi1, double x2, double y2, double phi2)
{
// goal: compute new road from point 1 to point 2, preserving angles

Expand Down Expand Up @@ -85,12 +85,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double phiTmp = phi1 + M_PI / 2;
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phiTmp))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (closeRoadConnection(geo, xTmp, yTmp, phiTmp, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand All @@ -111,12 +111,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double phiTmp = phi1 + M_PI / 2;
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phiTmp))
{
cerr << "ERR: error in addArc function." << std::endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (closeRoadConnection(geo, xTmp, yTmp, phiTmp, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand Down Expand Up @@ -152,12 +152,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double phiTmp = phi1 + M_PI / 2;
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phiTmp))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (closeRoadConnection(geo, xTmp, yTmp, phiTmp, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand All @@ -169,7 +169,7 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
addLine(geo, x1, y1, phi1, iPx, iPy, phi1);
if (closeRoadConnection(geo, iPx, iPy, phi1, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand All @@ -190,12 +190,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double phiTmp = phi1 + M_PI / 2;
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phiTmp))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (closeRoadConnection(geo, xTmp, yTmp, phiTmp, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand All @@ -207,12 +207,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double phiTmp = phi1 - M_PI / 2;
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phiTmp))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (closeRoadConnection(geo, xTmp, yTmp, phiTmp, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand All @@ -229,7 +229,7 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
addLine(geo, x1, y1, phi1, xTmp, yTmp, phi1);
if (addArc(geo, xTmp, yTmp, phi1, x2, y2, phi2))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
}
Expand All @@ -240,12 +240,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double yTmp = y2 - sin(phi2) * (d2 - d1);
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phi2))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (addLine(geo, xTmp, yTmp, phi2, x2, y2, phi2))
{
cerr << "ERR: error in addLine function." << endl;
std::cerr << "ERR: error in addLine function." << std::endl;
return 1;
}
}
Expand All @@ -254,7 +254,7 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
{
if (addArc(geo, x1, y1, phi1, x2, y2, phi2))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
}
Expand All @@ -265,7 +265,7 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
// almost nothing to be done
if (addLine(geo, x1, y1, phi1, x2, y2, phi2))
{
cerr << "ERR: error in addLine function." << endl;
std::cerr << "ERR: error in addLine function." << std::endl;
return 1;
}
}
Expand All @@ -290,12 +290,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double phiTmp = phi1 + 2 * alpha;
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phiTmp))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (closeRoadConnection(geo, xTmp, yTmp, phiTmp, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand All @@ -317,12 +317,12 @@ int closeRoadConnection(vector<geometry> &geo, double x1, double y1, double phi1
double phiTmp = phi1 + 2 * beta;
if (addArc(geo, x1, y1, phi1, xTmp, yTmp, phiTmp))
{
cerr << "ERR: error in addArc function." << endl;
std::cerr << "ERR: error in addArc function." << std::endl;
return 1;
}
if (closeRoadConnection(geo, xTmp, yTmp, phiTmp, x2, y2, phi2))
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/connection/closeRoadNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern settings setting;
int closeRoadNetwork(const DOMElement* rootNode, roadNetwork &data)
{
if(!setting.silentMode)
cout << "Processing closeRoadNetwork" << endl;
std::cout << "Processing closeRoadNetwork" << std::endl;

DOMElement* closeRoad = getChildWithName(rootNode, "closeRoads");

Expand All @@ -55,8 +55,8 @@ int closeRoadNetwork(const DOMElement* rootNode, roadNetwork &data)
int toSegment = readIntAttrFromNode(segmentLink, "toSegment");
int fromRoadId = readIntAttrFromNode(segmentLink, "fromRoad");
int toRoadId = readIntAttrFromNode(segmentLink, "toRoad");
string fromPos = readStrAttrFromNode(segmentLink, "fromPos");
string toPos = readStrAttrFromNode(segmentLink, "toPos");
std::string fromPos = readStrAttrFromNode(segmentLink, "fromPos");
std::string toPos = readStrAttrFromNode(segmentLink, "toPos");
road fromRoad;
road toRoad;

Expand Down Expand Up @@ -122,14 +122,14 @@ int closeRoadNetwork(const DOMElement* rootNode, roadNetwork &data)
}
else
{
cerr << "ERR: wrong position for fromPos is specified." << endl;
cerr << "\t -> use 'start' or 'end'" << endl;
std::cerr << "ERR: wrong position for fromPos is specified." << std::endl;
std::cerr << "\t -> use 'start' or 'end'" << std::endl;
return 1;
}
}
if (!found)
{
cerr << "ERR: from road not found." << endl;
std::cerr << "ERR: from road not found." << std::endl;
return 1;
}

Expand Down Expand Up @@ -176,14 +176,14 @@ int closeRoadNetwork(const DOMElement* rootNode, roadNetwork &data)
}
else
{
cerr << "ERR: wrong position for toPos is specified." << endl;
cerr << "\t -> use 'start' or 'end'" << endl;
std::cerr << "ERR: wrong position for toPos is specified." << std::endl;
std::cerr << "\t -> use 'start' or 'end'" << std::endl;
return 1;
}
}
if (!found)
{
cerr << "ERR: to road not found." << endl;
std::cerr << "ERR: to road not found." << std::endl;
return 1;
}

Expand All @@ -195,7 +195,7 @@ int closeRoadNetwork(const DOMElement* rootNode, roadNetwork &data)
// --- build new geometry ----------------------------------------------
if (closeRoadConnection(rConnection.geometries, fromX, fromY, fromHdg, toX, toY, toHdg)) //the tohdg angle is wrong some of the time
{
cerr << "ERR: error in closeRoadConnection function." << endl;
std::cerr << "ERR: error in closeRoadConnection function." << std::endl;
return 1;
}

Expand All @@ -208,7 +208,7 @@ int closeRoadNetwork(const DOMElement* rootNode, roadNetwork &data)
}

// --- add lanes -------------------------------------------------------
vector<laneSection> secs;
std::vector<laneSection> secs;

// flip lanes if in false direction
if (fromPos == "start")
Expand Down
34 changes: 17 additions & 17 deletions src/connection/linkSegments.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int resolveAlignmentConflicts(roadNetwork &data)
int borderingLaneSection = 0;
if(r.successor.contactPoint == endType)
borderingLaneSection = r.laneSections.size() - 1;
vector<int> laneIds;
std::vector<int> laneIds;
for(lane &l: r.laneSections.at(borderingLaneSection).lanes)
{
laneIds.insert(laneIds.begin(), l.id);
Expand All @@ -66,7 +66,7 @@ int resolveAlignmentConflicts(roadNetwork &data)
r.laneSections.at(borderingLaneSection).lanes[i].sucId = laneIds[i];
}

cerr << "switched road " << r.id << " and succ " <<suc->id << endl;
std::cerr << "switched road " << r.id << " and succ " <<suc->id << std::endl;

}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ int resolveAlignmentConflicts(roadNetwork &data)
int borderingLaneSection = 0;
if(r.predecessor.contactPoint == endType)
borderingLaneSection = r.laneSections.size() - 1;
vector<int> laneIds;
std::vector<int> laneIds;
for(lane &l: r.laneSections.at(borderingLaneSection).lanes)
{
laneIds.insert(laneIds.begin(), l.id);
Expand All @@ -106,7 +106,7 @@ int resolveAlignmentConflicts(roadNetwork &data)
r.laneSections.at(borderingLaneSection).lanes[i].preId = laneIds[i];
}

cerr << "switched road " << r.id << " and pre " <<pre->id << endl;
std::cerr << "switched road " << r.id << " and pre " <<pre->id << std::endl;

}
}
Expand Down Expand Up @@ -192,8 +192,8 @@ int transformRoad(DOMElement *segmentLink, roadNetwork &data, bool swap = false)
int toSegment = readIntAttrFromNode(segmentLink, "toSegment");
int fromRoadId = readIntAttrFromNode(segmentLink, "fromRoad");
int toRoadId = readIntAttrFromNode(segmentLink, "toRoad");
string fromPos = readStrAttrFromNode(segmentLink, "fromPos");
string toPos = readStrAttrFromNode(segmentLink, "toPos");
std::string fromPos = readStrAttrFromNode(segmentLink, "fromPos");
std::string toPos = readStrAttrFromNode(segmentLink, "toPos");
if(swap)
{
fromSegment = readIntAttrFromNode(segmentLink, "toSegment");
Expand Down Expand Up @@ -450,15 +450,15 @@ extern settings setting;
int linkSegments(const DOMElement* rootNode, roadNetwork &data)
{
if(!setting.silentMode)
cout << "Processing linkSegments" << endl;
std::cout << "Processing linkSegments" << std::endl;


DOMElement *links = getChildWithName(rootNode, "links");
if (links == NULL)
{
if(!setting.silentMode)
{
cout << "\tLinks are not specified -> skip segment linking" << endl;
std::cout << "\tLinks are not specified -> skip segment linking" << std::endl;
}
throwWarning("'links' are not specified in input file.\n\t -> skip segment linking", true);

Expand Down Expand Up @@ -492,20 +492,20 @@ int linkSegments(const DOMElement* rootNode, roadNetwork &data)
}

//generate a map to store all outgoing links of each segment
std::map<int, vector<int>> outgoing_connections;
std::map<int, vector<int>> incoming_connections;
std::map<int, std::vector<int>> outgoing_connections;
std::map<int, std::vector<int>> incoming_connections;


int linkcount = links->getChildElementCount();

if(linkcount <= 0 && !setting.silentMode)
{
cout << "\tNo links are defined" << endl;
std::cout << "\tNo links are defined" << std::endl;
return 0;
}
else if(!setting.silentMode)
{
cout << "\t"<< linkcount << " links are defined" << endl;
std::cout << "\t"<< linkcount << " links are defined" << std::endl;
}

for (DOMElement *segmentLink = links->getFirstElementChild();segmentLink != NULL; segmentLink = segmentLink->getNextElementSibling())
Expand All @@ -520,8 +520,8 @@ int linkSegments(const DOMElement* rootNode, roadNetwork &data)

}

queue<int> toDo = queue<int>(); //remaining segments
vector<int> transformedIds;
std::queue<int> toDo = std::queue<int>(); //remaining segments
std::vector<int> transformedIds;
toDo.push(refId);

while(!toDo.empty())
Expand Down Expand Up @@ -570,7 +570,7 @@ int linkSegments(const DOMElement* rootNode, roadNetwork &data)
}

//check if all roads are connected to the network
vector<road*> v;
std::vector<road*> v;
for(road &r: data.roads)
{
if(!r.isLinkedToNetwork)
Expand All @@ -584,8 +584,8 @@ int linkSegments(const DOMElement* rootNode, roadNetwork &data)
for(road* p: v)
{
if(!setting.silentMode)
cout << "\tRoad " << p->inputId << " in segment " << p->inputSegmentId << " is not linked"<< endl;
std::cerr << "\tRoad " << p->inputSegmentId << " is not linked"<< endl;
std::cout << "\tRoad " << p->inputId << " in segment " << p->inputSegmentId << " is not linked"<< std::endl;
std::cerr << "\tRoad " << p->inputSegmentId << " is not linked"<< std::endl;
}


Expand Down
Loading

0 comments on commit 6df43e2

Please sign in to comment.