Geogram  Version 1.8.9-rc
A programming library of geometric algorithms
GEO::Mesh Class Reference

Represents a mesh. More...

#include <geogram/mesh/mesh.h>

Inheritance diagram for GEO::Mesh:
GEO::CSGMesh

Public Member Functions

 Mesh (index_t dimension=3, bool single_precision=false)
 Mesh constructor. More...
 
virtual ~Mesh ()
 Mesh destructor.
 
void clear (bool keep_attributes=true, bool keep_memory=false)
 Removes all the elements and attributes of this mesh. More...
 
void show_stats (const std::string &tag="Mesh") const
 Displays number of vertices, facets and borders.
 
void assert_is_valid ()
 Does some validity checks. More...
 
void copy (const Mesh &rhs, bool copy_attributes=true, MeshElementsFlags what=MESH_ALL_ELEMENTS)
 Copies a mesh onto this one. More...
 
std::string get_attributes () const
 Gets the list of all attributes. More...
 
std::string get_scalar_attributes () const
 Gets the list of all scalar attributes. More...
 
std::string get_vector_attributes (index_t max_dim=0) const
 Gets the list of all vector attributes. More...
 
index_t nb_subelements_types () const
 Gets the number of subelements types. More...
 
MeshSubElementsStoreget_subelements_by_index (index_t i)
 Gets a MeshSubElementsStore by index. More...
 
const MeshSubElementsStoreget_subelements_by_index (index_t i) const
 Gets a MeshSubElementsStore by index. More...
 
MeshSubElementsStoreget_subelements_by_type (MeshElementsFlags what)
 Gets a MeshSubElementsStore by subelements type. More...
 
const MeshSubElementsStoreget_subelements_by_type (MeshElementsFlags what) const
 Gets a MeshSubElementsStore by subelements type. More...
 

Static Public Member Functions

static std::string subelements_type_to_name (MeshElementsFlags what)
 Gets a subelement name by subelement type. More...
 
static MeshElementsFlags name_to_subelements_type (const std::string &name)
 Gets a subelement type by subelement name. More...
 
static bool parse_attribute_name (const std::string &full_attribute_name, MeshElementsFlags &where, std::string &attribute_name, index_t &component)
 Extracts localisation, name and optional component from an attribute name. More...
 

Public Attributes

MeshVertices vertices
 
MeshEdges edges
 
MeshFacets facets
 
MeshFacetCornersStore facet_corners
 
MeshCells cells
 
MeshCellCornersStore cell_corners
 
MeshCellFacetsStore cell_facets
 

Protected Member Functions

void display_attributes (const std::string &tag, const std::string &subelement_name, const MeshSubElementsStore &subelements) const
 Displays the list of attributes to the Logger. More...
 

Related Functions

(Note that these are not member functions.)

enum  MeshElementsFlags
 Indicates the mesh elements (vertices, facets or cells) present in a mesh. More...
 

Detailed Description

Represents a mesh.

A mesh can have vertices, optionally facets and optionally volumetric cells. Attributes can be attached to all elements and sub-elements.

Definition at line 2693 of file mesh.h.

Constructor & Destructor Documentation

◆ Mesh()

GEO::Mesh::Mesh ( index_t  dimension = 3,
bool  single_precision = false 
)

Mesh constructor.

Parameters
[in]dimensiondimension of the vertices
[in]single_precisionif true, vertices are stored in single precision (float), else they are stored as double precision (double).

Member Function Documentation

◆ assert_is_valid()

void GEO::Mesh::assert_is_valid ( )

Does some validity checks.

Used for debugging. If the validity checks are not satisfied, then it crashes with an assertion failure.

◆ clear()

void GEO::Mesh::clear ( bool  keep_attributes = true,
bool  keep_memory = false 
)

Removes all the elements and attributes of this mesh.

Parameters
[in]keep_attributesif true, then all the existing attribute names / bindings are kept (but they are cleared). If false, they are destroyed.
[in]keep_memoryif true, then memory is kept and can be reused by subsequent mesh element creations.

◆ copy()

void GEO::Mesh::copy ( const Mesh rhs,
bool  copy_attributes = true,
MeshElementsFlags  what = MESH_ALL_ELEMENTS 
)

Copies a mesh onto this one.

Parameters
[in]rhsa const reference to the mesh to be copied
[in]copy_attributesif true, all the attributes are copied.
[in]whata combination of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_CELLS flags. Set to MESH_ALL_ELEMENTS to copy everything (default). If MESH_VERTICES is not set, then the mesh is cleared.

◆ display_attributes()

void GEO::Mesh::display_attributes ( const std::string &  tag,
const std::string &  subelement_name,
const MeshSubElementsStore subelements 
) const
protected

