CARLA
CarlaRecorderPosition.cpp
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 #include "CarlaRecorder.h"
9 #include "CarlaRecorderHelpers.h"
10 
11 void CarlaRecorderPosition::Write(std::ofstream &OutFile)
12 {
13  // database id
14  WriteValue<uint32_t>(OutFile, this->DatabaseId);
15  // transform
16  WriteFVector(OutFile, this->Location);
17  WriteFVector(OutFile, this->Rotation);
18 }
19 void CarlaRecorderPosition::Read(std::ifstream &InFile)
20 {
21  // database id
22  ReadValue<uint32_t>(InFile, this->DatabaseId);
23  // transform
24  ReadFVector(InFile, this->Location);
25  ReadFVector(InFile, this->Rotation);
26 }
27 
28 // ---------------------------------------------
29 
31 {
32  Positions.clear();
33 }
34 
36 {
37  Positions.push_back(Position);
38 }
39 
40 void CarlaRecorderPositions::Write(std::ofstream &OutFile)
41 {
42  // write the packet id
43  WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::Position));
44 
45  // write the packet size
46  uint32_t Total = 2 + Positions.size() * sizeof(CarlaRecorderPosition);
47  WriteValue<uint32_t>(OutFile, Total);
48 
49  // write total records
50  Total = Positions.size();
51  WriteValue<uint16_t>(OutFile, Total);
52 
53  // write records
54  if (Total > 0)
55  {
56  OutFile.write(reinterpret_cast<const char *>(Positions.data()),
57  Positions.size() * sizeof(CarlaRecorderPosition));
58  }
59 }
void Add(const CarlaRecorderPosition &InObj)
void Write(std::ofstream &OutFile)
void Read(std::ifstream &InFile)
void Write(std::ofstream &OutFile)
void WriteFVector(std::ofstream &OutFile, const FVector &InObj)
void ReadFVector(std::ifstream &InFile, FVector &OutObj)