23#ifndef VCL_MESH_COMPONENTS_TRIANGLE_BIT_FLAGS_H
24#define VCL_MESH_COMPONENTS_TRIANGLE_BIT_FLAGS_H
26#include "bases/component.h"
28#include <vclib/concepts/mesh/components/bit_flags.h>
29#include <vclib/space/core/bit_set.h>
80template<
typename ParentElemType =
void,
bool OPT = false>
83 TriangleBitFlags<ParentElemType, OPT>,
87 !std::is_same_v<ParentElemType, void>,
90 using Base = Component<
95 !std::is_same_v<ParentElemType, void>,
100 static const uint FIRST_USER_BIT = 15;
131 if constexpr (!Base::IS_VERTICAL) {
146 void init() { flags().reset(); }
154 bool deleted()
const {
return flags()[DELETED]; }
167 bool selected()
const {
return flags()[SELECTED]; }
180 bool visited()
const {
return flags()[VISITED]; }
203 return flags()[BORDER0 +
i];
216 return flags()[BORDER0 +
i];
229 return flags()[EDGESEL0 +
i];
242 return flags()[EDGESEL0 +
i];
255 return flags()[EDGEVIS0 +
i];
268 return flags()[EDGEVIS0 +
i];
280 return flags()[FAUX0 +
i];
292 return flags()[FAUX0 +
i];
306 return flags()[
bit + FIRST_USER_BIT];
321 return flags()[
bit + FIRST_USER_BIT];
403 void __triangleBitFlags()
const {}
409 template<
typename Element>
410 void importFrom(
const Element& e,
bool =
true)
412 if constexpr (HasBitFlags<Element>) {
414 if constexpr (HasTriangleBitFlags<Element>) {
419 deletedBit() = e.deleted();
423 for (uint i = 0; i < UM; ++i)
425 if constexpr (HasPolygonBitFlags<Element>) {
427 for (uint i = 0; i < 3; ++i) {
437 void serialize(std::ostream& os)
const { flags().serialize(os); }
439 void deserialize(std::istream& is) { flags().deserialize(is); }
444 BitSet<FT>& flags() {
return Base::data(); }
446 BitSet<FT> flags()
const {
return Base::data(); }
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
The TriangleBitFlags class represents a collection of 16 bits that will be part of a Triangle of a Me...
Definition triangle_bit_flags.h:89
BitProxy< FT > edgeOnBorder(uint i)
Accesses the 'onBorder' bit of the i-th edge of the triangle, returning a reference to it.
Definition triangle_bit_flags.h:200
int exportFlagsToVCGFormat() const
Returns the bit flags of this element in the format of the VCG library.
Definition triangle_bit_flags.h:374
void importFlagsFromVCGFormat(int f)
Sets all the flags of this element to the values contained in the integer input parameter,...
Definition triangle_bit_flags.h:341
bool onBorder() const
Returns whether the current Triangle is on border or not, by checking whether at least one of its thr...
Definition triangle_bit_flags.h:188
bool visited() const
Returns whether the current Triangle has been visited or not.
Definition triangle_bit_flags.h:180
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 ...
Definition triangle_bit_flags.h:303
bool edgeVisited(uint i) const
Returns whether the i-th edge of the current triangle is visited or not.
Definition triangle_bit_flags.h:265
bool edgeFaux(uint i) const
Returns whether the i-th edge of the current triangle is faux or not.
Definition triangle_bit_flags.h:289
static const uint USER_BITS_NUMBER
Static number of bits that can have custom meanings to the user.
Definition triangle_bit_flags.h:122
bool selected() const
Returns whether the current Triangle is selected or not.
Definition triangle_bit_flags.h:167
void init()
Initializes the bits to false.
Definition triangle_bit_flags.h:146
bool edgeSelected(uint i) const
Returns whether the i-th edge of the current triangle is selected or not.
Definition triangle_bit_flags.h:239
BitProxy< FT > selected()
Accesses the 'selected' bit of this Triangle, returning a reference to it.
Definition triangle_bit_flags.h:161
BitProxy< FT > edgeVisited(uint i)
Accesses the 'visited' bit of the i-th edge of the triangle, returning a reference to it.
Definition triangle_bit_flags.h:252
BitProxy< FT > visited()
Accesses the 'visited' bit of this Triangle, returning a reference to it.
Definition triangle_bit_flags.h:174
BitProxy< FT > userBit(uint bit)
Returns the boolean value of the user bit of this Triangle given in input. The bit is checked to be l...
Definition triangle_bit_flags.h:318
void resetBitFlags()
Unsets all the flags of this Triangle and sets them to false, except the deleted flag,...
Definition triangle_bit_flags.h:328
BitProxy< FT > edgeSelected(uint i)
Accesses the 'selected' bit of the i-th edge of the triangle, returning a reference to it.
Definition triangle_bit_flags.h:226
bool deleted() const
Returns whether the current Triangle is deleted or not.
Definition triangle_bit_flags.h:154
BitProxy< FT > edgeFaux(uint i)
Accesses the 'faux' bit of the i-th edge of the triangle, returning a reference to it.
Definition triangle_bit_flags.h:277
TriangleBitFlags()
Initializes the bits to false.
Definition triangle_bit_flags.h:129
bool edgeOnBorder(uint i) const
Returns whether the i-th edge of the current triangle is on border or not.
Definition triangle_bit_flags.h:213