3es  0.7
tes::PointCloud Class Reference

A MeshResource which defines a point cloud by its contained vertices. More...

#include <3espointcloud.h>

Inheritance diagram for tes::PointCloud:
tes::MeshResource tes::Resource

Public Member Functions

 PointCloud (uint32_t id)
 Create a PointCloud resource with the given ID. More...
 
 ~PointCloud ()
 Destructor.
 
uint32_t id () const override
 The resource ID. More...
 
PointCloudclone () const override
 Clone the cloud resource. More...
 
Matrix4f transform () const override
 Always the identity matrix. More...
 
uint32_t tint () const override
 Always returns white. More...
 
uint8_t drawType (int stream=0) const override
 Always returns DtPoints. More...
 
void reserve (unsigned size)
 Reserve sufficient vertex, normal and colour data for size points. More...
 
void resize (unsigned count)
 Resize the point cloud to contain count vertices, normals and colours. More...
 
void squeeze ()
 Reduce allocated memory to exactly match the number of points currently in the cloud.
 
unsigned capacity () const
 Return the number of points allocated memory currently supports. More...
 
unsigned vertexCount (int stream=0) const override
 Returns the number of vertices in the mesh. More...
 
const float * vertices (unsigned &stride, int stream=0) const override
 Returns a pointer to the vertex stream. More...
 
const Vector3fvertices () const
 Access vertices as a Vector3f array. More...
 
unsigned indexCount (int stream=0) const override
 Not supported. More...
 
const uint8_t * indices (unsigned &stride, unsigned &width, int stream=0) const override
 Not supported. More...
 
const float * normals (unsigned &stride, int stream=0) const override
 Returns a pointer to the normal stream. More...
 
const Vector3fnormals () const
 Access normals as a Vector3f array. More...
 
const uint32_t * colours (unsigned &stride, int stream=0) const override
 Returns a pointer to the colour stream. More...
 
const Colourcolours () const
 Access colours as a Colour array. More...
 
const float * uvs (unsigned &, int) const override
 Not supported. More...
 
void addPoint (const Vector3f &point)
 Add a single point to the cloud. More...
 
void addPoint (const Vector3f &point, const Vector3f &normal)
 Add a single point to the cloud. More...
 
void addPoint (const Vector3f &point, const Vector3f &normal, const Colour &colour)
 Add a single point to the cloud. More...
 
void addPoints (const Vector3f *points, unsigned count)
 Add a set of points to the cloud. More...
 
void addPoints (const Vector3f *points, const Vector3f *normals, unsigned count)
 Add a set of points to the cloud. More...
 
void addPoints (const Vector3f *points, const Vector3f *normals, const Colour *colours, unsigned count)
 Add a set of points to the cloud. More...
 
void setPoint (unsigned index, const Vector3f &point)
 Replace an existing point. More...
 
void setPoint (unsigned index, const Vector3f &point, const Vector3f &normal)
 Replace an existing point. More...
 
void setPoint (unsigned index, const Vector3f &point, const Vector3f &normal, const Colour &colour)
 Replace an existing point. More...
 
void setNormal (unsigned index, const Vector3f &normal)
 Replace an existing point normal. More...
 
void setColour (unsigned index, const Colour &colour)
 Replace an existing point colour. More...
 
void setPoints (unsigned index, const Vector3f *points, unsigned count)
 Replace a set of existing points. More...
 
void setPoints (unsigned index, const Vector3f *points, const Vector3f *normals, unsigned count)
 Replace a set of existing points. More...
 
void setPoints (unsigned index, const Vector3f *points, const Vector3f *normals, const Colour *colours, unsigned count)
 Replace a set of existing points. More...
 
- Public Member Functions inherited from tes::MeshResource
virtual ~MeshResource ()
 Virtual destructor.
 
uint16_t typeId () const override
 Returns MtMesh.
 
int create (PacketWriter &packet) const override
 Populate a mesh creation packet. More...
 
int destroy (PacketWriter &packet) const override
 Populate a mesh destroy packet. More...
 