Displays the list of attributes to the Logger.

Parameters
[in]tagthe tag to be sent to the Logger
[in]subelement_namethe name of the subelement (vertices, facets, facet_corners ...)
[in]subelementsa const reference to the MeshSubElementsStore

◆ get_attributes()

std::string GEO::Mesh::get_attributes ( ) const

Gets the list of all attributes.

Returns
a ';'-separated list of all attributes.

◆ get_scalar_attributes()

std::string GEO::Mesh::get_scalar_attributes ( ) const

Gets the list of all scalar attributes.

Returns
a ';'-separated list of all scalar attributes.

Whenever there is a vector attribute v of dim d, it appends v[0];v[1];...v[d-1] to the list.

◆ get_subelements_by_index() [1/2]

MeshSubElementsStore& GEO::Mesh::get_subelements_by_index ( index_t  i)

Gets a MeshSubElementsStore by index.

Parameters
[in]iindex of the subelements
Returns
a reference to the corresponding MeshSubElementsStore
Precondition
i < nb_subelements_types()

◆ get_subelements_by_index() [2/2]

const MeshSubElementsStore& GEO::Mesh::get_subelements_by_index ( index_t  i) const

Gets a MeshSubElementsStore by index.

Parameters
[in]iindex of the subelements
Returns
a const reference to the corresponding MeshSubElementsStore
Precondition
i < nb_subelements_types()

◆ get_subelements_by_type() [1/2]

MeshSubElementsStore& GEO::Mesh::get_subelements_by_type ( MeshElementsFlags  what)

Gets a MeshSubElementsStore by subelements type.

Parameters
[in]whatone of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_FACET_CORNERS, MESH_CELLS, MESH_CELL_CORNERS, MESH_CELL_FACETS
Returns
a reference to the corresponding MeshSubElementsStore

◆ get_subelements_by_type() [2/2]

const MeshSubElementsStore& GEO::Mesh::get_subelements_by_type ( MeshElementsFlags  what) const

Gets a MeshSubElementsStore by subelements type.

Parameters
[in]whatone of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_FACET_CORNERS, MESH_CELLS, MESH_CELL_CORNERS, MESH_CELL_FACETS
Returns
a const reference to the corresponding MeshSubElementsStore

◆ get_vector_attributes()

std::string GEO::Mesh::get_vector_attributes ( index_t  max_dim = 0) const

Gets the list of all vector attributes.

Parameters
[in]max_dimif non-zero, only vector attributes of dimension lower than max_dim are returned.
Returns
a ';'-separated list of all vector attributes.

◆ name_to_subelements_type()

static MeshElementsFlags GEO::Mesh::name_to_subelements_type ( const std::string &  name)
static

Gets a subelement type by subelement name.

Parameters
[in]namethe name of the subelement as a string
Returns
one of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_FACET_CORNERS, MESH_CELLS, MESH_CELL_CORNERS, MESH_CELL_FACETS or MESH_NONE if the name is invalid

◆ nb_subelements_types()

index_t GEO::Mesh::nb_subelements_types ( ) const

Gets the number of subelements types.

Returns
the number of subelements types.

◆ parse_attribute_name()

static bool GEO::Mesh::parse_attribute_name ( const std::string &  full_attribute_name,
MeshElementsFlags where,
std::string &  attribute_name,
index_t component 
)
static

Extracts localisation, name and optional component from an attribute name.

Parameters
[in]full_attribute_namefor instance, facets.density, or vertices.normal[0]
[out]whereone of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_FACET_CORNERS, MESH_CELLS, MESH_CELL_FACETS, MESH_CELL_CORNERS
[out]attribute_namethe name of the attribute, without the localisation and without the component
[out]componentthe component (between square brackets in full_attribute_name) or 0 if no component was specified
Return values
trueif the attribute name could be parsed
falseif the attribute name has invalid syntax

◆ subelements_type_to_name()

static std::string GEO::Mesh::subelements_type_to_name ( MeshElementsFlags  what)
static

Gets a subelement name by subelement type.

Parameters
[in]whatone of MESH_VERTICES, MESH_EDGES, MESH_FACETS, MESH_FACET_CORNERS, MESH_CELLS, MESH_CELL_CORNERS, MESH_CELL_FACETS
Returns
a string with the name of the subelement.

Friends And Related Function Documentation

◆ MeshElementsFlags

enum MeshElementsFlags
related

Indicates the mesh elements (vertices, facets or cells) present in a mesh.

The set of elements present in a mesh is represented by a bitwise-or combination of the constants.

Definition at line 2672 of file mesh.h.


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