Geogram Version 1.10.2
A programming library of geometric algorithms
Loading...
Searching...
No Matches
GEO::Mesh Class Reference

Represents a mesh. More...

#include <geogram/mesh/mesh.h>

Public Member Functions

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

Static Public Member Functions

static std::string subelements_type_to_name (MeshElementsFlags what)
 Gets a subelement name by subelement type.
static MeshElementsFlags name_to_subelements_type (const std::string &name)
 Gets a subelement type by subelement name.
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.

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.
 Mesh (const Mesh &rhs)=delete
 Forbids copy.
const Mesh & operator= (const Mesh &rhs)=delete
 Forbids copy.

(Note that these are not member symbols.)

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 3178 of file mesh.h.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

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).

◆ Mesh() [2/2]

GEO::Mesh::Mesh ( const Mesh & rhs)
protecteddelete

Forbids copy.

This is to make sure that client code does not unintentionlly copies a Mesh (for instance by passing it by-value to a function). Use copy() instead.

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.

All attributes of this mesh are deleted, and Attribute instances connected to this mesh are unbound.

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.

◆ load()

bool GEO::Mesh::load ( const std::string & filename)

Loads this mesh from a file.

The file format is deduced from the extension. Supported formats are those registered in the mesh I/O handlers (.obj, .off, .ply, .stl, .mesh/.meshb, .geogram, ...). Equivalent to mesh_load(filename, *this); implemented in mesh_io.cpp.

Parameters
[in]filenamethe name of the file
Return values
trueon success

◆ name_to_subelements_type()

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.

◆ operator=()

const Mesh & GEO::Mesh::operator= ( const Mesh & rhs)
protecteddelete

Forbids copy.

This is to make sure that client code does not unintentionlly copies a Mesh (for instance by passing it by-value to a function). Use copy() instead.

◆ parse_attribute_name()

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

◆ save()

bool GEO::Mesh::save ( const std::string & filename) const

Saves this mesh to a file.

The file format is deduced from the extension. Equivalent to mesh_save(*this, filename).

Parameters
[in]filenamethe name of the file
Return values
trueon success

◆ subelements_type_to_name()

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.

◆ 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 3157 of file mesh.h.

Member Data Documentation

◆ cell_corners

MeshCellCornersStore GEO::Mesh::cell_corners

Definition at line 3185 of file mesh.h.

◆ cell_facets

MeshCellFacetsStore GEO::Mesh::cell_facets

Definition at line 3186 of file mesh.h.

◆ cells

MeshCells GEO::Mesh::cells

Definition at line 3184 of file mesh.h.

◆ edges

MeshEdges GEO::Mesh::edges

Definition at line 3181 of file mesh.h.

◆ facet_corners

MeshFacetCornersStore GEO::Mesh::facet_corners

Definition at line 3183 of file mesh.h.

◆ facets

MeshFacets GEO::Mesh::facets

Definition at line 3182 of file mesh.h.

◆ vertices

MeshVertices GEO::Mesh::vertices

Definition at line 3180 of file mesh.h.


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