int transfer (PacketWriter &packet, int byteLimit, TransferProgress &progress) const override
 Populate the next mesh data packet. More...
 
*tes::PacketWriter packet ()
 Compose a mesh index component message in packet. More...
 
while (offset< mesh->indexCount()) *
 
- Public Member Functions inherited from tes::Resource
virtual ~Resource ()
 Virtual destructor (empty).
 
uint64_t uniqueKey () const
 Returns a unique key for this resource, based on the typeId() and id().
 

Protected Member Functions

 PointCloud (const PointCloud &other)
 A shallow copy constructor, supporting copy on write semantics. More...
 
- Protected Member Functions inherited from tes::MeshResource
virtual void nextPhase (TransferProgress &progress) const
 

Additional Inherited Members

- Static Public Member Functions inherited from tes::MeshResource
static int estimateTransferCount (size_t elementSize, unsigned byteLimit, int overhead=0)
 Estimate the number of elements which can be transferred at the given byteLimit. More...
 
*</code > **param packet Packet to write to *param meshId The mesh to which the data belong *param offset An index count offset to start writing from See remarks *param byteLimit A hard limit on the number of bytes to write *param dataSource Base pointer for the index data *param dataStride Number of bytes between indices *param indexByteWidth The byte size of a single index Generally equal to p dataStride *param componentCount The total number of indices *return The number of indices written *static unsigned writeIndices (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, unsigned indexByteWidth, uint32_t componentCount)
 
*</code > **param packet Packet to write to *param meshId The mesh to which the data belong *param offset An vertex count offset to start writing from See remarks *param byteLimit A hard limit on the number of bytes to write *param dataSource Base pointer for the vertex data *param dataStride Number of bytes between indices *param componentCount The total number of indices *return The number of indices written *static unsigned writeVectors3 (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, uint32_t componentCount)
 
static unsigned writeVectors2 (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, uint32_t componentCount)
 Compose a mesh float vector 2 component message in packet. More...
 
static unsigned writeColours (PacketWriter &packet, uint32_t meshId, uint32_t offset, unsigned byteLimit, const uint8_t *dataSource, unsigned dataStride, uint32_t componentCount)
 Compose a mesh component message for writing colour data in packet. More...
 
- Public Attributes inherited from tes::MeshResource
*const tes::MeshResourcemesh =
 
*uint32_t offset = 0
 
*unsigned dataStride
 
*unsigned indexByteWidth
 
*const uint8_t * indicesPtr = reinterpret_cast<const uint8_t *>(indices(dataStride, indexByteWidth))
 
offset
 Compose a mesh float vector 3 component message in packet. More...
 

Detailed Description

A MeshResource which defines a point cloud by its contained vertices.

The PointCloud supports a set of vertices, normals and colours only. Indices, UVs are not supported.

Constructor & Destructor Documentation

◆ PointCloud() [1/2]

tes::PointCloud::PointCloud ( const PointCloud other)
protected

A shallow copy constructor, supporting copy on write semantics.

Parameters
otherThe cloud to copy.

◆ PointCloud() [2/2]

tes::PointCloud::PointCloud ( uint32_t  id)

Create a PointCloud resource with the given ID.

Parameters
idA user assigned, unique ID for the point cloud resource.

Member Function Documentation

◆ addPoint() [1/3]

void tes::PointCloud::addPoint ( const Vector3f point)
inline

Add a single point to the cloud.

The normal is set to zero and the colour to white.

Parameters
pointThe point to add.

◆ addPoint() [2/3]

void tes::PointCloud::addPoint ( const Vector3f point,
const Vector3f normal 
)
inline

Add a single point to the cloud.

The colour is set to white.

Parameters
pointThe point to add.
normalThe point normal.

◆ addPoint() [3/3]

void tes::PointCloud::addPoint ( const Vector3f point,
const Vector3f normal,
const Colour colour 
)
inline

Add a single point to the cloud.

