CARLA
CarlaRecorderBoundingBox.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020 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 
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 
39 {
40  Boxes.clear();
41 }
42 
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 
69 {
70  Boxes.clear();
71 }
72 
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 }
void ReadFVector(std::istream &InFile, FVector &OutObj)
void Read(std::istream &InFile)
bg::model::box< Point3D > Box
Definition: InMemoryMap.h:52
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Write(std::ostream &OutFile)
void WriteFVector(std::ostream &OutFile, const FVector &InObj)
void Add(const CarlaRecorderActorBoundingBox &InObj)
void Write(std::ostream &OutFile)