CARLA
Texture.h
Go to the documentation of this file.
1 // Copyright (c) 2021 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 #include "carla/MsgPack.h"
10 #include "carla/rpc/FloatColor.h"
12 
13 #include <vector>
14 
15 namespace carla {
16 namespace rpc {
17 
18  template<typename T>
19  class Texture {
20  public:
21 
22  Texture() = default;
23 
24  Texture(uint32_t width, uint32_t height)
25  : _width(width), _height(height) {
27  }
28 
29  uint32_t GetWidth() const {
30  return _width;
31  }
32 
33  uint32_t GetHeight() const {
34  return _height;
35  }
36 
37  void SetDimensions(uint32_t width, uint32_t height) {
38  _width = width;
39  _height = height;
41  }
42 
43  T& At (uint32_t x, uint32_t y) {
44  return _texture_data[y*_width + x];
45  }
46 
47  const T& At (uint32_t x, uint32_t y) const {
48  return _texture_data[y*_width + x];
49  }
50 
51  const T* GetDataPtr() const {
52  return _texture_data.data();
53  }
54 
55  private:
56 
57  uint32_t _width = 0;
58  uint32_t _height = 0;
59  std::vector<T> _texture_data;
60 
61  public:
62 
63  MSGPACK_DEFINE_ARRAY(_width, _height, _texture_data);
64  };
65 
68 
69 }
70 }
MSGPACK_DEFINE_ARRAY(_width, _height, _texture_data)
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
uint32_t _height
Definition: Texture.h:58
const T * GetDataPtr() const
Definition: Texture.h:51
std::vector< T > _texture_data
Definition: Texture.h:59
T & At(uint32_t x, uint32_t y)
Definition: Texture.h:43
const T & At(uint32_t x, uint32_t y) const
Definition: Texture.h:47
void SetDimensions(uint32_t width, uint32_t height)
Definition: Texture.h:37
uint32_t GetHeight() const
Definition: Texture.h:33
uint32_t _width
Definition: Texture.h:57
uint32_t GetWidth() const
Definition: Texture.h:29
Texture(uint32_t width, uint32_t height)
Definition: Texture.h:24