Graphite  Version 3
An experimental 3D geometry processing program
GEO::MeshFacets Class Reference

The facets of a mesh. More...

#include <geogram/mesh/mesh.h>

Inheritance diagram for GEO::MeshFacets:
GEO::MeshFacetsStore GEO::MeshElements GEO::MeshSubElementsStore

Public Member Functions

 MeshFacets (Mesh &mesh)
 MeshFacets constructor. More...
 
index_t nb_vertices (index_t f) const
 Gets the number of vertices of a facet. More...
 
index_t vertex (index_t f, index_t lv) const
 Gets a vertex by facet and local vertex index. More...
 
void set_vertex (index_t f, index_t lv, index_t v)
 Sets a vertex by facet and local vertex index. More...
 
index_t find_vertex (index_t f, index_t v) const
 Gets the local index of a vertex in a facet. More...
 
index_t find_common_vertex (index_t f1, index_t f2) const
 finds a common vertex shared by two facets More...
 
index_t adjacent (index_t f, index_t le) const
 Gets an adjacent facet by facet and local edge index. More...
 
index_t find_adjacent (index_t f, index_t f2) const
 Gets the local index of a facet adjacent to another one. More...
 
void set_adjacent (index_t f, index_t le, index_t f2)
 Sets an adjacent facet by facet and local edge index. More...
 
index_t next_corner_around_facet (index_t f, index_t c) const
 Gets the successor of a corner around a facet. More...
 
index_t prev_corner_around_facet (index_t f, index_t c) const
 Gets the predecessor of a corner around a facet. More...
 
index_t find_edge (index_t f, index_t v1, index_t v2)
 Finds an edge by vertex indices. More...
 
void delete_elements (vector< index_t > &to_delete, bool remove_isolated_vertices=true) override
 Deletes a set of elements. More...
 
void permute_elements (vector< index_t > &permutation) override
 Applies a permutation to the elements and their attributes. More...
 
void clear (bool keep_attributes=true, bool keep_memory=false) override
 Removes all the elements and attributes. More...
 
index_t create_facets (index_t nb_facets, index_t nb_vertices_per_polygon)
 Creates a contiguous chunk of facets. More...
 
void reserve (index_t nb_to_reserve)
 Reserves space for new facets. More...
 
index_t create_triangles (index_t nb_triangles)
 Creates a contiguous chunk of triangles. More...
 
index_t create_quads (index_t nb_quads)
 Creates a contiguous chunk of quads. More...
 
index_t create_triangle (index_t v1, index_t v2, index_t v3)
 Creates a triangle. More...
 
index_t create_quad (index_t v1, index_t v2, index_t v3, index_t v4)
 Creates a quad. More...
 
index_t create_polygon (index_t nb_vertices)
 Creates a polygonal facet. More...
 
index_t create_polygon (index_t nb_vertices, const index_t *vertices)
 Creates a polygonal facet. More...
 
index_t create_polygon (const vector< index_t > &vertices)
 Creates a polygonal facet. More...
 
void connect ()
 Connects the facets.
 
void triangulate ()
 Triangulates the facets. More...
 
void flip (index_t f)
 Flips a facet. More...
 
void compute_borders ()
 Replaces the edges of this mesh with the borders of the surfacic part.
 
void assign_triangle_mesh (coord_index_t dim, vector< double > &vertices, vector< index_t > &triangles, bool steal_args)
 Copies a triangle mesh into this Mesh. More...
 
void assign_triangle_mesh (vector< index_t > &triangles, bool steal_args)
 
void pop () override
 Removes the last element.
 
index_range corners (index_t f) const
 Gets the corners of a facet. More...
 
- Public Member Functions inherited from GEO::MeshFacetsStore
 MeshFacetsStore (Mesh &mesh)
 
index_t corners_begin (index_t f) const
 Gets the first element for iterating over the corners of a facet. More...
 
index_t corners_end (index_t f) const
 Gets the upper limit for iterating over the corners of a facet. More...
 
index_t nb_corners (index_t f) const
 Gets the number of corners in a facet. More...
 
index_t corner (index_t f, index_t lv) const
 Gets a corner by facet and local vertex index. More...
 
bool are_simplices () const
 Tests whether all the facets are triangles. More...
 
