MIRA
PointCloudFormat.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Redistribution and modification of this code is strictly prohibited.
9  *
10  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
11  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
12  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
13  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14  *
15  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
16  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
18  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
19  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
20  */
21 
30 #ifndef _MIRA_POINTCLOUDFORMAT_H_
31 #define _MIRA_POINTCLOUDFORMAT_H_
32 
33 #include <vector>
34 #include <string>
35 #include <platform/Types.h>
36 
37 #include <maps/MapsExports.h>
38 
39 namespace mira { namespace maps {
40 
42 
43 class PCFormat;
44 
46 {
47 public:
48 
49  enum Type {
50  INVALID = 0,
51  // Use same type ids as PCL (point cloud library) to be compatible
52  INT32 = 5,
53  UINT32 = 6,
54  FLOAT32 = 7,
55  OTHER = 0xFFFFFFFF
56  };
57 
58 public:
59 
60  PCDataField() : type(INVALID), count(0), offset(0), size(0) {}
61  PCDataField(const std::string& iSemantic, Type iType, std::size_t iCount):
62  semantic(iSemantic), type(iType), count(iCount) {}
63 
64 public:
65 
66  template <typename Reflector>
67  void reflect(Reflector& r)
68  {
69  r.member("Semantic", semantic, "The name/semantic of this field (e.g. 'x' for x-coordinate)");
70  r.member("Type", type, "The data type of the field");
71  r.member("Count", count, "The number of repetitions of the above data type");
72  r.member("Size", size, "The total size of this field in bytes");
73  // the offset will be set by PCFormat
74  }
75 
76 public:
77 
79  bool isValid() const { return type != INVALID; }
80 
81 public:
82  std::string semantic;
85 
88 };
89 
90 template <typename T>
92 
93 template <>
95 
96 template <>
98 
99 template <>
101 
103 
105 {
106 public:
107 
109  size(0) {}
110 
111 public:
112 
113  template <typename Reflector>
114  void reflect(Reflector& r)
115  {
116  r.member("Fields", fields, "The data fields");
117  if(!Reflector::isReadOnly::value)
118  refreshFields();
119  }
120 
121 public:
122 
123  void addField(const std::string& semantic, PCDataField::Type type, std::size_t count);
124  void addOtherField(const std::string& semantic, std::size_t size);
125 
126 public:
127 
128  static const PCDataField nullfield;
129  const PCDataField& getField(const std::string& semantic, PCDataField::Type type, uint32 count=1) const;
130 
131  bool hasField(const std::string& semantic, PCDataField::Type type, uint32 count=1) const;
132 
133 public:
134 
135  std::vector<PCDataField> fields;
137 
138 private:
139 
140  void refreshFields();
141 
142 };
143 
145 
146 template <typename PointType>
148 {
150  // If you get a compiler error here you have neither defined
151  // an intrusive "static PointCloudFormat::Format pointCloudFormat()" nor
152  // specialized the template function "mira::pointCloudFormat()" for
153  // the given point type.
155  return PointType::pointCloudFormat(); // call intrusive static method to get format
156 }
157 
159 
160 }} // namespace
161 
162 #endif /* _MIRA_POINTCLOUDFORMAT_H_ */
Type
Definition: PointCloudFormat.h:49
Definition: PointCloudFormat.h:91
Definition: PointCloudFormat.h:50
bool isValid() const
Returns true, if this field is valid.
Definition: PointCloudFormat.h:79
uint32 offset
Definition: PointCloudFormat.h:86
Maps export macro declaration.
Type type
Definition: PointCloudFormat.h:83
uint32_t uint32
std::vector< PCDataField > fields
Definition: PointCloudFormat.h:135
static const PCDataField::Type type
Definition: PointCloudFormat.h:91
std::string semantic
Definition: PointCloudFormat.h:82
static const PCDataField nullfield
Definition: PointCloudFormat.h:128
PropertyHint type(const std::string &t)
void reflect(Reflector &r)
Definition: PointCloudFormat.h:67
PCFormat pointCloudFormat()
Definition: PointCloudFormat.h:147
uint32 count
Definition: PointCloudFormat.h:84
void reflect(Reflector &r)
Definition: PointCloudFormat.h:114
Definition: PointCloudFormat.h:55
PCDataField(const std::string &iSemantic, Type iType, std::size_t iCount)
Definition: PointCloudFormat.h:61
Definition: PointCloudFormat.h:45
int32_t int32
Definition: PointCloudFormat.h:53
Definition: PointCloudFormat.h:52
Definition: PointCloudFormat.h:104
PCFormat()
Definition: PointCloudFormat.h:108
#define MIRA_MAPPING_MAPS_EXPORT
Definition: MapsExports.h:44
PCDataField()
Definition: PointCloudFormat.h:60
uint32 size
Definition: PointCloudFormat.h:136
Definition: PointCloudFormat.h:54
uint32 size
Definition: PointCloudFormat.h:87