Visual Computing Library
|
The FaceContainer class represents a container of Face elements that can be used in a Mesh class. More...
#include <vclib/mesh/containers/face_container.h>
Public Types | |
using | Face = T |
using | FaceType = T |
using | FaceIterator = Base::ElementIterator |
using | ConstFaceIterator = Base::ConstElementIterator |
Public Member Functions | |
FaceContainer ()=default | |
Empty constructor that creates an empty container of Faces. | |
const FaceType & | face (uint i) const |
Returns a const reference of the Face at the i-th position in the Face Container of the Mesh, which will be the Face having index = i. | |
FaceType & | face (uint i) |
Returns a reference of the Face at the i-th position in the Face Container of the Mesh, which will be the Face having index = i. | |
uint | faceNumber () const |
Returns the number of non-deleted Faces contained in the Face container of the Mesh. | |
uint | faceContainerSize () const |
Returns the number of Faces (also deleted) contained in the Face container of the Mesh. | |
uint | deletedFaceNumber () const |
Returns the number of deleted Faces in the Face container, that is faceContainerSize() - faceNumber(). | |
uint | addFace () |
Add a Face to the container, returning its index. | |
template<typename... V> requires (sizeof...(args) >= 3) | |
uint | addFace (V... args) |
template<Range Rng> requires ( InputRange<Rng, typename Face::VertexType*> || InputRange<Rng, uint>) | |
uint | addFace (Rng &&r) |
uint | addFaces (uint n) |
Add an arbitrary number of n Faces, returning the id of the first added Face. | |
void | clearFaces () |
Clears the Face container of the Mesh, deleting all the Faces. | |
void | resizeFaces (uint n) |
Resizes the Face container to contain n Faces. | |
void | reserveFaces (uint n) |
Reserve a number of Faces in the container of Faces. This is useful when you know (or you have an idea) of how much Faces are going to add into a newly of existing mesh. Calling this function before any addFace() call will avoid unuseful reallocations of the container, saving execution time. | |
void | compactFaces () |
Compacts the FaceContainer, removing all the Faces marked as deleted. Faces indices will change accordingly. The function will automatically take care of updating all the Face pointers contained in the Mesh. | |
void | deleteFace (uint i) |
Marks as deleted the Face with the given id. | |
void | deleteFace (const FaceType *f) |
Marks as deleted the given Face, before asserting that the Face belongs to this container. | |
uint | faceIndexIfCompact (uint i) const |
This is an utility member function that returns the index of an element if the container would be compact, that is the number of non-deleted elements before the Face with the given index. | |
std::vector< uint > | faceCompactIndices () const |
Returns a vector that tells, for each actual Face index, the new index that the Face would have in a compacted container. For each deleted Face index, the value of the vector will be UINT_NULL. | |
void | updateFaceIndices (const std::vector< uint > &newIndices) |
Updates all the indices and pointers of the Faces of this container that are stored in any container of the mesh, according to the mapping stored in the newIndices vector, that tells for each old Face index, the new Face index. | |
FaceIterator | faceBegin (bool jumpDeleted=true) |
Returns an iterator to the beginning of the container. | |
FaceIterator | faceEnd () |
Returns an iterator to the end of the container. | |
ConstFaceIterator | faceBegin (bool jumpDeleted=true) const |
Returns a const iterator to the beginning of the container. | |
ConstFaceIterator | faceEnd () const |
Returns a const iterator to the end of the container. | |
auto | faces (bool jumpDeleted=true) |
Returns a small view object that allows to iterate over the Faces of the containers, providing two member functions begin() and end(). | |
auto | faces (bool jumpDeleted=true) const |
Returns a small view object that allows to iterate over the Faces of the containers, providing two member functions begin() and end(). | |
void | enableAllPerFaceOptionalComponents () |
Enables all the optional components associated to the Face type contained in the FaceContainer. | |
void | disableAllPerFaceOptionalComponents () |
Disables all the optional components associated to the Face type contained in the FaceContainer. | |
bool | isPerFaceAdjacentEdgesEnabled () const |
Checks if the Face Optional AdjacentEdges is enabled. | |
void | enablePerFaceAdjacentEdges () |
Enable the Optional AdjacentEdges of the Face. | |
void | disablePerFaceAdjacentEdges () |
Disables the Optional AdjacentEdges of the Face. | |
bool | isPerFaceAdjacentFacesEnabled () const |
Checks if the Face Optional AdjacentFaces is enabled. | |
void | enablePerFaceAdjacentFaces () |
Enable the Optional AdjacentFaces of the Face. | |
void | disablePerFaceAdjacentFaces () |
Disables the Optional AdjacentFaces of the Face. | |
bool | isPerFaceColorEnabled () const |
Checks if the Face Optional Color is enabled. | |
void | enablePerFaceColor () |
Enable the Optional Color of the Face. | |
void | disablePerFaceColor () |
Disables the Optional Color of the Face. | |
bool | isPerFaceMarkEnabled () const |
Checks if the Face Optional Mark is enabled. | |
void | enablePerFaceMark () |
Enable the Optional Mark of the Face. | |
void | disablePerFaceMark () |
Disables the Optional Mark of the Face. | |
bool | isPerFaceNormalEnabled () const |
Checks if the Face Optional Normal is enabled. | |
void | enablePerFaceNormal () |
Enable the Optional Normal of the Face. | |
void | disablePerFaceNormal () |
Disables the Optional Normal of the Face. | |
bool | isPerFacePrincipalCurvatureEnabled () const |
Checks if the Face Optional PrincipalCurvature is enabled. | |
void | enablePerFacePrincipalCurvature () |
Enable the Optional PrincipalCurvature of the Face. | |
void | disablePerFacePrincipalCurvature () |
Disables the Optional PrincipalCurvature of the Face. | |
bool | isPerFaceQualityEnabled () const |
Checks if the Face Optional Quality is enabled. | |
void | enablePerFaceQuality () |
Enable the Optional Quality of the Face. | |
void | disablePerFaceQuality () |
Disables the Optional Quality of the Face. | |
bool | isPerFaceWedgeColorsEnabled () const |
Checks if the Face Optional WedgeColors is enabled. | |
void | enablePerFaceWedgeColors () |
Enable the Optional WedgeColors of the Face. | |
void | disablePerFaceWedgeColors () |
Disables the Optional WedgeColors of the Face. | |
bool | isPerFaceWedgeTexCoordsEnabled () const |
Checks if the Face Optional WedgeTexCoords is enabled. | |
void | enablePerFaceWedgeTexCoords () |
Enable the Optional WedgeTexCoords of the Face. | |
void | disablePerFaceWedgeTexCoords () |
Disables the Optional WedgeTexCoords of the Face. | |
bool | hasPerFaceCustomComponent (const std::string &name) const |
Checks if Faces have a custom component with the given name. | |
std::vector< std::string > | perFaceCustomComponentNames () const |
Returns a vector containing all the names of the custom components of any type associated to the Face Element. | |
template<typename K > requires face::HasCustomComponents<T> | |
bool | isPerFaceCustomComponentOfType (const std::string &name) const |
Checks if the custom component of the Face Element having the given name has the same type of the given template argument type of this function. | |
std::type_index | perFaceCustomComponentType (const std::string &name) const |
Returns the std::type_index of the custom component of the Face Element having the given input name. | |
template<typename K > requires face::HasCustomComponents<T> | |
std::vector< std::string > | perFaceCustomComponentNamesOfType () const |
Returns a vector containing all the names of the custom components associated to the Edge Element having the same type of the given template argument type of this function. | |
template<typename K > requires face::HasCustomComponents<T> | |
void | addPerFaceCustomComponent (const std::string &name) |
Adds a custom component of type K to the Face, having the given name. | |
void | deletePerFaceCustomComponent (const std::string &name) |
Deletes the custom component of the given name from the Face Element. | |
template<typename K > requires face::HasCustomComponents<T> | |
CustomComponentVectorHandle< K > | perFaceCustomComponentVectorHandle (const std::string &name) |
Returns a vector handle to the custom component having the type K and the given name. | |
template<typename K > requires face::HasCustomComponents<T> | |
ConstCustomComponentVectorHandle< K > | perFaceCustomComponentVectorHandle (const std::string &name) const |
Returns a const vector handle to the custom component having type K and the given name. | |
Protected Member Functions | |
template<typename OthMesh > | |
void | manageImportTriFromPoly (const OthMesh &m) |
This function manages the case where we try to import into a TriMesh a PolyMesh Faces have been already imported, but without vertex pointers and other components that depend on the number of vertices (e.g. wedges) | |
Private Types | |
using | FaceContainerType = FaceContainer< T > |
using | Base = ElementContainer< T > |
Private Member Functions | |
void | addFaceHelper (T &f) |
template<typename... V> | |
void | addFaceHelper (T &f, typename T::VertexType *v, V... args) |
template<typename... V> | |
void | addFaceHelper (T &f, uint vid, V... args) |
Static Private Member Functions | |
template<typename MFaceType , typename VertexType , typename MVertexType > | |
static void | importTriPointersHelper (FaceType &f, const MFaceType &mf, VertexType *base, const MVertexType *mvbase, const std::vector< uint > &tris, uint basetri) |
The FaceContainer class represents a container of Face elements that can be used in a Mesh class.
This class adds a container (vector) of Faces to the Mesh, making available the accessors members to them and their components.
It provides all the add, delete, reserve, compact and other functions to manage the Faces, plus the iterators and views to iterate over them. It also provides the functions to enable and disable the optional components of the Faces.
T | The type of the Face elements. It must satisfy the FaceConcept. |
|
inline |
Add a Face to the container, returning its index.
If the call of this function will cause a reallocation of the FaceContainer, the function will automatically take care of updating all the Face pointers contained in the Mesh.
|
inline |
Add an arbitrary number of n Faces, returning the id of the first added Face.
This means that, if you want to add 5 Faces and this member function returns 4, the added Faces will have id from 4 to id 8 included.
If the call of this function will cause a reallocation of the FaceContainer, the function will automatically take care of updating all the Face pointers contained in the Mesh.
n | the number of Faces to add to the mesh. |
|
inline |
|
inline |
Clears the Face container of the Mesh, deleting all the Faces.
The contained faces are actually removed from the container, not only marked as deleted. Therefore, the container will have size 0 (faceContainerSize() == 0
) after the call of this function.
|
inline |
Returns the number of deleted Faces in the Face container, that is faceContainerSize() - faceNumber().
|
inline |
Marks as deleted the given Face, before asserting that the Face belongs to this container.
This member function does not perform any reallocation of the Faces: the deleted Faces will stay in the Face Container, but will be marked as deleted.
Deleted Faces are automatically jumped by the iterators provided by the Face Container.
[in] | f | the pointer of the Face that will be marked as deleted. |
|
inline |
Marks as deleted the Face with the given id.
This member function does not perform any reallocation of the Faces: the deleted Faces will stay in the Face Container, but will be marked as deleted.
Deleted Faces are automatically jumped by the iterators provided by the Face Container.
[in] | i | the id of the Face that will be marked as deleted. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Disables the Optional PrincipalCurvature of the Face.
|
inline |
|
inline |
|
inline |
|
inline |
Enable the Optional AdjacentEdges of the Face.
|
inline |
Enable the Optional AdjacentFaces of the Face.
|
inline |
|
inline |
|
inline |
|
inline |
Enable the Optional PrincipalCurvature of the Face.
|
inline |
|
inline |
Enable the Optional WedgeColors of the Face.
|
inline |
Enable the Optional WedgeTexCoords of the Face.
|
inline |
Returns a reference of the Face at the i-th position in the Face Container of the Mesh, which will be the Face having index = i.
This function does not perform any sanity check: if i is less than faceContainerSize(), this function will return a valid Face reference (note that the Face may have been flagged as deleted).
[in] | i | the index of the Face that will be returned. |
|
inline |
Returns a const reference of the Face at the i-th position in the Face Container of the Mesh, which will be the Face having index = i.
This function does not perform any sanity check: if i is less than faceContainerSize(), this function will return a valid Face reference (note that the Face may have been flagged as deleted).
[in] | i | the index of the Face that will be returned. |
|
inline |
Returns an iterator to the beginning of the container.
The iterator is automatically initialized to jump deleted Faces of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Faces. |
|
inline |
Returns a const iterator to the beginning of the container.
The iterator is automatically initialized to jump deleted Faces of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Faces. |
|
inline |
Returns a vector that tells, for each actual Face index, the new index that the Face would have in a compacted container. For each deleted Face index, the value of the vector will be UINT_NULL.
This is useful if you need to know the indices of the Faces that they would have in a compact container, without considering the deleted ones.
|
inline |
Returns the number of Faces (also deleted) contained in the Face container of the Mesh.
If faceNumber() != faceContainerSize(), it means that there are some Faces that are flagged as deleted.
|
inline |
Returns an iterator to the end of the container.
|
inline |
Returns a const iterator to the end of the container.
|
inline |
This is an utility member function that returns the index of an element if the container would be compact, that is the number of non-deleted elements before the Face with the given index.
Complexity: O(n), with n the number of Faces in the container.
This function does not perform any sanity check on the given index.
[in] | i | the index of a Face of the container. |
|
inline |
Returns the number of non-deleted Faces contained in the Face container of the Mesh.
If faceNumber() != faceContainerSize(), it means that there are some Faces that are flagged as deleted.
|
inline |
Returns a small view object that allows to iterate over the Faces of the containers, providing two member functions begin() and end().
This member function is very useful when you want to iterate over the Faces using the C++ foreach syntax:
The iterator used to iterate over Faces is automatically initialized to jump deleted Faces of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Faces. |
|
inline |
Returns a small view object that allows to iterate over the Faces of the containers, providing two member functions begin() and end().
This member function is very useful when you want to iterate over the Faces using the C++ foreach syntax:
The iterator used to iterate over Faces is automatically initialized to jump deleted Faces of the container. You can change this option by calling this function with jumpDeleted=false
.
[in] | jumpDeleted | boolean that tells if the iterator should jump deleted Faces. |
|
inline |
Checks if Faces have a custom component with the given name.
This function does not take into account the type of the custom component.
|
inline |
|
inline |
|
inline |
|
inline |
Checks if the custom component of the Face Element having the given name has the same type of the given template argument type of this function.
For example, the following code checks if the component called cc
is of type double
:
K | the type of the custom component to check. |
[in] | name | the name of the custom component to check. |
std::out_of_range | if no custom component of the given name was found. |
true
if the custom component is of the same type of the template argument.
|
inline |
|
inline |
|
inline |
Checks if the Face Optional PrincipalCurvature is enabled.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns a vector containing all the names of the custom components associated to the Edge Element having the same type of the given template argument type of this function.
For example, the following code gets a vector containing all the custom components of type double
:
K | the type of the custom component names. |
|
inline |
Returns the std::type_index of the custom component of the Face Element having the given input name.
[in] | name | the name of the custom component to get the std::type_index from. |
std::out_of_range | if no custom component of the given name was found. |
|
inline |
Returns a vector handle to the custom component having the type K and the given name.
The handle can be used like a normal std::vector, but does not have access to the modifiers member functions (resize, push_back...). The handle contains references to the custom component, therefore you can modify the custom component by modifying the element of the handle vector normally. Since the handle stores references, there are no copies performed when calling this function.
For example, assuming that the mesh has a Face custom component named cc
of type int:
Using handles allows to access more efficiently to custom components rather accessing from an element object. However, note that references are binded to the container of the mesh.
K | the type of the custom component on which return the handle. |
[in] | name | name of the custom component on which return the handle. |
std::out_of_range | if no custom component of the given name was found. |
|
inline |
Returns a const vector handle to the custom component having type K and the given name.
The handle can be used like a normal std::vector, but does not have access to the modifiers member functions (resize, push_back...). The handle contains const references to the custom component, therefore you can access to the custom component by accessing the element of the handle vector normally. Since the handle stores references, there are no copies performed when calling this function.
For example, assuming that the mesh has a Face custom component named cc
of type int:
Using handles allows to access more efficiently to custom components rather accessing from an element object. However, note that references are binded to the container of the mesh.
K | the type of the custom component on which return the handle. |
[in] | name | name of the custom component on which return the handle. |
|
inline |
Reserve a number of Faces in the container of Faces. This is useful when you know (or you have an idea) of how much Faces are going to add into a newly of existing mesh. Calling this function before any addFace() call will avoid unuseful reallocations of the container, saving execution time.
The filosofy of this function is similar to the one of the reserve() function of the std::vector class.
If the call of this function will cause a reallocation of the Face container, the function will automatically take care of updating all the Face pointers contained in the Mesh.
n | the new capacity of the Face container. |
|
inline |
Resizes the Face container to contain n
Faces.
If the new size is greater than the old one, new Faces are added to the container, and a reallocation may happen. If the new size is smaller than the old one, the container will keep its first non-deleted n
Faces, and the remaining Faces are marked as deleted.
If the call of this function will cause a reallocation of the Face container, the function will automatically take care of updating all the Face pointers contained in the Mesh.
n
is relative to the number of non-deleted Faces, not to the size of the Face container. For example, if you have a mesh with 10 Faces and faceContainerSize() == 20, calling resizeFaces(5) will not cause a reallocation of the container, but will mark as deleted the least 5 non-deleted Faces of the container. In the same scenario, calling resizeFaces(15) will result in a Face container having 15 Faces and faceContainerSize() == 25. The latest 5 Faces will be the newly added.[in] | n | the new size of the Face container. |
|
inline |
Updates all the indices and pointers of the Faces of this container that are stored in any container of the mesh, according to the mapping stored in the newIndices vector, that tells for each old Face index, the new Face index.
This function is useful when delete some Faces, and you want to update the indices/pointers stored in all the containers of the mesh accordingly.
E.g. Supposing you deleted a set of Faces, you can give to this function the vector telling, for each one of the old Face indices, the new Face index (or UINT_NULL if you want to leave it unreferenced). This function will update all the pointers stored in the mesh containers accordingly (if they store adjacencies to the Faces).