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

The Mark class is an utility class useful to un-mark components in constant time. More...

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

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

Public Member Functions

 Mark ()
 Constructor that initializes the mark to 0.
 
int mark () const
 Returns the value of the mark.
 
void resetMark ()
 Resets the mark to 0.
 
template<typename E >
bool hasSameMark (const E &e) const
 Checks if the current element/mesh has the same mark of the given input element/mesh e.
 
void incrementMark ()
 Increments the mark of the current element/mesh by 1.
 
void decrementMark ()
 Decrements the mark of the current element/mesh by 1.
 

Protected Member Functions

template<typename Element >
void importFrom (const Element &e, bool=true)
 
void serialize (std::ostream &os) const
 
void deserialize (std::istream &is)
 

Private Types

using Base = Component< Mark< ParentElemType, OPT >, CompId::MARK, int, ParentElemType, !std::is_same_v< ParentElemType, void >, OPT >
 

Private Member Functions

void init ()
 Initializes the mark to 0.
 
intmarkRef ()
 

Detailed Description

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

The Mark class is an utility class useful to un-mark components in constant time.

Its implementation is just an integer that can be incremented and decremented.

Assuming that two Elements (or a Mesh and an Element) have the Mark component: you can consider one of the elements "marked" if it has the same mark value of the other element/mesh.

Example: suppose that you have a Mesh with Vertex Elements, and both Mesh and Vertices have the Mark component. In initialization, all the elements are considered marked, because the elements have the same mark value of the Mesh. To un-mark all the vertices of the mesh:

m.incrementMark();
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43

Now all the vertices (and all the other elements) are un-marked because they have a different mark value w.r.t. the one of the mesh.

Then, if you want to mark the vertices having index 3 and 5:

m.vertex(3).incrementMark();
m.vertex(5).incrementMark();

And to check if vertices 4 and 5 are marked:

m.hasSameMark(m.vertex(4)); // or: m.vertex(4).hasSameMark(m)
m.hasSameMark(m.vertex(5)); // or: m.vertex(5).hasSameMark(m)
Note
This component can be both used for Elements and Meshes.
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

◆ hasSameMark()

template<typename ParentElemType = void, bool OPT = false>
template<typename E >
bool vcl::comp::Mark< ParentElemType, OPT >::hasSameMark ( const E &  e) const
inline

Checks if the current element/mesh has the same mark of the given input element/mesh e.

Template Parameters
Ethe type of the input element/mesh.
Parameters
ethe input element/mesh.

◆ init()

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

Initializes the mark to 0.

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.

◆ mark()

template<typename ParentElemType = void, bool OPT = false>
int vcl::comp::Mark< ParentElemType, OPT >::mark ( ) const
inline

Returns the value of the mark.

Returns
the value of the mark.

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