chai3d::cPointArray Class Reference

This class implements an array of 3D points. More...

#include <CPointArray.h>

Inheritance diagram for chai3d::cPointArray:

Public Member Functions

 cPointArray (cVertexArrayPtr a_vertexArray)
 
 ~cPointArray ()
 
void clear ()
 This method clears all points from the array. More...
 
virtual unsigned int getNumVerticesPerElement ()
 This method returns the number of vertices that compose a point. More...
 
cPointArrayPtr copy ()
 This method copies point data and return new point array. More...
 
void compress ()
 This method compresses the array by removing non used points. More...
 
int newPoint (const unsigned int a_vertexIndex0)
 
void removePoint (const unsigned int a_pointIndex)
 
void setVertex (const unsigned int a_pointIndex, const unsigned int a_vertexIndex)
 
unsigned int getVertexIndex0 (const unsigned int a_pointIndex) const
 
virtual unsigned int getVertexIndex (const unsigned int a_elementIndex, const unsigned int a_vertexNumber) const
 
cVector3d getTexCoordAtPosition (const unsigned int a_pointIndex, const cVector3d &a_localPos)
 
void render ()
 
virtual bool computeCollision (const unsigned int a_elementIndex, cGenericObject *a_object, cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings) const
 This method checks if a given line segment intersects a selected point from this array. More...
 
- Public Member Functions inherited from chai3d::cGenericArray
 cGenericArray (cVertexArrayPtr a_vertexArray)
 
 ~cGenericArray ()
 
virtual unsigned int getNumElements ()
 This method returns the number of allocated elements. More...
 
void compress ()
 This method removes non used elements. This compresses the array. More...
 
bool getAllocated (const unsigned int a_index) const
 
cVector3d getTexCoordAtPosition (const unsigned int a_elementIndex, const cVector3d &a_localPos)
 

Static Public Member Functions

static cPointArrayPtr create (cVertexArrayPtr a_vertexArray)
 Shared cPointArray allocator. More...
 
- Static Public Member Functions inherited from chai3d::cGenericArray
static cGenericArrayPtr create (cVertexArrayPtr a_vertexArray)
 Shared cGenericArray allocator. More...
 

Additional Inherited Members

- Public Attributes inherited from chai3d::cGenericArray
cVertexArrayPtr m_vertices
 Vertex array that contains all vertices used to describe the elements of this array. More...
 
std::vector< unsigned int > m_indices
 Element indices to vertices. More...
 
std::vector< bool > m_allocated
 Element allocation flags. More...
 
bool m_flagMarkForUpdate
 If true then element data has been modified. More...
 
bool m_flagMarkForResize
 If true then element array size has changed. More...
 
GLuint m_elementBuffer
 OpenGL Buffer for storing elements. More...
 
- Protected Attributes inherited from chai3d::cGenericArray
std::list< unsigned int > m_freeElements
 List of free elements. More...
 

Detailed Description

cPointArray defines an array of points, each composed of a single vertex.
A point array is created by first passing a reference to an array of vertices (cVertexArray) from which the points are composed.
For graphic rendering purposes and memory efficiency, points are stored in large arrays. The number of allocated points in an array can be retrieved by calling getNumElements().
New points can be added or removed by calling newPoint() and removePoint(). respectively.
When a point is removed from the array, its vertex index is set to zero and the point index number is added to a list of free points for future allocation.

To avoid accumulating large numbers of free points, it is possible to compress the array by calling compress(). This method removes all non used points from memory.

Constructor & Destructor Documentation

chai3d::cPointArray::cPointArray ( cVertexArrayPtr  a_vertexArray)
inline

Constructor of cPointArray.

Parameters
a_vertexArrayArray of vertices used to describe the points.
chai3d::cPointArray::~cPointArray ( )
inline

Destructor of cPointArray.

Member Function Documentation

void chai3d::cPointArray::clear ( )
inlinevirtual

Reimplemented from chai3d::cGenericArray.

static cPointArrayPtr chai3d::cPointArray::create ( cVertexArrayPtr  a_vertexArray)
inlinestatic
virtual unsigned int chai3d::cPointArray::getNumVerticesPerElement ( )
inlinevirtual

Reimplemented from chai3d::cGenericArray.

cPointArrayPtr chai3d::cPointArray::copy ( )

This method creates a copy of all allocated points. Please note that this method does not copy points that were previously deallocated.

Returns
New point array.
void chai3d::cPointArray::compress ( )

This method compress the point array by removing all non allocated points. If many points are unused, this method can effectively reduce the memory footprint allocated by the array.
IMPORTANT:
After calling this method, it is important to immediately update any collision detector as the collision tree may try to access points that no longer exist.

int chai3d::cPointArray::newPoint ( const unsigned int  a_vertexIndex0)
inline

This method creates a new point.

Parameters
a_vertexIndex0index of vertex 0.
Returns
Index number of new point.
void chai3d::cPointArray::removePoint ( const unsigned int  a_pointIndex)
inline

This method deallocates a selected point from the array. Its vertex index is set to zero, and the point is added to the free list for future allocation.

Parameters
a_pointIndexIndex number of selected point.
void chai3d::cPointArray::setVertex ( const unsigned int  a_pointIndex,
const unsigned int  a_vertexIndex 
)
inline

This method sets the vertex of a selected point by passing its index number.

Parameters
a_pointIndexIndex of selected point.
a_vertexIndexIndex of vertex.
unsigned int chai3d::cPointArray::getVertexIndex0 ( const unsigned int  a_pointIndex) const
inline

This method returns the index number of the vertex that describes a selected point.

Parameters
a_pointIndexIndex of point.
Returns
Index to vertex.
virtual unsigned int chai3d::cPointArray::getVertexIndex ( const unsigned int  a_elementIndex,
const unsigned int  a_vertexNumber 
) const
inlinevirtual

This method reads the index number of the vertex of a selected point. In the case of a point a_vertexNumber only takes value 0, as a point is only composed of a single vertex.

Parameters
a_elementIndexIndex number of selected point.
a_vertexNumberVertex number.
Returns
Index number of the requested vertex.

Reimplemented from chai3d::cGenericArray.

cVector3d chai3d::cPointArray::getTexCoordAtPosition ( const unsigned int  a_pointIndex,
const cVector3d a_localPos 
)
inline

This method returns the texture coordinate at the point. For points, a_localPos is meaningless and ignore. This value is used however for segments or triangles.

Parameters
a_pointIndexIndex number of selected point.
a_localPosValue ignored.
Returns
Interpolated texture coordinate at desired location.
void chai3d::cPointArray::render ( )
inlinevirtual

This method renders the OpenGL vertex buffer object.

Reimplemented from chai3d::cGenericArray.

bool chai3d::cPointArray::computeCollision ( const unsigned int  a_elementIndex,
cGenericObject a_object,
cVector3d a_segmentPointA,
cVector3d a_segmentPointB,
cCollisionRecorder a_recorder,
cCollisionSettings a_settings 
) const
virtual

This method checks if the given line point intersects a selected a point from this array.
If a collision occurs, the collision point is reported to the collision recorder.

Parameters
a_elementIndexPoint index number.
a_objectPointer to the object on which collision detection is being performed.
a_segmentPointAPoint from where collision ray starts (in local frame).
a_segmentPointBDirection vector of collision ray (in local frame).
a_recorderStores collision events.
a_settingsCollision detection settings.
Returns
true if a collision has occurred, otherwise false.

Reimplemented from chai3d::cGenericArray.


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