const index_tcorners_begin_ptr (index_t f) const
 Gets a pointer to the first element for iterating over the corners of a facet. More...
 
- Public Member Functions inherited from GEO::MeshSubElementsStore
 MeshSubElementsStore (Mesh &mesh)
 Constructs a new MeshSubElementStore. More...
 
virtual ~MeshSubElementsStore ()
 MeshElementStore destructor.
 
index_t nb () const
 Gets the number of (sub-)elements. More...
 
AttributesManagerattributes () const
 Gets the attributes manager. More...
 
index_as_iterator begin () const
 Used by range-based for. More...
 
index_as_iterator end () const
 Used by range-based for. More...
 

Protected Member Functions

void is_simplicial ()
 Indicates that the stored elements are only triangles.
 
void is_not_simplicial ()
 Indicates that the stored elements are no longer only triangles. More...
 
- Protected Member Functions inherited from GEO::MeshFacetsStore
void clear_store (bool keep_attributes, bool keep_memory=false) override
 Removes all the elements and attributes. More...
 
void resize_store (index_t new_size) override
 Resizes this MeshSubElementsStore. More...
 
index_t create_sub_element ()
 
index_t create_sub_elements (index_t nb)
 
void copy (const MeshFacetsStore &rhs, bool copy_attributes=true)
 
- Protected Member Functions inherited from GEO::MeshSubElementsStore
void reserve_store (index_t nb_to_reserve)
 Reserves space for new elements. More...
 
index_t create_sub_elements (index_t nb)
 Creates a contiguous chunk of attributes for sub-elements. More...
 
index_t create_sub_element ()
 Creates attributes for a sub-element. More...
 
void adjust_store ()
 Makes the size of the store tightly match the number of the elements. More...
 
void copy (const MeshSubElementsStore &rhs, bool copy_attributes=true)
 Copies a MeshSubElementsStore into this one. More...
 

Protected Attributes

MeshVerticesvertices_
 
MeshFacetCornersStorefacet_corners_
 
- Protected Attributes inherited from GEO::MeshFacetsStore
bool is_simplicial_
 
vector< index_tfacet_ptr_
 
- Protected Attributes inherited from GEO::MeshSubElementsStore
Meshmesh_
 
AttributesManager attributes_
 
index_t nb_
 

Friends

class Mesh
 
class GeogramIOHandler
 
void tessellate_facets (Mesh &M, index_t max_nb_vertices)
 Subdivides the facets with more than nb_vertices. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from GEO::MeshElements
static bool has_non_zero (const GEO::vector< index_t > &I)
 Tests whether a vector contains a non-zero value. More...
 

Detailed Description

The facets of a mesh.

Definition at line 1028 of file mesh.h.

Constructor & Destructor Documentation

◆ MeshFacets()

GEO::MeshFacets::MeshFacets ( Mesh mesh)

MeshFacets constructor.

Parameters
[in]mesha reference to the mesh this MeshFacets is attached to

Member Function Documentation

◆ adjacent()

index_t GEO::MeshFacets::adjacent ( index_t  f,
index_t  le 
) const
inline

Gets an adjacent facet by facet and local edge index.

Parameters
[in]fthe facet
[in]lethe local index of an edge in facet f
Returns
the facet incident to f along edge le or NO_FACET if le is on the border

Definition at line 1108 of file mesh.h.

◆ assign_triangle_mesh()

void GEO::MeshFacets::assign_triangle_mesh ( coord_index_t  dim,
vector< double > &  vertices,
vector< index_t > &  triangles,
bool  steal_args 
)

Copies a triangle mesh into this Mesh.

Facet adjacence are not computed. Facet and corner attributes are zeroed.

Parameters
[in]dimdimension of the vertices
[in]verticescoordinates of the vertices
[in]trianglesfacet to vertex links
[in]steal_argsif set, vertices and triangles are 'stolen' from the arguments (using vector::swap).

◆ clear()

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

Removes all the elements and attributes.

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.

Implements GEO::MeshElements.

◆ corners()

index_range GEO::MeshFacets::corners ( index_t  f) const
inline

Gets the corners of a facet.

Parameters
[in]fthe index of the facet.
Returns
a range with all the corners of the facet.

Definition at line 1412 of file mesh.h.

◆ create_facets()

