CCCoreLib 31 May 2022
CloudCompare Core algorithms
Public Member Functions | Protected Types | Protected Attributes | List of all members
CCCoreLib::SimpleMesh Class Reference

A simple mesh structure, with index-based vertex access. More...

#include <SimpleMesh.h>

Inheritance diagram for CCCoreLib::SimpleMesh:
Inheritance graph
[legend]
Collaboration diagram for CCCoreLib::SimpleMesh:
Collaboration graph
[legend]

Public Member Functions

 SimpleMesh (GenericIndexedCloud *_theVertices, bool linkVerticesWithMesh=false)
 SimpleMesh Constructor. More...
 
 ~SimpleMesh () override
 SimpleMesh destructor.
 
void forEach (genericTriangleAction action) override
 Fast iteration mechanism. More...
 
void placeIteratorAtBeginning () override
 Places the mesh iterator at the beginning. More...
 
GenericTriangle_getNextTriangle () override
 Returns the next triangle (relatively to the global iterator position) More...
 
GenericTriangle_getTriangle (unsigned triangleIndex) override
 Returns the ith triangle. More...
 
VerticesIndexesgetNextTriangleVertIndexes () override
 Returns the indexes of the vertices of the next triangle (relatively to the global iterator position) More...
 
VerticesIndexesgetTriangleVertIndexes (unsigned triangleIndex) override
 Returns the indexes of the vertices of a given triangle. More...
 
unsigned size () const override
 Returns the number of triangles. More...
 
void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax) override
 Returns the mesh bounding-box. More...
 
void getTriangleVertices (unsigned triangleIndex, CCVector3 &A, CCVector3 &B, CCVector3 &C) const override
 Returns the vertices of a given triangle. More...
 
unsigned capacity () const
 Returns the mesh capacity.
 
const GenericIndexedCloudvertices () const
 Returns the vertices.
 
void clear ()
 Clears the mesh.
 
virtual void addTriangle (unsigned i1, unsigned i2, unsigned i3)
 Adds a triangle to the mesh. More...
 
virtual bool reserve (unsigned n)
 Reserves the memory to store the triangles (as 3 indexes each) More...
 
virtual bool resize (unsigned n)
 Resizes the mesh database. More...
 
bool normalsAvailable () const override
 Returns whether normals are available. More...
 
bool interpolateNormals (unsigned triIndex, const CCVector3 &P, CCVector3 &N) override
 Interpolates normal(s) inside a given triangle. More...
 
- Public Member Functions inherited from CCCoreLib::GenericIndexedMesh
 ~GenericIndexedMesh () override=default
 Default destructor.
 
virtual GenericTriangle_getTriangle (unsigned triangleIndex)=0
 Returns the ith triangle. More...
 
virtual VerticesIndexesgetTriangleVertIndexes (unsigned triangleIndex)=0
 Returns the indexes of the vertices of a given triangle. More...
 
virtual void getTriangleVertices (unsigned triangleIndex, CCVector3 &A, CCVector3 &B, CCVector3 &C) const =0
 Returns the vertices of a given triangle. More...
 
virtual VerticesIndexesgetNextTriangleVertIndexes ()=0
 Returns the indexes of the vertices of the next triangle (relatively to the global iterator position) More...
 
virtual bool normalsAvailable () const
 Returns whether normals are available. More...
 
virtual bool interpolateNormals (unsigned triIndex, const CCVector3 &P, CCVector3 &N)
 Interpolates normal(s) inside a given triangle. More...
 
- Public Member Functions inherited from CCCoreLib::GenericMesh
virtual ~GenericMesh ()=default
 Default destructor.
 
virtual unsigned size () const =0
 Returns the number of triangles. More...
 
virtual void forEach (genericTriangleAction action)=0
 Fast iteration mechanism. More...
 
virtual void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax)=0
 Returns the mesh bounding-box. More...
 
virtual void placeIteratorAtBeginning ()=0
 Places the mesh iterator at the beginning. More...
 
virtual GenericTriangle_getNextTriangle ()=0
 Returns the next triangle (relatively to the global iterator position) More...
 

Protected Types

using TriangleIndexesContainer = std::vector< VerticesIndexes >
 A triangle vertices indexes container.
 

Protected Attributes

TriangleIndexesContainer triIndexes
 The triangles indexes.
 
unsigned globalIterator
 Iterator on the list of triangles.
 
SimpleTriangle dummyTriangle
 Dump triangle structure to transmit temporary data.
 
GenericIndexedCloudtheVertices
 The associated point cloud (vertices)
 
bool verticesLinked
 Specifies if the associated cloud should be deleted when the mesh is deleted.
 
BoundingBox m_bbox
 Bounding-box.
 

Additional Inherited Members

- Public Types inherited from CCCoreLib::GenericMesh
using genericTriangleAction = std::function< void(GenericTriangle &)>
 Generic function to apply to a triangle (used by foreach)
 

Detailed Description

A simple mesh structure, with index-based vertex access.

Implements the GenericIndexedMesh interface. This mesh is always associated to a (index based) point cloud that stores the mesh vertexes.

Constructor & Destructor Documentation

◆ SimpleMesh()

