MeVisLab Toolbox Reference
WEMPrimitive.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #pragma once
14 
15 #include "MLWEMIncludes.h"
16 
17 ML_START_NAMESPACE
18 
20 
22 #define WEM_TRAVERSED_BIT 16
23 
25 
28 {
29 public:
31  WEMPrimitive(const WEMPrimitive &) = default;
32  WEMPrimitive(WEMPrimitive&& p) noexcept;
33  WEMPrimitive& operator=(const WEMPrimitive &) = default;
36  virtual ~WEMPrimitive() = default;
42  inline int getEntryNumber() const { return _entryNumber; }
44  inline void setEntryNumber(int e) { _entryNumber = e; }
46  inline bool isSet(unsigned int bit) const { return ((_bitFlag & (1 << bit)) != 0); }
48  inline void setFlag(unsigned int bit) { _bitFlag |= (1 << bit); }
50  inline void unsetFlag(unsigned int bit) { _bitFlag &= (~(1 << bit)); }
52  inline void clearFlag() { _bitFlag = 0; }
54  inline bool isTraversed() const { return ((_bitFlag & (1 << WEM_TRAVERSED_BIT)) != 0); }
56  void setTraversed(bool traversed);
58  inline int getHeapPosition() const { return _heapPosition; }
60  inline bool inHeap() const { return (_heapPosition != -1); }
62  inline void setHeapPosition(int heapPosition) { _heapPosition = heapPosition; }
64  inline double getHeapValue() const { return _heapValue; }
66  inline void setHeapValue(double heapValue) { _heapValue = heapValue; }
67 
68 protected:
69 
71  unsigned int _bitFlag;
77  double _heapValue;
78 };
79 
81 
83 {
84  static bool less(const WEMPrimitive &x, const WEMPrimitive &y);
85 };
86 
87 
88 
89 ML_END_NAMESPACE
#define MLWEM_EXPORT
Definition: MLWEMSystem.h:18
#define WEM_TRAVERSED_BIT
Traversed bit.
Definition: WEMPrimitive.h:22
This is the base class for the WEM elements nodes, edges, and faces.
Definition: WEMPrimitive.h:28
WEMPrimitive(WEMPrimitive &&p) noexcept
int getHeapPosition() const
Returns the heap position.
Definition: WEMPrimitive.h:58
double _heapValue
Element value, used for heap sorting.
Definition: WEMPrimitive.h:77
WEMPrimitive & operator=(const WEMPrimitive &)=default
int _entryNumber
Entry number in index vector, for easy deletion and reference.
Definition: WEMPrimitive.h:73
int getEntryNumber() const
Returns the entry number.
Definition: WEMPrimitive.h:42
void setFlag(unsigned int bit)
Sets the given bit-flag.
Definition: WEMPrimitive.h:48
void setTraversed(bool traversed)
Sets the traversed flag.
int _heapPosition
Heap position, same like entryNumber but for heaps.
Definition: WEMPrimitive.h:75
void resetPrimitive()
Resets the object to its default constructed state.
bool isTraversed() const
Returns whether this primitive has been traversed.
Definition: WEMPrimitive.h:54
virtual ~WEMPrimitive()=default
Standard destructor.
void setHeapPosition(int heapPosition)
Sets the heap position.
Definition: WEMPrimitive.h:62
unsigned int _bitFlag
Bit-wise flag for custom use.
Definition: WEMPrimitive.h:71
void setHeapValue(double heapValue)
Sets the heap value.
Definition: WEMPrimitive.h:66
WEMPrimitive & operator=(WEMPrimitive &&p) noexcept
void clearFlag()
Clears the bit-flag.
Definition: WEMPrimitive.h:52
void setEntryNumber(int e)
Sets the entry number.
Definition: WEMPrimitive.h:44
void unsetFlag(unsigned int bit)
Unsets the given bit-flag.
Definition: WEMPrimitive.h:50
double getHeapValue() const
Returns the heap value.
Definition: WEMPrimitive.h:64
bool inHeap() const
Returns whether this primitive is in the heap.
Definition: WEMPrimitive.h:60
bool isSet(unsigned int bit) const
Returns whether the bit-flag is set.
Definition: WEMPrimitive.h:46
WEMPrimitive(const WEMPrimitive &)=default
static bool less(const WEMPrimitive &x, const WEMPrimitive &y)