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

The TriangleBitFlags class represents a collection of 16 bits that will be part of a Triangle of a Mesh. More...

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

Inheritance diagram for vcl::comp::TriangleBitFlags< ParentElemType, OPT >:

Public Member Functions

 TriangleBitFlags ()
 Initializes the bits to false.
 
bool deleted () const
 Returns whether the current Triangle is deleted or not.
 
BitProxy< FTselected ()
 Accesses the 'selected' bit of this Triangle, returning a reference to it.
 
bool selected () const
 Returns whether the current Triangle is selected or not.
 
BitProxy< FTvisited ()
 Accesses the 'visited' bit of this Triangle, returning a reference to it.
 
bool visited () const
 Returns whether the current Triangle has been visited or not.
 
bool onBorder () const
 Returns whether the current Triangle is on border or not, by checking whether at least one of its three edges are on border or not.
 
BitProxy< FTedgeOnBorder (uint i)
 Accesses the 'onBorder' bit of the i-th edge of the triangle, returning a reference to it.
 
bool edgeOnBorder (uint i) const
 Returns whether the i-th edge of the current triangle is on border or not.
 
BitProxy< FTedgeSelected (uint i)
 Accesses the 'selected' bit of the i-th edge of the triangle, returning a reference to it.
 
bool edgeSelected (uint i) const
 Returns whether the i-th edge of the current triangle is selected or not.
 
BitProxy< FTedgeVisited (uint i)
 Accesses the 'visited' bit of the i-th edge of the triangle, returning a reference to it.
 
bool edgeVisited (uint i) const
 Returns whether the i-th edge of the current triangle is visited or not.
 
BitProxy< FTedgeFaux (uint i)
 Accesses the 'faux' bit of the i-th edge of the triangle, returning a reference to it.
 
bool edgeFaux (uint i) const
 Returns whether the i-th edge of the current triangle is faux or not.
 
bool userBit (uint bit) const
 Returns a reference to the value of the user bit of this Triangle given in input. The bit is checked to be less than the total number of assigned user bits, which in this class is 4.
 
BitProxy< FTuserBit (uint bit)
 Returns the boolean value of the user bit of this Triangle given in input. The bit is checked to be less than the total number of assigned user bits, which in this class is 4.
 
void resetBitFlags ()
 Unsets all the flags of this Triangle 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 __triangleBitFlags () 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.
 

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)
 

Private Types

enum  {
  DELETED = 0 , SELECTED = 1 , VISITED = 2 , BORDER0 = 3 ,
  EDGESEL0 = 6 , EDGEVIS0 = 9 , FAUX0 = 12
}
 
using Base = Component< TriangleBitFlags< ParentElemType, OPT >, CompId::BIT_FLAGS, BitSet< short >, ParentElemType, !std::is_same_v< ParentElemType, void >, OPT >
 
using FT = short
 

Private Member Functions

void init ()
 Initializes the bits to false.
 
BitSet< FT > & flags ()
 
BitSet< FTflags () const
 

Static Private Attributes

static const uint FIRST_USER_BIT = 15
 

Detailed Description

template<typename ParentElemType = void, bool OPT = false>
class vcl::comp::TriangleBitFlags< ParentElemType, OPT >

The TriangleBitFlags class represents a collection of 16 bits that will be part of a Triangle 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 Triangle Faces, and adds bits with particular meanings for triangles.

The bits have the following meaning:

  • 0: deleted: if the current Triangle has been deleted - read only
  • 1: selected: if the current Triangle has been selected
  • 2: visited: if the current Triangle has been visited (useful for some visit algorithms)
  • from 3 to 5: edge border: if the current Triangle has the i-th edge (i in [0, 2]) on border
  • from 6 to 8: edge selection: if the current Triangle has the i-th edge (i in [0, 2]) selected
  • from 9 to 11: edge visited: if the current Triangle has the i-th edge (i in [0, 2]) visited
  • from 12 to 14: edge faux: if the current Triangle has the i-th edge (i in [0, 2]) marked as faux
  • 15: user bit that can have custom meanings to the user

This class provides 1 user bit, that can be accessed using the member function userBit(uint i) with position 0.

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 TriangleBitFlags component, you'll be able to access to this component member functions from f:

v.edgeSelected(1) = true;
Template Parameters
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.

Member Function Documentation

◆ deleted()

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

Returns whether the current Triangle is deleted or not.

Returns
true if the Triangle is deleted, false otherwise.

◆ edgeFaux() [1/2]

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

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

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

◆ edgeFaux() [2/2]

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

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

Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
true if the i-th edge of the triangle is faux, false otherwise.

◆ edgeOnBorder() [1/2]

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

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

Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
a reference to the 'onBorder' bit of the i-th edge of the triangle.

◆ edgeOnBorder() [2/2]

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

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

Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
true if the i-th edge of the triangle is on border, false otherwise.

◆ edgeSelected() [1/2]

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

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

Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
a reference to the 'selected' bit of the i-th edge of the triangle.

◆ edgeSelected() [2/2]

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

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

Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
true if the i-th edge of the triangle is selected, false otherwise.

◆ edgeVisited() [1/2]

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

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

Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
a reference to the 'visited' bit of the i-th edge of the triangle.

◆ edgeVisited() [2/2]

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

Returns whether the i-th edge of the current triangle is visited or not.

Parameters
[in]ithe index of the edge, it must be less than 3.
Returns
true if the i-th edge of the triangle is visited, false otherwise.

◆ exportFlagsToVCGFormat()

template<typename ParentElemType = void, bool OPT = false>
int vcl::comp::TriangleBitFlags< 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<typename ParentElemType = void, bool OPT = false>
void vcl::comp::TriangleBitFlags< 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<typename ParentElemType = void, bool OPT = false>
void vcl::comp::TriangleBitFlags< 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<typename ParentElemType = void, bool OPT = false>
bool vcl::comp::TriangleBitFlags< ParentElemType, OPT >::onBorder ( ) const
inline

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

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

◆ selected() [1/2]

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

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

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

◆ selected() [2/2]

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

Returns whether the current Triangle is selected or not.

Returns
true if the Triangle is selected, false otherwise.

◆ userBit() [1/2]

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

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

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

◆ userBit() [2/2]

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

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

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

◆ visited() [1/2]

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

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

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

◆ visited() [2/2]

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

Returns whether the current Triangle has been visited or not.

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

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