SimpleMesh::SimpleMesh ( GenericIndexedCloud _theVertices,
bool  linkVerticesWithMesh = false 
)

SimpleMesh Constructor.

Parameters
_theVerticesthe point cloud containing the vertices
linkVerticesWithMeshspecifies if the vertex cloud should be deleted when the SimpleMesh object is destructed

Member Function Documentation

◆ _getNextTriangle()

GenericTriangle * SimpleMesh::_getNextTriangle ( )
overridevirtual

Returns the next triangle (relatively to the global iterator position)

Virtual method to handle the mesh global iterator. Global iterator position should be increased each time this method is called. The returned object can be temporary.

Returns
a triangle

Implements CCCoreLib::GenericMesh.

◆ _getTriangle()

GenericTriangle * SimpleMesh::_getTriangle ( unsigned  triangleIndex)
overridevirtual

Returns the ith triangle.

Virtual method to request a triangle with a specific index. The returned object can be temporary.

Parameters
triangleIndexof the requested triangle (between 0 and the mesh size-1)
Returns
the requested triangle, or 0 if index value is not valid

Implements CCCoreLib::GenericIndexedMesh.

◆ addTriangle()

void SimpleMesh::addTriangle ( unsigned  i1,
unsigned  i2,
unsigned  i3 
)
virtual

Adds a triangle to the mesh.

Vertex indexes are expresesed relatively to the vertex cloud.

Parameters
i1first vertex index
i2second vertex index
i3third vertex index

◆ forEach()

void SimpleMesh::forEach ( genericTriangleAction  action)
overridevirtual

Fast iteration mechanism.

Virtual method to apply a function to the whole mesh

Parameters
actionfunction to apply (see GenericMesh::genericTriangleAction)

Implements CCCoreLib::GenericMesh.

◆ getBoundingBox()

void SimpleMesh::getBoundingBox ( CCVector3 bbMin,
CCVector3 bbMax 
)
overridevirtual

Returns the mesh bounding-box.

Virtual method to request the mesh bounding-box limits. It is equivalent to the bounding-box of the cloud composed of the mesh vertexes.

Parameters
bbMinlower bounding-box limits (Xmin,Ymin,Zmin)
bbMaxhigher bounding-box limits (Xmax,Ymax,Zmax)

Implements CCCoreLib::GenericMesh.

◆ getNextTriangleVertIndexes()

VerticesIndexes * SimpleMesh::getNextTriangleVertIndexes ( )
overridevirtual

Returns the indexes of the vertices of the next triangle (relatively to the global iterator position)

Returns
the triangle indexes (or 0 if the global iterator is out of bounds)

Implements CCCoreLib::GenericIndexedMesh.

◆ getTriangleVertices()

void SimpleMesh::getTriangleVertices ( unsigned  triangleIndex,
CCVector3 A,
CCVector3 B,
CCVector3 C 
) const
overridevirtual

Returns the vertices of a given triangle.

Parameters
[in]triangleIndexindex of the triangle (between 0 and the size(mesh)-1)
[out]Afirst vertex
[out]Bsecond vertex
[out]Cthird vertex

Implements CCCoreLib::GenericIndexedMesh.

◆ getTriangleVertIndexes()

VerticesIndexes * SimpleMesh::getTriangleVertIndexes ( unsigned  triangleIndex)
overridevirtual

Returns the indexes of the vertices of a given triangle.

Parameters
triangleIndexindex of the triangle (between 0 and size(mesh)-1)
Returns
the triangle indexes (or 0 if index value is not valid)

Implements CCCoreLib::GenericIndexedMesh.

◆ interpolateNormals()

bool SimpleMesh::interpolateNormals ( unsigned  triIndex,
const CCVector3 P,
CCVector3 N 
)
overridevirtual

Interpolates normal(s) inside a given triangle.

This method should be ideally overriden by the child class if normals are supported

Parameters
[in]triIndextriangle index
[in]Ppoint where to interpolate (should be inside the triangle!)
[out]Ninterpolated normal
Returns
success

Reimplemented from CCCoreLib::GenericIndexedMesh.

◆ normalsAvailable()

bool SimpleMesh::normalsAvailable ( ) const
overridevirtual

Returns whether normals are available.

Reimplemented from CCCoreLib::GenericIndexedMesh.

◆ placeIteratorAtBeginning()

void SimpleMesh::placeIteratorAtBeginning ( )
overridevirtual

Places the mesh iterator at the beginning.

Virtual method to handle the mesh global iterator

Implements CCCoreLib::GenericMesh.

◆ reserve()

bool SimpleMesh::reserve ( unsigned  n)
virtual

Reserves the memory to store the triangles (as 3 indexes each)

Parameters
nthe number of triangles to reserve
Returns
true if the method succeeds, false otherwise

◆ resize()

bool SimpleMesh::resize ( unsigned  n)
virtual

Resizes the mesh database.

If the new number of elements is smaller than the actual size, the overflooding elements will be deleted.

Parameters
nthe new number of triangles
Returns
true if the method succeeds, false otherwise

◆ size()

unsigned CCCoreLib::SimpleMesh::size ( ) const
inlineoverridevirtual

Returns the number of triangles.

Virtual method to request the mesh size

Returns
the mesh size

Implements CCCoreLib::GenericMesh.


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