Parameters
pointThe point to add.
normalThe point normal.
colourThe point colour.

◆ addPoints() [1/3]

void tes::PointCloud::addPoints ( const Vector3f points,
unsigned  count 
)

Add a set of points to the cloud.

The normals are set to zero and the colours to white.

Parameters
pointsThe points to add.
countNumber of points in points.

◆ addPoints() [2/3]

void tes::PointCloud::addPoints ( const Vector3f points,
const Vector3f normals,
unsigned  count 
)

Add a set of points to the cloud.

The colours are set to white.

Parameters
pointsThe points to add.
normalsThe point normals.
countNumber of points in points and normals.

◆ addPoints() [3/3]

void tes::PointCloud::addPoints ( const Vector3f points,
const Vector3f normals,
const Colour colours,
unsigned  count 
)

Add a set of points to the cloud.

Parameters
pointsThe points to add.
normalsThe point normals.
coloursThe point colours.
countNumber of points in points, normals and colours.

◆ capacity()

unsigned tes::PointCloud::capacity ( ) const

Return the number of points allocated memory currently supports.

Returns
The number of points supported by the current memory allocation.

◆ clone()

PointCloud* tes::PointCloud::clone ( ) const
overridevirtual

Clone the cloud resource.

This performs a shallow copy clone with copy on write semantics. That is to say, the copy becomes a deep copy if either the clone or the original are modified.

Returns
A clone of the point cloud resource.

Implements tes::Resource.

◆ colours() [1/2]

const uint32_t* tes::PointCloud::colours ( unsigned &  stride,
int  stream = 0 
) const
overridevirtual

Returns a pointer to the colour stream.

Each element is taken 32-bit integer. Expects vertexCount(stream) elements or null if no vertex colours.

Parameters
[out]strideThe stride between colour elements (bytes). This would be 4 for a contiguous array of uint32_t colours.
streamReserved for future use.
Returns
A pointer to the first colour value or null.

Implements tes::MeshResource.

◆ colours() [2/2]

const Colour* tes::PointCloud::colours ( ) const

Access colours as a Colour array.

Returns
A pointer to the colour data as a Colour array. The number of elements matches vertexCount().

◆ drawType()

uint8_t tes::PointCloud::drawType ( int  stream = 0) const
overridevirtual

Always returns DtPoints.

Returns
DtPoints

Implements tes::MeshResource.

◆ id()

uint32_t tes::PointCloud::id ( ) const
overridevirtual

The resource ID.

Unique among resources of the same typeId().

Returns
The resource's ID.

Implements tes::Resource.

◆ indexCount()

unsigned tes::PointCloud::indexCount ( int  stream = 0) const
overridevirtual

Not supported.

Returns
Zero.

Implements tes::MeshResource.

◆ indices()

const uint8_t* tes::PointCloud::indices ( unsigned &  stride,
unsigned &  width,
int  stream = 0 
) const
overridevirtual

Not supported.

Returns
null

Implements tes::MeshResource.

◆ normals() [1/2]

const float* tes::PointCloud::normals ( unsigned &  stride,
int  stream = 0 
) const
overridevirtual

Returns a pointer to the normal stream.

Each element is taken as a triple of single precision floats: (x, y, z). Expects vertexColour(stream) elements or null if no normals.

Parameters
[out]strideThe stride between normal elements (bytes). This would be 12 for a contiguous array of float triples.
streamReserved for future use.
Returns
A pointer to the first normal or null

Implements tes::MeshResource.

◆ normals() [2/2]

const Vector3f* tes::PointCloud::normals ( ) const

Access normals as a Vector3f array.

Returns
A pointer to the normal data as a Vector3f array. The number of elements matches vertexCount().

◆ reserve()

void tes::PointCloud::reserve ( unsigned  size)

Reserve sufficient vertex, normal and colour data for size points.

Parameters
sizeThe number of points to reserve space for.

◆ resize()

void tes::PointCloud::resize ( unsigned  count)

Resize the point cloud to contain count vertices, normals and colours.

