Visual Computing Library
Loading...
Searching...
No Matches
vcl::comp::PolygonBitFlags< N, ParentElemType, OPT > Class Template Reference

The PolygonBitFlags class represents a collection of 8 bits plus 8 bits for each edge that will be part of a generic Polygonal Face of a Mesh. More...

#include <vclib/mesh/components/polygon_bit_flags.h>

Inheritance diagram for vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >:

Public Member Functions

 PolygonBitFlags ()
 Initializes all the bits to false.
 
bool deleted () const
 Returns whether the current Polygon is deleted or not.
 
BitProxy< FTselected ()
 Accesses the 'selected' bit of this Polygon, returning a reference to it.
 
bool selected () const
 Returns whether the current Polygon is selected or not.
 
BitProxy< FTvisited ()
 Accesses the 'visited' bit of this Polygon, returning a reference to it.
 
bool visited () const
 Returns whether the current Polygon has been visited or not.
 
bool onBorder () const
 Returns whether the current Polygon is on border or not, by checking whether at least one of its edges are on border or not.
 
BitProxy< FTedgeOnBorder (uint i)
 Accesses the 'onBorder' bit of the i-th edge of the polygon, returning a reference to it.
 
bool edgeOnBorder (uint i) const
 Returns whether the i-th edge of the current Polygon is on border or not.
 
BitProxy< FTedgeSelected (uint i)
 Accesses the 'selected' bit of the i-th edge of the polygon, returning a reference to it.
 
bool edgeSelected (uint i) const
 Returns whether the i-th edge of the current Polygon is selected or not.
 
BitProxy< FTedgeVisited (uint i)
 Accesses the 'visited' bit of the i-th edge of the polygon, returning a reference to it.
 
bool edgeVisited (uint i) const
 Returns whether the i-th edge of the current Polygon has been visited or not.
 
BitProxy< FTedgeFaux (uint i)
 Accesses the 'faux' bit of the i-th edge of the polygon, returning a reference to it.
 
bool edgeFaux (uint i) const
 Returns whether the i-th edge of the current Polygon is faux or not.
 
bool userBit (uint bit) const
 Returns the boolean value of the user bit of this Polygon given in input. The bit is checked to be less than the total number of assigned user bits, which in this class is 2.
 
BitProxy< FTuserBit (uint bit)
 Returns a reference to the value of the user bit of this Polygon given in input. The bit is checked to be less than the total number of assigned user bits, which in this class is 2.
 
bool edgeUserBit (uint i, uint bit) const
 Returns the boolean value of the user bit of the i-th edge of this Polygon given in input. The bit is checked to be less than the total number of assigned edge user bits, which in this class is 5.
 
BitProxy< FTedgeUserBit (uint i, uint bit)
 Returns a reference to the value of the user bit of the i-th edge of this Polygon given in input. The bit is checked to be less than the total number of assigned edge user bits, which in this class is 5.
 
void resetBitFlags ()
 Unsets all the flags of this Polygon and sets them to false, except the deleted flag, which needs to be manually reset.
 
void importFlagsFromVCGFormat (int f)
 Sets all the flags of this element to the values contained in the integer input parameter, that represents the bit flags of the VCG library.
 
int exportFlagsToVCGFormat () const
 Returns the bit flags of this element in the format of the VCG library.
 
void __polygonBitFlags () const
 

Static Public Attributes

static const uint USER_BITS_NUMBER = sizeof(FT) * 8 - FIRST_USER_BIT
 Static number of bits that can have custom meanings to the user.
 
static const uint EDGE_USER_BITS_NUMBER
 Static number of bits for each edge that can have custom meanings to the user.
 
- Static Public Attributes inherited from vcl::comp::ContainerComponent< DerivedComponent, COMP_ID, T, N, AdditionalData, ParentElemType, VERT, OPT, TTVN, PointedTypes >
static const bool TIED_TO_VERTEX_NUMBER = TTVN
 Boolean that tells if this component stores a container having its size tied to the number of the vertices of the Element.
 
static const int SIZE = N
 

Protected Member Functions

BitProxy< FTdeletedBit ()
 
template<typename Element >
void importFrom (const Element &e, bool=true)
 
void serialize (std::ostream &os) const
 
void deserialize (std::istream &is)
 
void resize (uint n)
 
void pushBack (BitSet< FT > f=BitSet< FT >())
 
void insert (uint i, BitSet< FT > f=BitSet< FT >())
 
void erase (uint i)
 
void clear ()
 
- Protected Member Functions inherited from vcl::comp::ContainerComponent< DerivedComponent, COMP_ID, T, N, AdditionalData, ParentElemType, VERT, OPT, TTVN, PointedTypes >
void init ()
 
Vector< T, N > & container ()
 
const Vector< T, N > & container () const
 
template<typename AdDt = AdditionalData>
requires (HAS_ADDITIONAL_DATA)
AdDtadditionalData ()
 
template<typename AdDt = AdditionalData>
requires (HAS_ADDITIONAL_DATA)
const AdDtadditionalData () const
 

Private Types

enum  { DELETED = 0 , SELECTED = 1 , VISITED = 2 , FAUX0 = 3 }
 