index_t GEO::MeshFacets::create_facets ( index_t  nb_facets,
index_t  nb_vertices_per_polygon 
)
inline

Creates a contiguous chunk of facets.

Parameters
[in]nb_facetsnumber of facets to create
[in]nb_vertices_per_polygonnumber of vertices in each facet
Returns
the index of the first facet

Definition at line 1203 of file mesh.h.

◆ create_polygon() [1/3]

index_t GEO::MeshFacets::create_polygon ( const vector< index_t > &  vertices)
inline

Creates a polygonal facet.

Parameters
[in]verticesa const reference to a vector that contains the vertices
Returns
the index of the created facet

Definition at line 1344 of file mesh.h.

◆ create_polygon() [2/3]

index_t GEO::MeshFacets::create_polygon ( index_t  nb_vertices)
inline

Creates a polygonal facet.

Parameters
[in]nb_verticesnumber of vertices of the facet
Returns
the index of the created facet

Definition at line 1300 of file mesh.h.

◆ create_polygon() [3/3]

index_t GEO::MeshFacets::create_polygon ( index_t  nb_vertices,
const index_t vertices 
)
inline

Creates a polygonal facet.

Parameters
[in]nb_verticesnumber of vertices of the facet
[in]verticesa const pointer to the nb_vertices vertices
Returns
the index of the created facet

Definition at line 1322 of file mesh.h.

◆ create_quad()

index_t GEO::MeshFacets::create_quad ( index_t  v1,
index_t  v2,
index_t  v3,
index_t  v4 
)
inline

Creates a quad.

Parameters
[in]v1,v2,v3,v4the vertices of the quad
Returns
the index of the created quad

Definition at line 1282 of file mesh.h.

◆ create_quads()

index_t GEO::MeshFacets::create_quads ( index_t  nb_quads)
inline

Creates a contiguous chunk of quads.

Parameters
[in]nb_quadsnumber of quads to create
Returns
the index of the first quad

Definition at line 1252 of file mesh.h.

◆ create_triangle()

index_t GEO::MeshFacets::create_triangle ( index_t  v1,
index_t  v2,
index_t  v3 
)
inline

Creates a triangle.

Parameters
[in]v1,v2,v3the vertices of the triangle
Returns
the index of the created triangle

Definition at line 1261 of file mesh.h.

◆ create_triangles()

index_t GEO::MeshFacets::create_triangles ( index_t  nb_triangles)
inline

Creates a contiguous chunk of triangles.

Parameters
[in]nb_trianglesnumber of triangles to create
Returns
the index of the first triangle

Definition at line 1243 of file mesh.h.

◆ delete_elements()

void GEO::MeshFacets::delete_elements ( vector< index_t > &  to_delete,
bool  remove_isolated_vertices = true 
)
overridevirtual

Deletes a set of elements.

Parameters
[in]to_deletea vector of size nb(). If to_delete[e] is different from 0, then element e will be destroyed, else it will be kept. On exit, to_delete is modified (it is used for internal bookkeeping).
[in]remove_isolated_verticesif true, then the vertices that are no longer incident to any element are deleted.

Implements GEO::MeshElements.

◆ find_adjacent()

index_t GEO::MeshFacets::find_adjacent ( index_t  f,
index_t  f2 
) const
inline

Gets the local index of a facet adjacent to another one.

Parameters
[in]fa facet
[in]f2another facet
Returns
le such that adjacent(f,le) == f2 or NO_INDEX if f and f2 are not adjacent.

Definition at line 1119 of file mesh.h.

◆ find_common_vertex()

index_t GEO::MeshFacets::find_common_vertex ( index_t  f1,
index_t  f2 
) const
inline

finds a common vertex shared by two facets

Parameters
[in]f1,f2the two facets
Returns
the local index in f1 of a vertex present in f2, or NO_VERTEX if there is no such vertex.

Definition at line 1091 of file mesh.h.

◆ find_edge()

index_t GEO::MeshFacets::find_edge ( index_t  f,
index_t  v1,
index_t  v2 
)
inline

Finds an edge by vertex indices.

Parameters
[in]fa facet
[in]v1,v2two vertex indices
Returns
the edge le such that vertex(f,le) = v1 and vertex(f, (le+1)nb_vertices(f)) == v2