Parameters
countThe number of points to resize the cloud to.

◆ setColour()

void tes::PointCloud::setColour ( unsigned  index,
const Colour colour 
)

Replace an existing point colour.

Ignore if out of range.

Parameters
indexThe point index.
colourThe new point colour.

◆ setNormal()

void tes::PointCloud::setNormal ( unsigned  index,
const Vector3f normal 
)

Replace an existing point normal.

Ignore if out of range.

Parameters
indexThe point index.
normalThe new point normal.

◆ setPoint() [1/3]

void tes::PointCloud::setPoint ( unsigned  index,
const Vector3f point 
)
inline

Replace an existing point.

Ignore if out of range.

Parameters
indexThe point index.
pointThe new point coordinate.

◆ setPoint() [2/3]

void tes::PointCloud::setPoint ( unsigned  index,
const Vector3f point,
const Vector3f normal 
)
inline

Replace an existing point.

Ignore if out of range.

Parameters
indexThe point index.
pointThe new point coordinate.
normalThe new point normal.

◆ setPoint() [3/3]

void tes::PointCloud::setPoint ( unsigned  index,
const Vector3f point,
const Vector3f normal,
const Colour colour 
)
inline

Replace an existing point.

Ignore if out of range.

Parameters
indexThe point index.
pointThe new point coordinate.
normalThe new point normal.
colourThe new point colour.

◆ setPoints() [1/3]

void tes::PointCloud::setPoints ( unsigned  index,
const Vector3f points,
unsigned  count 
)

Replace a set of existing points.

Normal and colour data are left as is.

Overrun points are ignored.

Parameters
indexThe point index.
pointsThe new point coordinates.
countThe number of points in points.

◆ setPoints() [2/3]

void tes::PointCloud::setPoints ( unsigned  index,
const Vector3f points,
const Vector3f normals,
unsigned  count 
)

Replace a set of existing points.

Colour data are left as is.

Overrun points are ignored.

Parameters
indexThe point index.
pointsThe new point coordinates.
normalsThe new point normals.
countThe number of points in points and normals.

◆ setPoints() [3/3]

void tes::PointCloud::setPoints ( unsigned  index,
const Vector3f points,
const Vector3f normals,
const Colour colours,
unsigned  count 
)

Replace a set of existing points.

Overrun points are ignored.

Parameters
indexThe point index.
pointsThe new point coordinates.
normalsThe new point normals.
coloursThe new point colours.
countThe number of points in points, normals and colours.

◆ tint()

uint32_t tes::PointCloud::tint ( ) const
overridevirtual

Always returns white.

Returns
White.

Implements tes::MeshResource.

◆ transform()

Matrix4f tes::PointCloud::transform ( ) const
overridevirtual

Always the identity matrix.

Returns
An identity matrix.

Implements tes::MeshResource.

◆ uvs()

const float* tes::PointCloud::uvs ( unsigned &  ,
int   
) const
overridevirtual

Not supported.

Returns
null

Implements tes::MeshResource.

◆ vertexCount()

unsigned tes::PointCloud::vertexCount ( int  stream = 0) const
overridevirtual

Returns the number of vertices in the mesh.

Parameters
streamReserved for future use.
Returns
The number of vertices.

Implements tes::MeshResource.

◆ vertices() [1/2]

const float* tes::PointCloud::vertices ( unsigned &  stride,
int  stream = 0 
) const
overridevirtual

Returns a pointer to the vertex stream.

Each element is taken as a triple of single precision floats: (x, y, z).

Parameters
[out]strideThe stride between vertex elements (bytes). This would be 12 for a contiguous array of float triples.
streamReserved for future use.
Returns
A pointer to the first vertex.

Implements tes::MeshResource.

◆ vertices() [2/2]

const Vector3f* tes::PointCloud::vertices ( ) const

Access vertices as a Vector3f array.

Returns
A pointer to the vertex data as a Vector3f array. The number of elements matches vertexCount().

The documentation for this class was generated from the following file: