YARP
Yet Another Robot Platform
Mesh.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 // This is an automatically generated file.
10 
11 // Generated from the following "shape_msgs/Mesh" msg definition:
12 // # Definition of a mesh
13 //
14 // # list of triangles; the index values refer to positions in vertices[]
15 // MeshTriangle[] triangles
16 //
17 // # the actual vertices that make up the mesh
18 // geometry_msgs/Point[] vertices
19 // Instances of this class can be read and written with YARP ports,
20 // using a ROS-compatible format.
21 
22 #ifndef YARP_ROSMSG_shape_msgs_Mesh_h
23 #define YARP_ROSMSG_shape_msgs_Mesh_h
24 
25 #include <yarp/os/Wire.h>
26 #include <yarp/os/Type.h>
27 #include <yarp/os/idl/WireTypes.h>
28 #include <string>
29 #include <vector>
32 
33 namespace yarp {
34 namespace rosmsg {
35 namespace shape_msgs {
36 
38 {
39 public:
40  std::vector<yarp::rosmsg::shape_msgs::MeshTriangle> triangles;
41  std::vector<yarp::rosmsg::geometry_msgs::Point> vertices;
42 
43  Mesh() :
44  triangles(),
45  vertices()
46  {
47  }
48 
49  void clear()
50  {
51  // *** triangles ***
52  triangles.clear();
53 
54  // *** vertices ***
55  vertices.clear();
56  }
57 
58  bool readBare(yarp::os::ConnectionReader& connection) override
59  {
60  // *** triangles ***
61  int len = connection.expectInt32();
62  triangles.resize(len);
63  for (int i=0; i<len; i++) {
64  if (!triangles[i].read(connection)) {
65  return false;
66  }
67  }
68 
69  // *** vertices ***
70  len = connection.expectInt32();
71  vertices.resize(len);
72  for (int i=0; i<len; i++) {
73  if (!vertices[i].read(connection)) {
74  return false;
75  }
76  }
77 
78  return !connection.isError();
79  }
80 
81  bool readBottle(yarp::os::ConnectionReader& connection) override
82  {
83  connection.convertTextMode();
84  yarp::os::idl::WireReader reader(connection);
85  if (!reader.readListHeader(2)) {
86  return false;
87  }
88 
89  // *** triangles ***
90  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
91  return false;
92  }
93  int len = connection.expectInt32();
94  triangles.resize(len);
95  for (int i=0; i<len; i++) {
96  if (!triangles[i].read(connection)) {
97  return false;
98  }
99  }
100 
101  // *** vertices ***
102  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
103  return false;
104  }
105  len = connection.expectInt32();
106  vertices.resize(len);
107  for (int i=0; i<len; i++) {
108  if (!vertices[i].read(connection)) {
109  return false;
110  }
111  }
112 
113  return !connection.isError();
114  }
115 
117  bool read(yarp::os::ConnectionReader& connection) override
118  {
119  return (connection.isBareMode() ? readBare(connection)
120  : readBottle(connection));
121  }
122 
123  bool writeBare(yarp::os::ConnectionWriter& connection) const override
124  {
125  // *** triangles ***
126  connection.appendInt32(triangles.size());
127  for (size_t i=0; i<triangles.size(); i++) {
128  if (!triangles[i].write(connection)) {
129  return false;
130  }
131  }
132 
133  // *** vertices ***
134  connection.appendInt32(vertices.size());
135  for (size_t i=0; i<vertices.size(); i++) {
136  if (!vertices[i].write(connection)) {
137  return false;
138  }
139  }
140 
141  return !connection.isError();
142  }
143 
144  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
145  {
146  connection.appendInt32(BOTTLE_TAG_LIST);
147  connection.appendInt32(2);
148 
149  // *** triangles ***
150  connection.appendInt32(BOTTLE_TAG_LIST);
151  connection.appendInt32(triangles.size());
152  for (size_t i=0; i<triangles.size(); i++) {
153  if (!triangles[i].write(connection)) {
154  return false;
155  }
156  }
157 
158  // *** vertices ***
159  connection.appendInt32(BOTTLE_TAG_LIST);
160  connection.appendInt32(vertices.size());
161  for (size_t i=0; i<vertices.size(); i++) {
162  if (!vertices[i].write(connection)) {
163  return false;
164  }
165  }
166 
167  connection.convertTextMode();
168  return !connection.isError();
169  }
170 
172  bool write(yarp::os::ConnectionWriter& connection) const override
173  {
174  return (connection.isBareMode() ? writeBare(connection)
175  : writeBottle(connection));
176  }
177 
178  // This class will serialize ROS style or YARP style depending on protocol.
179  // If you need to force a serialization style, use one of these classes:
182 
183  // The name for this message, ROS will need this
184  static constexpr const char* typeName = "shape_msgs/Mesh";
185 
186  // The checksum for this message, ROS will need this
187  static constexpr const char* typeChecksum = "1ffdae9486cd3316a121c578b47a85cc";
188 
189  // The source text for this message, ROS will need this
190  static constexpr const char* typeText = "\
191 # Definition of a mesh\n\
192 \n\
193 # list of triangles; the index values refer to positions in vertices[]\n\
194 MeshTriangle[] triangles\n\
195 \n\
196 # the actual vertices that make up the mesh\n\
197 geometry_msgs/Point[] vertices\n\
198 \n\
199 ================================================================================\n\
200 MSG: shape_msgs/MeshTriangle\n\
201 # Definition of a triangle's vertices\n\
202 uint32[3] vertex_indices\n\
203 \n\
204 ================================================================================\n\
205 MSG: geometry_msgs/Point\n\
206 # This contains the position of a point in free space\n\
207 float64 x\n\
208 float64 y\n\
209 float64 z\n\
210 ";
211 
212  yarp::os::Type getType() const override
213  {
215  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
216  typ.addProperty("message_definition", yarp::os::Value(typeText));
217  return typ;
218  }
219 };
220 
221 } // namespace shape_msgs
222 } // namespace rosmsg
223 } // namespace yarp
224 
225 #endif // YARP_ROSMSG_shape_msgs_Mesh_h
WireTypes.h
yarp::rosmsg::shape_msgs::Mesh
Definition: Mesh.h:38
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::shape_msgs::Mesh::typeChecksum
static constexpr const char * typeChecksum
Definition: Mesh.h:187
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
Point.h
yarp::rosmsg::shape_msgs::Mesh::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::shape_msgs::Mesh > rosStyle
Definition: Mesh.h:180
yarp::rosmsg::shape_msgs::Mesh::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Mesh.h:123
yarp::rosmsg::shape_msgs::Mesh::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Mesh.h:172
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::shape_msgs::Mesh::typeText
static constexpr const char * typeText
Definition: Mesh.h:190
yarp::rosmsg::shape_msgs::Mesh::Mesh
Mesh()
Definition: Mesh.h:43
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::os::ConnectionReader::convertTextMode
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
yarp::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::shape_msgs::Mesh::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::shape_msgs::Mesh > bottleStyle
Definition: Mesh.h:181
MeshTriangle.h
yarp::os::ConnectionWriter::convertTextMode
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
yarp::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
yarp::os::idl::WireReader
IDL-friendly connection reader.
Definition: WireReader.h:33
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::shape_msgs::Mesh::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Mesh.h:81
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::shape_msgs::Mesh::typeName
static constexpr const char * typeName
Definition: Mesh.h:184
yarp::rosmsg::shape_msgs::Mesh::vertices
std::vector< yarp::rosmsg::geometry_msgs::Point > vertices
Definition: Mesh.h:41
yarp::rosmsg::shape_msgs::Mesh::triangles
std::vector< yarp::rosmsg::shape_msgs::MeshTriangle > triangles
Definition: Mesh.h:40
yarp::rosmsg::shape_msgs::Mesh::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Mesh.h:117
yarp::rosmsg::shape_msgs::Mesh::clear
void clear()
Definition: Mesh.h:49
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::shape_msgs::Mesh::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Mesh.h:144
shape_msgs
Definition: Mesh.h:22
yarp::os::idl::WireReader::readListHeader
bool readListHeader()
Definition: WireReader.cpp:470
yarp::rosmsg::shape_msgs::Mesh::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Mesh.h:58
yarp::rosmsg::shape_msgs::Mesh::getType
yarp::os::Type getType() const override
Definition: Mesh.h:212
yarp::os::idl::WirePortable::write
virtual bool write(const yarp::os::idl::WireWriter &writer) const
Definition: WirePortable.cpp:20