CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderBoundingBox.cpp
Go to the documentation of this file.
1
// Copyright (c) 2026 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
#include "
CarlaRecorderBoundingBox.h
"
8
#include "
CarlaRecorder.h
"
9
#include "
CarlaRecorderHelpers.h
"
10
11
void
CarlaRecorderBoundingBox::Write
(std::ostream &OutFile)
12
{
13
WriteFVector
(OutFile, this->
Origin
);
14
WriteFVector
(OutFile, this->
Extension
);
15
}
16
17
void
CarlaRecorderBoundingBox::Read
(std::istream &InFile)
18
{
19
ReadFVector
(InFile, this->
Origin
);
20
ReadFVector
(InFile, this->
Extension
);
21
}
22
23
void
CarlaRecorderActorBoundingBox::Write
(std::ostream &OutFile)
24
{
25
WriteValue<uint32_t>
(OutFile, this->
DatabaseId
);
26
BoundingBox
.
Write
(OutFile);
27
}
28
29
void
CarlaRecorderActorBoundingBox::Read
(std::istream &InFile)
30
{
31
ReadValue<uint32_t>
(InFile, this->
DatabaseId
);
32
BoundingBox
.
Read
(InFile);
33
}
34
35
36
// ---------------------------------------------
37
38
void
CarlaRecorderActorBoundingBoxes::Clear
(
void
)
39
{
40
Boxes
.clear();
41
}
42
43
void
CarlaRecorderActorBoundingBoxes::Add
(
const
CarlaRecorderActorBoundingBox
&InObj)
44
{
45
Boxes
.push_back(InObj);
46
}
47
48
void
CarlaRecorderActorBoundingBoxes::Write
(std::ostream &OutFile)
49
{
50
// write the packet id
51
WriteValue<char>
(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::BoundingBox
));
52
53
// write the packet size
54
uint32_t Total = 2 +
Boxes
.size() *
sizeof
(
CarlaRecorderActorBoundingBox
);
55
WriteValue<uint32_t>
(OutFile, Total);
56
57
// write total records
58
Total =
Boxes
.size();
59
WriteValue<uint16_t>
(OutFile, Total);
60
61
// write records
62
for
(
auto
& Box :
Boxes
)
63
{
64
Box.Write(OutFile);
65
}
66
}
67
68
void
CarlaRecorderActorTriggerVolumes::Clear
(
void
)
69
{
70
Boxes
.clear();
71
}
72
73
void
CarlaRecorderActorTriggerVolumes::Add
(
const
CarlaRecorderActorBoundingBox
&InObj)
74
{
75
Boxes
.push_back(InObj);
76
}
77
78
void
CarlaRecorderActorTriggerVolumes::Write
(std::ostream &OutFile)
79
{
80
if
(
Boxes
.size() == 0)
81
{
82
return
;
83
}
84
// write the packet id
85
WriteValue<char>
(OutFile,
static_cast<
char
>
(
CarlaRecorderPacketId::TriggerVolume
));
86
87
// write the packet size
88
uint32_t Total = 2 +
Boxes
.size() *
sizeof
(
CarlaRecorderActorBoundingBox
);
89
WriteValue<uint32_t>
(OutFile, Total);
90
91
// write total records
92
Total =
Boxes
.size();
93
WriteValue<uint16_t>
(OutFile, Total);
94
95
// write records
96
for
(
auto
& Box :
Boxes
)
97
{
98
Box.Write(OutFile);
99
}
100
}
CarlaRecorderBoundingBox.h
WriteFVector
void WriteFVector(std::ostream &OutFile, const FVector &InObj)
Definition
CarlaRecorderHelpers.cpp:42
ReadFVector
void ReadFVector(std::istream &InFile, FVector &OutObj)
Definition
CarlaRecorderHelpers.cpp:72
CarlaRecorderHelpers.h
WriteValue
void WriteValue(std::ostream &OutFile, const T &InObj)
Definition
CarlaRecorderHelpers.h:21
ReadValue
void ReadValue(std::istream &InFile, T &OutObj)
Definition
CarlaRecorderHelpers.h:60
CarlaRecorder.h
CarlaRecorderPacketId::TriggerVolume
@ TriggerVolume
Definition
CarlaRecorder.h:68
CarlaRecorderPacketId::BoundingBox
@ BoundingBox
Definition
CarlaRecorder.h:64
CarlaRecorderActorBoundingBoxes::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderBoundingBox.cpp:48
CarlaRecorderActorBoundingBoxes::Boxes
std::vector< CarlaRecorderActorBoundingBox > Boxes
Definition
CarlaRecorderBoundingBox.h:48
CarlaRecorderActorBoundingBoxes::Add
void Add(const CarlaRecorderActorBoundingBox &InObj)
Definition
CarlaRecorderBoundingBox.cpp:43
CarlaRecorderActorBoundingBoxes::Clear
void Clear(void)
Definition
CarlaRecorderBoundingBox.cpp:38
CarlaRecorderActorTriggerVolumes::Clear
void Clear(void)
Definition
CarlaRecorderBoundingBox.cpp:68
CarlaRecorderActorTriggerVolumes::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderBoundingBox.cpp:78
CarlaRecorderActorTriggerVolumes::Boxes
std::vector< CarlaRecorderActorBoundingBox > Boxes
Definition
CarlaRecorderBoundingBox.h:63
CarlaRecorderActorTriggerVolumes::Add
void Add(const CarlaRecorderActorBoundingBox &InObj)
Definition
CarlaRecorderBoundingBox.cpp:73
CarlaRecorderActorBoundingBox
Definition
CarlaRecorderBoundingBox.h:26
CarlaRecorderActorBoundingBox::BoundingBox
CarlaRecorderBoundingBox BoundingBox
Definition
CarlaRecorderBoundingBox.h:28
CarlaRecorderActorBoundingBox::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderBoundingBox.cpp:23
CarlaRecorderActorBoundingBox::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderBoundingBox.cpp:29
CarlaRecorderActorBoundingBox::DatabaseId
uint32_t DatabaseId
Definition
CarlaRecorderBoundingBox.h:27
CarlaRecorderBoundingBox::Write
void Write(std::ostream &OutFile)
Definition
CarlaRecorderBoundingBox.cpp:11
CarlaRecorderBoundingBox::Extension
FVector Extension
Definition
CarlaRecorderBoundingBox.h:16
CarlaRecorderBoundingBox::Origin
FVector Origin
Definition
CarlaRecorderBoundingBox.h:15
CarlaRecorderBoundingBox::Read
void Read(std::istream &InFile)
Definition
CarlaRecorderBoundingBox.cpp:17
Generated by
1.18.0