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

The BitFlags component class represents a collection of 8 bits that will be part of an Element (e.g. Vertex, Face, ...). More...

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

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

Public Member Functions

 BitFlags ()
 Initializes the bits to false.
 
bool deleted () const
 Returns whether the current Element is deleted or not.
 
BitProxy< FTselected ()
 Accesses the 'selected' bit of this Element, returning a reference to it.
 
bool selected () const
 Returns whether the current Element is selected or not.
 
BitProxy< FTonBorder ()
 Accesses the 'onBorder' bit of this Element, returning a reference to it.
 
bool onBorder () const
 Returns whether the current Element is on border or not.
 
BitProxy< FTvisited ()
 Accesses the 'visited' bit of this Element, returning a reference to it.
 
bool visited () const
 Returns whether the current Element has been visited or not.
 
bool userBit (uint bit) const
 Returns a reference to the value of the user bit of this Element 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 Element 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 Element 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.
 

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 , BORDER = 2 , VISITED = 3 }
 
using Base = Component< BitFlags< ParentElemType, OPT >, CompId::BIT_FLAGS, BitSet< char >, ParentElemType, !std::is_same_v< ParentElemType, void >, OPT >
 
using FT = char
 

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 = 4
 

Detailed Description

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

The BitFlags component class represents a collection of 8 bits that will be part of an Element (e.g. Vertex, Face, ...).

This Component (or a specialization, that is any class that satisfies the HasBitFlags concept) is mandatory into every Element of the mesh.

The bits have the following meaning:

  • 0: deleted: if the current Element has been deleted - read only
  • 1: selected: if the current Element has been selected
  • 2: border: if the current Element is on border
  • 3: visited: if the current Element has been visited (useful for some visit algorithms)
  • from 4 to 7: user bits that can have custom meanings to the user

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

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 Vertex Element v with the BitFlags component, you'll be able to access to this component member functions from v:

bool isD = v.deleted();
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
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::BitFlags< ParentElemType, OPT >::deleted ( ) const
inline

Returns whether the current Element is deleted or not.

Returns
true if the Element is deleted, false otherwise.

◆ exportFlagsToVCGFormat()

template<typename ParentElemType = void, bool OPT = false>
int vcl::comp::BitFlags< 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::BitFlags< 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::BitFlags< 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() [1/2]

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

Accesses the 'onBorder' bit of this Element, returning a reference to it.

Returns
a reference to the 'onBorder' bit of this Element.

◆ onBorder() [2/2]

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

Returns whether the current Element is on border or not.

Returns
true if the Element is on border, false otherwise.

◆ selected() [1/2]

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

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

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

◆ selected() [2/2]

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

Returns whether the current Element is selected or not.

Returns
true if the Element is selected, false otherwise.

◆ userBit() [1/2]

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

Returns the boolean value of the user bit of this Element 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::BitFlags< ParentElemType, OPT >::userBit ( uint  bit) const
inline

Returns a reference to the value of the user bit of this Element 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::BitFlags< ParentElemType, OPT >::visited ( )
inline

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

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

◆ visited() [2/2]

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

Returns whether the current Element has been visited or not.

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

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