3es  0.7
3espointcloudshape.h
1 //
2 // author: Kazys Stepanas
3 //
4 #ifndef _3ESPOINTS_H_
5 #define _3ESPOINTS_H_
6 
7 #include "3es-core.h"
8 
9 #include "3esshape.h"
10 #include "3esmeshset.h"
11 
12 namespace tes
13 {
23  class _3es_coreAPI PointCloudShape : public Shape
24  {
25  public:
31  PointCloudShape(const MeshResource *mesh, uint32_t id = 0, uint16_t category = 0, uint8_t pointSize = 1);
32 
34  ~PointCloudShape();
35 
39  inline PointCloudShape &setPointSize(uint8_t size) { _pointSize = size; return *this; }
42  inline uint8_t pointSize() const { return _pointSize; }
43 
57  template <typename I>
58  PointCloudShape &setIndices(I begin, uint32_t indexCount);
59 
62  inline const MeshResource *mesh() const { return _mesh; }
63 
67  virtual bool writeCreate(PacketWriter &stream) const override;
68 
76  virtual int writeData(PacketWriter &stream, unsigned &progressMarker) const override;
77 
80  virtual inline bool isComplex() const override { return true; }
81 
86  int enumerateResources(const Resource **resources, int capacity, int fetchOffset) const override;
87 
91  Shape *clone() const override;
92 
93  private:
94  void onClone(PointCloudShape *copy) const;
95 
96  uint32_t *allocateIndices(uint32_t count);
97  void freeIndices(const uint32_t *indices);
98 
99  const MeshResource *_mesh;
100  uint32_t *_indices;
101  uint32_t _indexCount;
102  uint8_t _pointSize;
103  };
104 
105 
106  inline PointCloudShape::PointCloudShape(const MeshResource *mesh, uint32_t id, uint16_t category, uint8_t pointSize)
107  : Shape(SIdPointCloud, id, category)
108  , _mesh(mesh)
109  , _indices(nullptr)
110  , _indexCount(0)
111  , _pointSize(pointSize)
112  {
113  }
114 
115 
117  {
118  freeIndices(_indices);
119  }
120 
121 
122  template <typename I>
123  PointCloudShape &PointCloudShape::setIndices(I iter, uint32_t indexCount)
124  {
125  freeIndices(_indices);
126  _indices = nullptr;
127  _indexCount = indexCount;
128  if (indexCount)
129  {
130  _indices = allocateIndices(indexCount);
131  uint32_t *ind = _indices;
132  for (uint32_t i = 0; i < indexCount; ++i, ++ind, ++iter)
133  {
134  *ind = *iter;
135  }
136  }
137 
138  return *this;
139  }
140 }
141 
142 #endif // _3ESPOINTS_H_
A base class for encapsulating a shape which is to be represented remotely.
Definition: 3esshape.h:39
virtual bool isComplex() const override
Defines this class as a complex shape.
Definition: 3espointcloudshape.h:80
const MeshResource * mesh() const
Get the mesh resource containing the point data to render.
Definition: 3espointcloudshape.h:62
Definition: 3esbounds.h:13
The Resource base class defines an interface for any resource used by Shape objects such as MeshSet...
Definition: 3esresource.h:34
Represents a mesh part or object.
Definition: 3esmeshresource.h:16
PointCloudShape & setIndices(I begin, uint32_t indexCount)
Sets the (optional) indices for this PointCloudShape Shape.
Definition: 3espointcloudshape.h:123
A Shape which renders a set of points as in a point cloud.
Definition: 3espointcloudshape.h:23
PointCloudShape(const MeshResource *mesh, uint32_t id=0, uint16_t category=0, uint8_t pointSize=1)
Construct a point cloud shape object.
Definition: 3espointcloudshape.h:106
uint8_t pointSize() const
Get the desired point render size (pixels).
Definition: 3espointcloudshape.h:42
A utility class for writing payload data to a PacketHeader.
Definition: 3espacketwriter.h:34
~PointCloudShape()
Destructor.
Definition: 3espointcloudshape.h:116
PointCloudShape & setPointSize(uint8_t size)
Set the desired point render size (pixels).
Definition: 3espointcloudshape.h:39