enum  { EDGEBORD = 0 , EDGESEL = 1 , EDGEVIS = 2 }
 
using FT = char
 
using Base = ContainerComponent< PolygonBitFlags< N, ParentElemType, OPT >, CompId::BIT_FLAGS, BitSet< FT >, N, BitSet< FT >, ParentElemType, !std::is_same_v< ParentElemType, void >, OPT, true >
 

Private Member Functions

void init ()
 Initializes the bits to false.
 
BitSet< FT > & flags ()
 
const BitSet< FT > & flags () const
 
Vector< BitSet< FT >, -1 > & edgeFlags ()
 
const Vector< BitSet< FT >, -1 > & edgeFlags () const
 

Static Private Attributes

static const uint FIRST_USER_BIT = 6
 
static const uint FIRST_EDGE_USER_BIT = 3
 

Additional Inherited Members

- Protected Types inherited from vcl::comp::ContainerComponent< DerivedComponent, COMP_ID, T, N, AdditionalData, ParentElemType, VERT, OPT, TTVN, PointedTypes >
using Iterator = Vector< T, N >::Iterator
 
using ConstIterator = Vector< T, N >::ConstIterator
 

Detailed Description

template<int N, typename ParentElemType = void, bool OPT = false>
class vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >

The PolygonBitFlags class represents a collection of 8 bits plus 8 bits for each edge that will be part of a generic Polygonal Face of a Mesh.

This is a specialization class of the BitFlags component, meaning that it can be used in sostitution to that component. The difference is that this class is meant to be used on Polygonal Faces, and adds bits with particular meanings for polygons.

This class also provides 3 flags for faux edges. These flags are added just to make portable all the algorithms that use faux flags also for PolygonMeshes. However, these flags should be used only when the mesh is a Triangle mesh, that is when each face has vertexNumber() == 3.

The bits have the follwing meaning:

  • 0: deleted: if the current Polygon has been deleted - read only
  • 1: selected: if the current Polygon has been selected
  • 2: visited: if the current Polygon has been visited (useful for some visit algorithms)
  • from 3 to 5: edge faux: if the current Face has is i-th edge (i in [0, 2]) marked as faux
  • from 6 to 7: user bits that can have custom meanings to the user

This class provides 2 user bits, that can be accessed using the member function userBit(uint i) with position in the interval [0, 1].

Additionally, this class provides the following bits for each edge of the Polygonal Face:

  • 0: edge border: if the current Polygonal face has the i-th edge on border
  • 1: edge selection: if the current Polygonal face has the i-th edge selected
  • 2: edge visited: if the i-th edge of the current Polygonal face has been visited
  • from 3 to 7: user bits of the i-th edge that can have custo meanings to the user

The member functions of this class will be available in the instance of any Element that will contain this component.

For example, if you have a Face Element f that has the PolygonBitFlags component, you'll be able to access to this component member functions from f:

v.isAnyEdgeOnBorder();
Note
This component is Tied To Vertex Number: it means that the size of the container, if dynamic, will change automatically along the Vertex Number of the Component. For further details check the documentation of the ContainerComponent class.
Template Parameters
NThe size of the container, that will represent the number of storable bit flags for each edge of the Polygon. If negative, the container is dynamic and tied to the vertex number.
ParentElemTypeThis template argument must be void if the component needs to be stored horizontally, or the type of the parent element that will contain this component if the component needs to be stored vertically.
OPTIf true, the component will be optional. This argument is considered only if the component is stored vertically.

Constructor & Destructor Documentation

◆ PolygonBitFlags()

template<int N, typename ParentElemType = void, bool OPT = false>
vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::PolygonBitFlags ( )
inline

Initializes all the bits to false.

If the Edge flags container size is static, initializes all the Edge flags to false, otherwise the container will be empty.

Member Function Documentation

◆ deleted()

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::deleted ( ) const
inline

Returns whether the current Polygon is deleted or not.

Returns
true if the Polygon is deleted, false otherwise.

◆ edgeFaux() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeFaux ( uint  i)
inline

Accesses the 'faux' bit of the i-th edge of the polygon, returning a reference to it.

Note
The 'faux' bit is used to just for portability with triangle meshes that are stored in polygonal meshes. However, these flags should be used only when the mesh is a Triangle mesh, that is when each face has vertexNumber()== 3.
Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
a reference to the 'faux' bit of the i-th edge of the polygon.

◆ edgeFaux() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeFaux ( uint  i) const
inline

Returns whether the i-th edge of the current Polygon is faux or not.

Note
The 'faux' bit is used to just for portability with triangle meshes that are stored in polygonal meshes. However, these flags should be used only when the mesh is a Triangle mesh, that is when each face has vertexNumber()== 3.
Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
true if the i-th edge of the Polygon is faux, false otherwise.

◆ edgeOnBorder() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeOnBorder ( uint  i)
inline

Accesses the 'onBorder' bit of the i-th edge of the polygon, returning a reference to it.

Parameters
[in]ithe index of the edge.
Returns
a reference to the 'onBorder' bit of the i-th edge of the polygon.

◆ edgeOnBorder() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeOnBorder ( uint  i) const
inline

