CARLA
Loading...
Searching...
No Matches
CarlaRecorderWeather.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
8#include "CarlaRecorder.h"
10
11void CarlaRecorderWeather::Write(std::ostream &OutFile)
12{
13 WriteValue(OutFile, this->Cloudiness);
14 WriteValue(OutFile, this->Precipitation);
15 WriteValue(OutFile, this->PrecipitationDeposits);
16 WriteValue(OutFile, this->WindIntensity);
17 WriteValue(OutFile, this->SunAzimuthAngle);
18 WriteValue(OutFile, this->SunAltitudeAngle);
19 WriteValue(OutFile, this->FogDensity);
20 WriteValue(OutFile, this->FogDistance);
21 WriteValue(OutFile, this->FogFalloff);
22 WriteValue(OutFile, this->Wetness);
23 WriteValue(OutFile, this->ScatteringIntensity);
24 WriteValue(OutFile, this->MieScatteringScale);
25 WriteValue(OutFile, this->RayleighScatteringScale);
26 WriteValue(OutFile, this->DustStorm);
27}
28
29void CarlaRecorderWeather::Read(std::istream &InFile)
30{
31 ReadValue(InFile, this->Cloudiness);
32 ReadValue(InFile, this->Precipitation);
33 ReadValue(InFile, this->PrecipitationDeposits);
34 ReadValue(InFile, this->WindIntensity);
35 ReadValue(InFile, this->SunAzimuthAngle);
36 ReadValue(InFile, this->SunAltitudeAngle);
37 ReadValue(InFile, this->FogDensity);
38 ReadValue(InFile, this->FogDistance);
39 ReadValue(InFile, this->FogFalloff);
40 ReadValue(InFile, this->Wetness);
41 ReadValue(InFile, this->ScatteringIntensity);
42 ReadValue(InFile, this->MieScatteringScale);
44 ReadValue(InFile, this->DustStorm);
45}
46
47// ---------------------------------------------
48
50{
51 Weathers.clear();
52}
53
55{
56 Weathers.push_back(InObj);
57}
58
59void CarlaRecorderWeathers::Write(std::ostream &OutFile)
60{
61 if (Weathers.size() == 0)
62 {
63 return;
64 }
65
66 // write the packet id
67 WriteValue<char>(OutFile, static_cast<char>(CarlaRecorderPacketId::Weather));
68
69 // write the packet size
70 uint32_t Total = 2 + Weathers.size() * sizeof(CarlaRecorderWeather);
71 WriteValue<uint32_t>(OutFile, Total);
72
73 // write total records
74 Total = Weathers.size();
75 WriteValue<uint16_t>(OutFile, Total);
76
77 // write records
78 for (auto& Weather : Weathers)
79 {
80 Weather.Write(OutFile);
81 }
82}
83
84void CarlaRecorderWeathers::Read(std::istream &InFile)
85{
86 uint16_t Total = 0;
87 ReadValue<uint16_t>(InFile, Total);
88 for (uint16_t i = 0; (i < Total) && InFile; ++i)
89 {
91 Record.Read(InFile);
92 Add(Record);
93 }
94}
95
96const std::vector<CarlaRecorderWeather>& CarlaRecorderWeathers::GetWeathers() const
97{
98 return Weathers;
99}
100
102{
103 return Weathers.empty();
104}
void WriteValue(std::ostream &OutFile, const T &InObj)
void ReadValue(std::istream &InFile, T &OutObj)
std::vector< CarlaRecorderWeather > Weathers
void Read(std::istream &InFile)
const std::vector< CarlaRecorderWeather > & GetWeathers() const
void Write(std::ostream &OutFile)
void Add(const CarlaRecorderWeather &InObj)
void Write(std::ostream &OutFile)
void Read(std::istream &InFile)