CARLA
载入中...
搜索中...
未找到
Unreal
CarlaUE4
Plugins
Carla
Source
Carla
MapGen
RoadSegmentDescription.h
浏览该文件的文档.
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
// 引入图相关的类型定义头文件,可能包含了图中半边等相关结构体等的定义
10
#include "
GraphTypes.h
"
11
// 引入不可复制的工具类相关头文件,用于限制类对象不能被拷贝
12
#include "
Util/NonCopyable.h
"
13
#include <vector>
14
15
namespace
MapGen
{
16
17
// RoadSegmentDescription类用于描述道路段相关信息,继承自NonCopyable,意味着该类对象不能被复制
18
class
RoadSegmentDescription
:
private
NonCopyable
19
{
20
public
:
21
// 将一个GraphHalfEdge类型的边添加到道路段描述中
22
void
Add
(
const
GraphHalfEdge
&Edge) {
23
// 如果角度指针Angle目前为空(即还未设置角度信息)
24
if
(Angle ==
nullptr
) {
25
// 使用MakeUnique创建一个指向float类型的智能指针,其值为传入边的角度值,用于记录该道路段的角度信息
26
Angle = MakeUnique<float>(Edge.Angle);
27
}
else
if
(*Angle!= Edge.Angle) {
/// @todo Use a scale.
28
// 如果当前已记录的角度与传入边的角度不一致,将角度指针置为nullptr,表示该道路段角度不统一(不再是直线等情况)
29
Angle =
nullptr
;
30
}
31
// 将传入边的指针添加到向量_vect中,用于存储组成该道路段的边的信息
32
_vect
.emplace_back(&Edge);
33
}
34
35
// 重载了下标运算符,用于通过索引获取存储在_vect中的GraphHalfEdge对象的引用,方便访问道路段中的边信息
36
const
GraphHalfEdge
&
operator[]
(
size_t
i)
const
{
37
return
*
_vect
[i];
38
}
39
40
// 返回道路段中边的数量,即存储在_vect中的元素个数,反映了该道路段由多少个半边组成
41
size_t
Size
()
const
{
42
return
_vect
.size();
43
}
44
45
// 判断该道路段是否是直线(通过角度是否有效来判断,即Angle指针是否非空)
46
bool
IsStraight
()
const
{
47
return
Angle.IsValid();
48
}
49
50
// 如果道路段是直线,返回指向其角度值的指针,否则返回nullptr,表示该道路段不是直线,没有统一的角度
51
/// @return nullptr if the road segment is not straight.
52
const
float
*
GetAngle
()
const
{
53
return
Angle.Get();
54
}
55
56
private
:
57
// 智能指针,用于指向一个float类型的角度值,如果该道路段是直线,则指向其角度值,否则为nullptr
58
TUniquePtr<float> Angle =
nullptr
;
59
60
// 向量,用于存储指向GraphHalfEdge类型的指针,这些指针指向组成该道路段的各个半边
61
std::vector<const GraphHalfEdge *>
_vect
;
62
};
63
}
// namespace MapGen
GraphTypes.h
NonCopyable.h
GraphHalfEdge
MapGen::RoadSegmentDescription
Definition
RoadSegmentDescription.h:19
MapGen::RoadSegmentDescription::_vect
std::vector< const GraphHalfEdge * > _vect
Definition
RoadSegmentDescription.h:61
MapGen::RoadSegmentDescription::Add
void Add(const GraphHalfEdge &Edge)
Definition
RoadSegmentDescription.h:22
MapGen::RoadSegmentDescription::operator[]
const GraphHalfEdge & operator[](size_t i) const
Definition
RoadSegmentDescription.h:36
MapGen::RoadSegmentDescription::Size
size_t Size() const
Definition
RoadSegmentDescription.h:41
MapGen::RoadSegmentDescription::IsStraight
bool IsStraight() const
Definition
RoadSegmentDescription.h:46
MapGen::RoadSegmentDescription::GetAngle
const float * GetAngle() const
Definition
RoadSegmentDescription.h:52
NonCopyable
Definition
Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Util/NonCopyable.h:3
MapGen
Definition
CityAreaDescription.h:14
制作者
1.10.0