ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::SimpleMesh Class Reference

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

#include <SimpleMesh.h>

Inheritance diagram for cloudViewer::SimpleMesh:
Collaboration diagram for cloudViewer::SimpleMesh:

Public Member Functions

 SimpleMesh (GenericIndexedCloud *_theVertices, bool linkVerticesWithMesh=false)
 SimpleMesh Constructor. More...
 
 ~SimpleMesh () override
 SimpleMesh destructor. More...
 
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
 
VerticesIndexesgetTriangleVertIndexes (unsigned triangleIndex) override
 Returns the indexes of the vertices of a given triangle. More...
 
virtual 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...
 
virtual void getTriangleVertices (unsigned triangleIndex, double A[3], double B[3], double C[3]) const override
 
unsigned capacity () const
 Returns the mesh capacity. More...
 
const GenericIndexedCloudvertices () const
 Returns the vertices. More...
 
void clear ()
 Clears the mesh. More...
 
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 cloudViewer::GenericIndexedMesh
 GenericIndexedMesh ()=default
 
 ~GenericIndexedMesh () override=default
 Default destructor. More...
 
- Public Member Functions inherited from cloudViewer::GenericMesh
 GenericMesh ()=default
 
virtual ~GenericMesh ()=default
 Default destructor. More...
 
virtual bool hasTriangles () const
 

Protected Types

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

Protected Attributes

TriangleIndexesContainer m_triIndexes
 The triangles indexes. More...
 
unsigned globalIterator
 Iterator on the list of triangles. More...
 
SimpleTriangle dummyTriangle
 Dump triangle structure to transmit temporary data. More...
 
GenericIndexedCloudtheVertices
 The associated point cloud (vertices) More...
 
bool verticesLinked
 
BoundingBox m_bbox
 Bounding-box. More...
 

Additional Inherited Members

- Public Types inherited from cloudViewer::GenericMesh
enum class  SimplificationContraction { Average , Quadric }
 Indicates the method that is used for mesh simplification if multiple vertices are combined to a single one. More...
 
enum class  FilterScope { All , Color , Normal , Vertex }
 Indicates the scope of filter operations. More...
 
enum class  DeformAsRigidAsPossibleEnergy { Spokes , Smoothed }
 
using genericTriangleAction = std::function< void(GenericTriangle &)>
 Generic function to apply to a triangle (used by foreach) More...
 

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.

Definition at line 26 of file SimpleMesh.h.

Member Typedef Documentation

◆ TriangleIndexesContainer

A triangle vertices indexes container.

Definition at line 102 of file SimpleMesh.h.

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

Definition at line 18 of file SimpleMesh.cpp.

◆ ~SimpleMesh()

SimpleMesh::~SimpleMesh ( )
override

SimpleMesh destructor.

Definition at line 25 of file SimpleMesh.cpp.

References theVertices, and verticesLinked.

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 cloudViewer::GenericMesh.

Definition at line 45 of file SimpleMesh.cpp.

References _getTriangle(), and globalIterator.

◆ _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 cloudViewer::GenericIndexedMesh.

Definition at line 49 of file SimpleMesh.cpp.

References cloudViewer::SimpleTriangle::A, cloudViewer::SimpleTriangle::B, cloudViewer::SimpleTriangle::C, dummyTriangle, cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::VerticesIndexes::i1, cloudViewer::VerticesIndexes::i2, cloudViewer::VerticesIndexes::i3, m_triIndexes, and theVertices.

Referenced by _getNextTriangle().

◆ 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

Definition at line 103 of file SimpleMesh.cpp.

References m_bbox, m_triIndexes, and cloudViewer::BoundingBoxTpl< T >::setValidity().

Referenced by AddTriangle(), define_SimpleMesh(), MergeOldTriangles(), cloudViewer::ManualSegmentationTools::segmentMesh(), and cloudViewer::Neighbourhood::triangulateFromQuadric().

◆ capacity()

unsigned cloudViewer::SimpleMesh::capacity ( ) const
inline

Returns the mesh capacity.

Definition at line 62 of file SimpleMesh.h.

Referenced by AddTriangle(), define_SimpleMesh(), and cloudViewer::ManualSegmentationTools::segmentMesh().

◆ clear()

void cloudViewer::SimpleMesh::clear ( )
inline

Clears the mesh.

Definition at line 70 of file SimpleMesh.h.

Referenced by define_SimpleMesh(), and cloudViewer::ManualSegmentationTools::segmentMeshWithAABox().

◆ 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 cloudViewer::GenericMesh.

Definition at line 32 of file SimpleMesh.cpp.

References cloudViewer::SimpleTriangle::A, cloudViewer::SimpleTriangle::B, cloudViewer::SimpleTriangle::C, count, cloudViewer::GenericIndexedCloud::getPoint(), m_triIndexes, and theVertices.

◆ 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 cloudViewer::GenericMesh.

Definition at line 84 of file SimpleMesh.cpp.

