CARLA
RoadSegmentDescription.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #include "GraphTypes.h"
10 #include "Util/NonCopyable.h"
11 
12 #include <vector>
13 
14 namespace MapGen {
15 
17  {
18  public:
19 
20  void Add(const GraphHalfEdge &Edge) {
21  if (Angle == nullptr) {
22  Angle = MakeUnique<float>(Edge.Angle);
23  } else if (*Angle != Edge.Angle) { /// @todo Use a scale.
24  Angle = nullptr;
25  }
26  _vect.emplace_back(&Edge);
27  }
28 
29  const GraphHalfEdge &operator[](size_t i) const {
30  return *_vect[i];
31  }
32 
33  size_t Size() const {
34  return _vect.size();
35  }
36 
37  bool IsStraight() const {
38  return Angle.IsValid();
39  }
40 
41  /// @return nullptr if the road segment is not straight.
42  const float *GetAngle() const {
43  return Angle.Get();
44  }
45 
46  private:
47 
48  TUniquePtr<float> Angle = nullptr;
49 
50  std::vector<const GraphHalfEdge *> _vect;
51  };
52 
53 } // namespace MapGen
std::vector< const GraphHalfEdge * > _vect
void Add(const GraphHalfEdge &Edge)
const GraphHalfEdge & operator[](size_t i) const