13#include <unordered_set>
17 using Graph = DoublyConnectedEdgeList;
24 return static_cast<int>(std::round(angle/HALF_PI));
30 const int max =
getQuadrant(std::max(angle0, angle1));
31 return HALF_PI * std::min(
min,
min * max);
35 static float getRotation(
float angle0,
float angle1,
float angle2) {
43 return -1.0 * HALF_PI;
47 UE_LOG(LogCarla, Error, TEXT(
"Wrong quadrants"));
55 for (
auto &node : graph.
GetNodes()) {
56 std::vector<float> angles;
60 auto *edge = &firstEdge;
63 angles.emplace_back(edge->Angle);
65 }
while (edge != &firstEdge);
66 check(!angles.empty());
67 node.EdgeCount = angles.size();
68 node.bIsIntersection =
true;
69 switch (node.EdgeCount) {
71 node.Rotation =
getRotation(angles[0u], angles[1u]);
75 node.Rotation =
getRotation(angles[0u], angles[1u], angles[2u]);
84 node.Rots.swap(angles);
95 std::vector<TUniquePtr<RoadSegmentDescription>>
Segments;
103 Segments.emplace_back(MakeUnique<RoadSegmentDescription>());
153 auto it = faceList.begin();
155 for (; it != faceList.end(); ++it) {
156 CityAreas.emplace_back(MakeUnique<CityAreaDescription>(*it));
double min(double v1, double v2)
void Add(const GraphNode &Node)
Simple doubly-connected edge list structure.
ListView< FaceIterator > GetFaces()
static float GetAngle(const HalfEdge &halfEdge)
Return the angle [-pi, pi] of the half-edge.
ListView< NodeIterator > GetNodes()
static HalfEdge & GetHalfEdge(Face &face)
static HalfEdge & GetLeavingHalfEdge(Node &node)
static HalfEdge & GetPair(HalfEdge &halfEdge)
static Node & GetSource(HalfEdge &halfEdge)
size_t CountNodes() const
static HalfEdge & GetNextInNode(HalfEdge &halfEdge)
static HalfEdge & GetNextInFace(HalfEdge &halfEdge)
size_t CountHalfEdges() const
size_t CountFaces() const
RoadSegmentList RoadSegments
GraphParser(DoublyConnectedEdgeList &Dcel)
RoadSegmentBuilder(const Graph &graph)
std::unordered_set< const Graph::HalfEdge * > _visitedEdges
void Add(Graph::HalfEdge &edge)
std::vector< const Graph::HalfEdge * > _initial
std::vector< TUniquePtr< RoadSegmentDescription > > Segments
bool insert(Graph::HalfEdge &edge)
Insert both half-edges only if they haven't been visited yet.
static int getQuadrant(float angle)
static void fixGraphData(Graph &graph)
DoublyConnectedEdgeList Graph
static float getRotation(float angle0, float angle1)