Definition at line 1172 of file mesh.h.

◆ find_vertex()

index_t GEO::MeshFacets::find_vertex ( index_t  f,
index_t  v 
) const
inline

Gets the local index of a vertex in a facet.

Parameters
[in]fa facet
[in]va vertex
Returns
lv such that vertex(f,lv) == v or NO_VERTE if f is not incident to v

Definition at line 1076 of file mesh.h.

◆ flip()

void GEO::MeshFacets::flip ( index_t  f)

Flips a facet.

The order of the corners is reversed

Parameters
[in]fthe facet to be flipped

◆ is_not_simplicial()

void GEO::MeshFacets::is_not_simplicial ( )
inlineprotected

Indicates that the stored elements are no longer only triangles.

Creates the facet pointers for the pre-existing triangles if any.

Definition at line 1439 of file mesh.h.

◆ nb_vertices()

index_t GEO::MeshFacets::nb_vertices ( index_t  f) const
inline

Gets the number of vertices of a facet.

Parameters
[in]fthe facet
Returns
the number of vertices of facet f

Definition at line 1043 of file mesh.h.

◆ next_corner_around_facet()

index_t GEO::MeshFacets::next_corner_around_facet ( index_t  f,
index_t  c 
) const
inline

Gets the successor of a corner around a facet.

Parameters
[in]fthe facet
[in]cthe corner
Returns
the successor of corner c around facet f
Precondition
c >= corners_begin(f) && c < corners_end(f)

Definition at line 1146 of file mesh.h.

◆ permute_elements()

void GEO::MeshFacets::permute_elements ( vector< index_t > &  permutation)
overridevirtual

Applies a permutation to the elements and their attributes.

On exit, permutation is modified (used for internal bookkeeping). Applying a permutation permutation is equivalent to:

for(i=0; i<permutation.size(); i++) {
data2[i] = data[permutation[i]]
}
data = data2 ;

Implements GEO::MeshElements.

◆ prev_corner_around_facet()

index_t GEO::MeshFacets::prev_corner_around_facet ( index_t  f,
index_t  c 
) const
inline

Gets the predecessor of a corner around a facet.

Parameters
[in]fthe facet
[in]cthe corner
Returns
the predecessor of corner c around facet f
Precondition
c >= corners_begin(f) && c < corners_end(f)

Definition at line 1159 of file mesh.h.

◆ reserve()

void GEO::MeshFacets::reserve ( index_t  nb_to_reserve)
inline

Reserves space for new facets.

Parameters
[in]nb_to_reservethe number of facets to reserve

Does not change size

Definition at line 1233 of file mesh.h.

◆ set_adjacent()

void GEO::MeshFacets::set_adjacent ( index_t  f,
index_t  le,
index_t  f2 
)
inline

Sets an adjacent facet by facet and local edge index.

Parameters
[in]fthe facet
[in]lethe local index of an edge in facet f
[in]f2specifies the facet incident to f along edge le or NO_FACET if le is on the border

Definition at line 1135 of file mesh.h.

◆ set_vertex()

void GEO::MeshFacets::set_vertex ( index_t  f,
index_t  lv,
index_t  v 
)
inline

Sets a vertex by facet and local vertex index.

Parameters
[in]fthe facet
[in]lvthe local vertex index in f
[in]vspecifies the lvth vertex of facet f
Precondition
lv < nb_vertices(f)

Definition at line 1065 of file mesh.h.

◆ triangulate()

void GEO::MeshFacets::triangulate ( )

Triangulates the facets.

Note
Attributes are zeroed

◆ vertex()

index_t GEO::MeshFacets::vertex ( index_t  f,
index_t  lv 
) const
inline

Gets a vertex by facet and local vertex index.

Parameters
[in]fthe facet
[in]lvthe local vertex index in f
Returns
the lvth vertex of facet f
Precondition
lv < nb_vertices(f)

Definition at line 1054 of file mesh.h.

Friends And Related Function Documentation

◆ tessellate_facets

void tessellate_facets ( Mesh M,
index_t  max_nb_vertices 
)
friend

Subdivides the facets with more than nb_vertices.

Parameters
[in]Ma reference to a surface mesh.
[in]max_nb_verticesmaximum number of vertices in a facet.

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