References cloudViewer::GenericCloud::getBoundingBox(), and theVertices.

◆ 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 cloudViewer::GenericIndexedMesh.

Definition at line 184 of file SimpleMesh.cpp.

References getTriangleVertIndexes(), and globalIterator.

◆ getTriangleVertices() [1/2]

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 cloudViewer::GenericIndexedMesh.

Definition at line 60 of file SimpleMesh.cpp.

References cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::VerticesIndexes::i1, cloudViewer::VerticesIndexes::i2, cloudViewer::VerticesIndexes::i3, m_triIndexes, and theVertices.

◆ getTriangleVertices() [2/2]

void cloudViewer::SimpleMesh::getTriangleVertices ( unsigned  triangleIndex,
double  A[3],
double  B[3],
double  C[3] 
) const
overridevirtual

◆ 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 cloudViewer::GenericIndexedMesh.

Definition at line 180 of file SimpleMesh.cpp.

References m_triIndexes.

Referenced by getNextTriangleVertIndexes(), ImportSourceVertices(), and MergeOldTriangles().

◆ 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 cloudViewer::GenericIndexedMesh.

Definition at line 131 of file SimpleMesh.cpp.

References cross(), cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::VerticesIndexes::i1, cloudViewer::VerticesIndexes::i2, cloudViewer::VerticesIndexes::i3, m_triIndexes, theVertices, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

◆ normalsAvailable()

bool SimpleMesh::normalsAvailable ( ) const
overridevirtual

Returns whether normals are available.

Reimplemented from cloudViewer::GenericIndexedMesh.

Definition at line 127 of file SimpleMesh.cpp.

References cloudViewer::GenericIndexedCloud::normalsAvailable(), and theVertices.

◆ placeIteratorAtBeginning()

void SimpleMesh::placeIteratorAtBeginning ( )
overridevirtual

Places the mesh iterator at the beginning.

Virtual method to handle the mesh global iterator

Implements cloudViewer::GenericMesh.

Definition at line 43 of file SimpleMesh.cpp.

References globalIterator.

◆ 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

Definition at line 109 of file SimpleMesh.cpp.

References m_triIndexes.

Referenced by AddTriangle(), define_SimpleMesh(), MergeOldTriangles(), cloudViewer::ManualSegmentationTools::segmentMesh(), and cloudViewer::Neighbourhood::triangulateFromQuadric().

◆ 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

Definition at line 118 of file SimpleMesh.cpp.

References m_triIndexes.

Referenced by define_SimpleMesh(), MergeOldTriangles(), cloudViewer::ManualSegmentationTools::segmentMesh(), and cloudViewer::ManualSegmentationTools::segmentMeshWithAABox().

◆ size()

virtual unsigned cloudViewer::SimpleMesh::size ( ) const
inlineoverridevirtual

Returns the number of triangles.

Virtual method to request the mesh size

Returns
the mesh size

Implements cloudViewer::GenericMesh.

Definition at line 47 of file SimpleMesh.h.

Referenced by AddTriangle(), ImportSourceVertices(), MergeOldTriangles(), cloudViewer::ManualSegmentationTools::segmentMesh(), and cloudViewer::ManualSegmentationTools::segmentMeshWithAABox().

◆ vertices()

const GenericIndexedCloud* cloudViewer::SimpleMesh::vertices ( ) const
inline

Returns the vertices.

Definition at line 67 of file SimpleMesh.h.

Referenced by ccCropTool::Crop(), and define_SimpleMesh().

Member Data Documentation

◆ dummyTriangle

SimpleTriangle cloudViewer::SimpleMesh::dummyTriangle
protected

Dump triangle structure to transmit temporary data.

Definition at line 109 of file SimpleMesh.h.

Referenced by _getTriangle().

◆ globalIterator

unsigned cloudViewer::SimpleMesh::globalIterator
protected

Iterator on the list of triangles.

Definition at line 107 of file SimpleMesh.h.

Referenced by _getNextTriangle(), getNextTriangleVertIndexes(), and placeIteratorAtBeginning().

◆ m_bbox

BoundingBox cloudViewer::SimpleMesh::m_bbox
protected

Bounding-box.

Definition at line 118 of file SimpleMesh.h.

Referenced by addTriangle().

◆ m_triIndexes

TriangleIndexesContainer cloudViewer::SimpleMesh::m_triIndexes
protected

◆ theVertices

GenericIndexedCloud* cloudViewer::SimpleMesh::theVertices
protected

The associated point cloud (vertices)

Definition at line 112 of file SimpleMesh.h.

Referenced by _getTriangle(), forEach(), getBoundingBox(), getTriangleVertices(), interpolateNormals(), normalsAvailable(), and ~SimpleMesh().

◆ verticesLinked

bool cloudViewer::SimpleMesh::verticesLinked
protected

Specifies if the associated cloud should be deleted when the mesh is deleted

Definition at line 115 of file SimpleMesh.h.

Referenced by ~SimpleMesh().


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