12 #include <type_traits> 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>());
109 Segments.back()->Add(edge);
115 Segments.back()->Add(*edge);
153 auto it = faceList.begin();
155 for (; it != faceList.end(); ++it) {
156 CityAreas.emplace_back(MakeUnique<CityAreaDescription>(*it));
static HalfEdge & GetHalfEdge(Face &face)
static float GetAngle(const HalfEdge &halfEdge)
Return the angle [-pi, pi] of the half-edge.
size_t CountNodes() const
Simple doubly-connected edge list structure.
ListView< NodeIterator > GetNodes()
bool insert(Graph::HalfEdge &edge)
Insert both half-edges only if they haven't been visited yet.
static Node & GetSource(HalfEdge &halfEdge)
void Add(Graph::HalfEdge &edge)
static HalfEdge & GetPair(HalfEdge &halfEdge)
static float getRotation(float angle0, float angle1)
static int getQuadrant(float angle)
RoadSegmentBuilder(const Graph &graph)
std::vector< const Graph::HalfEdge * > _initial
DoublyConnectedEdgeList Graph
static HalfEdge & GetLeavingHalfEdge(Node &node)
std::vector< TUniquePtr< RoadSegmentDescription > > Segments
void Add(const GraphNode &Node)
double min(double v1, double v2)
size_t CountFaces() const
static HalfEdge & GetNextInFace(HalfEdge &halfEdge)
size_t CountHalfEdges() const
static void fixGraphData(Graph &graph)
static HalfEdge & GetNextInNode(HalfEdge &halfEdge)
ListView< FaceIterator > GetFaces()
std::unordered_set< const Graph::HalfEdge * > _visitedEdges
GraphParser(DoublyConnectedEdgeList &Dcel)