kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
Mesh.h
Go to the documentation of this file.
1 #ifndef _ROS_shape_msgs_Mesh_h
2 #define _ROS_shape_msgs_Mesh_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
9 #include "geometry_msgs/Point.h"
10 
11 namespace shape_msgs
12 {
13 
14  class Mesh : public ros::Msg
15  {
16  public:
20  uint8_t vertices_length;
23 
24  Mesh():
25  triangles_length(0), triangles(NULL),
26  vertices_length(0), vertices(NULL)
27  {
28  }
29 
30  virtual int serialize(unsigned char *outbuffer) const
31  {
32  int offset = 0;
33  *(outbuffer + offset++) = triangles_length;
34  *(outbuffer + offset++) = 0;
35  *(outbuffer + offset++) = 0;
36  *(outbuffer + offset++) = 0;
37  for( uint8_t i = 0; i < triangles_length; i++){
38  offset += this->triangles[i].serialize(outbuffer + offset);
39  }
40  *(outbuffer + offset++) = vertices_length;
41  *(outbuffer + offset++) = 0;
42  *(outbuffer + offset++) = 0;
43  *(outbuffer + offset++) = 0;
44  for( uint8_t i = 0; i < vertices_length; i++){
45  offset += this->vertices[i].serialize(outbuffer + offset);
46  }
47  return offset;
48  }
49 
50  virtual int deserialize(unsigned char *inbuffer)
51  {
52  int offset = 0;
53  uint8_t triangles_lengthT = *(inbuffer + offset++);
54  if(triangles_lengthT > triangles_length)
55  this->triangles = (shape_msgs::MeshTriangle*)realloc(this->triangles, triangles_lengthT * sizeof(shape_msgs::MeshTriangle));
56  offset += 3;
57  triangles_length = triangles_lengthT;
58  for( uint8_t i = 0; i < triangles_length; i++){
59  offset += this->st_triangles.deserialize(inbuffer + offset);
60  memcpy( &(this->triangles[i]), &(this->st_triangles), sizeof(shape_msgs::MeshTriangle));
61  }
62  uint8_t vertices_lengthT = *(inbuffer + offset++);
63  if(vertices_lengthT > vertices_length)
64  this->vertices = (geometry_msgs::Point*)realloc(this->vertices, vertices_lengthT * sizeof(geometry_msgs::Point));
65  offset += 3;
66  vertices_length = vertices_lengthT;
67  for( uint8_t i = 0; i < vertices_length; i++){
68  offset += this->st_vertices.deserialize(inbuffer + offset);
69  memcpy( &(this->vertices[i]), &(this->st_vertices), sizeof(geometry_msgs::Point));
70  }
71  return offset;
72  }
73 
74  const char * getType(){ return "shape_msgs/Mesh"; };
75  const char * getMD5(){ return "1ffdae9486cd3316a121c578b47a85cc"; };
76 
77  };
78 
79 }
80 #endif
geometry_msgs::Point st_vertices
Definition: Mesh.h:21
virtual int serialize(unsigned char *outbuffer) const
Definition: Mesh.h:30
shape_msgs::MeshTriangle * triangles
Definition: Mesh.h:19
geometry_msgs::Point * vertices
Definition: Mesh.h:22
const char * getType()
Definition: Mesh.h:74
Mesh()
Definition: Mesh.h:24
Definition: MeshTriangle.h:12
Definition: Point.h:12
virtual int deserialize(unsigned char *inbuffer)
Definition: MeshTriangle.h:35
virtual int deserialize(unsigned char *inbuffer)
Definition: Mesh.h:50
uint8_t triangles_length
Definition: Mesh.h:17
uint8_t vertices_length
Definition: Mesh.h:20
virtual int serialize(unsigned char *outbuffer) const
Definition: Point.h:26
Definition: Mesh.h:14
shape_msgs::MeshTriangle st_triangles
Definition: Mesh.h:18
const char * getMD5()
Definition: Mesh.h:75
virtual int serialize(unsigned char *outbuffer) const
Definition: MeshTriangle.h:22
virtual int deserialize(unsigned char *inbuffer)
Definition: Point.h:35
Definition: msg.h:43