Returns whether the i-th edge of the current Polygon is on border or not.

Parameters
[in]ithe index of the edge.
Returns
true if the i-th edge of the Polygon is on border, false otherwise.

◆ edgeSelected() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeSelected ( uint  i)
inline

Accesses the 'selected' bit of the i-th edge of the polygon, returning a reference to it.

Parameters
[in]ithe index of the edge.
Returns
a reference to the 'selected' bit of the i-th edge of the polygon.

◆ edgeSelected() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeSelected ( uint  i) const
inline

Returns whether the i-th edge of the current Polygon is selected or not.

Parameters
[in]ithe index of the edge.
Returns
true if the i-th edge of the Polygon is selected, false otherwise.

◆ edgeUserBit() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeUserBit ( uint  i,
uint  bit 
)
inline

Returns a reference to the value of the user bit of the i-th edge of this Polygon given in input. The bit is checked to be less than the total number of assigned edge user bits, which in this class is 5.

Parameters
[in]ithe index of the edge.
[in]bitthe position of the bit, in the interval [0 - 4].
Returns
a reference to the desired user bit.

◆ edgeUserBit() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeUserBit ( uint  i,
uint  bit 
) const
inline

Returns the boolean value of the user bit of the i-th edge of this Polygon given in input. The bit is checked to be less than the total number of assigned edge user bits, which in this class is 5.

Parameters
[in]ithe index of the edge.
[in]bitthe position of the bit, in the interval [0 - 4].
Returns
true if the required bit is enabled, false otherwise.

◆ edgeVisited() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeVisited ( uint  i)
inline

Accesses the 'visited' bit of the i-th edge of the polygon, returning a reference to it.

Parameters
[in]ithe index of the edge.
Returns
a reference to the 'visited' bit of the i-th edge of the polygon.

◆ edgeVisited() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::edgeVisited ( uint  i) const
inline

Returns whether the i-th edge of the current Polygon has been visited or not.

Parameters
[in]ithe index of the edge.
Returns
true if the i-th edge of the Polygon has been visited, false otherwise.

◆ exportFlagsToVCGFormat()

template<int N, typename ParentElemType = void, bool OPT = false>
int vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::exportFlagsToVCGFormat ( ) const
inline

Returns the bit flags of this element in the format of the VCG library.

Returns
an integer representing the bit flags of this element in the format of the VCG library.

◆ importFlagsFromVCGFormat()

template<int N, typename ParentElemType = void, bool OPT = false>
void vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::importFlagsFromVCGFormat ( int  f)
inline

Sets all the flags of this element to the values contained in the integer input parameter, that represents the bit flags of the VCG library.

Parameters
[in]fbit flags in the format of the VCG library.

◆ init()

template<int N, typename ParentElemType = void, bool OPT = false>
void vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::init ( )
inlineprivate

Initializes the bits to false.

It is made in the init function since the component could be not available during construction (e.g. if the component is optional and not enabled).

This member function is hidden by the element that inherits this class.

◆ onBorder()

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::onBorder ( ) const
inline

Returns whether the current Polygon is on border or not, by checking whether at least one of its edges are on border or not.

Returns
true if at least one edge of the Polygon is on border, false otherwise.

◆ selected() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::selected ( )
inline

Accesses the 'selected' bit of this Polygon, returning a reference to it.

Returns
a reference to the 'selected' bit of this Polygon.

◆ selected() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::selected ( ) const
inline

Returns whether the current Polygon is selected or not.

Returns
true if the Polygon is selected, false otherwise.

◆ userBit() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::userBit ( uint  bit)
inline

Returns a reference to the value of the user bit of this Polygon given in input. The bit is checked to be less than the total number of assigned user bits, which in this class is 2.

Parameters
[in]bitthe position of the bit, in the interval [0 - 1].
Returns
a reference to the desired user bit.

◆ userBit() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::userBit ( uint  bit) const
inline

Returns the boolean value of the user bit of this Polygon given in input. The bit is checked to be less than the total number of assigned user bits, which in this class is 2.

Parameters
[in]bitthe position of the bit, in the interval [0 - 1], that will be returned by reference.
Returns
true if the required bit is enabled, false otherwise.

◆ visited() [1/2]

template<int N, typename ParentElemType = void, bool OPT = false>
BitProxy< FT > vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::visited ( )
inline

Accesses the 'visited' bit of this Polygon, returning a reference to it.

Returns
a reference to the 'visited' bit of this Polygon.

◆ visited() [2/2]

template<int N, typename ParentElemType = void, bool OPT = false>
bool vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::visited ( ) const
inline

Returns whether the current Polygon has been visited or not.

Returns
true if the Polygon has been visited, false otherwise.

Member Data Documentation

◆ EDGE_USER_BITS_NUMBER

template<int N, typename ParentElemType = void, bool OPT = false>
const uint vcl::comp::PolygonBitFlags< N, ParentElemType, OPT >::EDGE_USER_BITS_NUMBER
static
Initial value:
=
sizeof(FT) * 8 - FIRST_EDGE_USER_BIT

Static number of bits for each edge that can have custom meanings to the user.


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