Bayeux  3.4.1
Core Foundation library for SuperNEMO
face_identifier.h
Go to the documentation of this file.
1 /* Author(s): François Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2015-03-16
4  * Last modified: 2016-11-12
5  *
6  * License: GPL3
7  *
8  * Description:
9  *
10  * The identifier of a face in a simple or composite shape
11  *
12  */
13 
14 #ifndef GEOMTOOLS_FACE_IDENTIFIER_H
15 #define GEOMTOOLS_FACE_IDENTIFIER_H 1
16 
17 // Standard library:
18 #include <iostream>
19 #include <string>
20 #include <vector>
21 
22 // Third party:
23 // - Boost:
24 #include <boost/cstdint.hpp>
25 // - Bayeux/datatools:
26 #include <datatools/bit_mask.h>
27 #include <datatools/i_tree_dump.h>
28 
29 namespace geomtools {
30 
34  {
35  public:
36 
38  enum mode_type {
43  };
44 
45  static const uint32_t FACE_BITS_NONE = 0x0;
46  static const uint32_t FACE_BITS_ANY = 0xFFFFFFFF;
47 
48  // Range [0,1,2.... MAX, ANY, NONE]
49  static const uint32_t FACE_INDEX_NONE = 0xFFFFFFFF;
50  static const uint32_t FACE_INDEX_MIN = 0;
51  static const uint32_t FACE_INDEX_MAX = 0xFFFFFFFD;
52  static const uint32_t FACE_INDEX_ANY = 0xFFFFFFFE;
53 
54  // Range [0,1,2.... MAX, ANY, NONE]
55  static const uint32_t PART_INDEX_NONE = 0xFFFFFFFF;
56  static const uint32_t PART_INDEX_MIN = 0;
57  static const uint32_t PART_INDEX_DEFAULT = PART_INDEX_MIN;
58  static const uint32_t PART_INDEX_MAX = 0xFFFFFFFD;
59  static const uint32_t PART_INDEX_ANY = 0xFFFFFFFE;
60 
63 
65  face_identifier(uint32_t face_info_, mode_type mode_ = MODE_FACE_BITS);
66 
68  bool is_valid() const;
69 
71  bool is_ok() const;
72 
74  bool is_unique() const;
75 
77  bool is_many() const;
78 
80  bool is_none() const;
81 
84  void invalidate();
85 
87  void reset();
88 
90  mode_type get_mode() const;
91 
93  bool has_mode() const;
94 
96  bool is_face_bits_mode() const;
97 
99  bool is_face_index_mode() const;
100 
102  uint32_t get_parts_depth() const;
103 
105  bool has_parts() const;
106 
108  bool has_part(unsigned int depth_) const;
109 
111  bool is_invalid_part(unsigned int depth_) const;
112 
114  bool is_any_part(unsigned int depth_) const;
115 
117  bool match_part(unsigned int depth_, uint32_t part_) const;
118 
120  void reset_part(unsigned int depth_);
121 
123  void set_any_part(unsigned int depth_);
124 
126  void set_any_parts();
127 
129  void set_part(unsigned int depth_, uint32_t);
130 
132  uint32_t get_part(unsigned int depth_) const;
133 
135  void prepend_part(uint32_t part_);
136 
138  void append_part(uint32_t part_);
139 
141  void append_parts(const std::vector<uint32_t> & parts_);
142 
144  bool can_inherit_parts(unsigned int depth_ = 1) const;
145 
147  void inherit_parts(face_identifier & fid_, unsigned int depth_ = 1) const;
148 
150  const std::vector<uint32_t> & get_parts() const;
151 
153  bool is_face_bits_valid() const;
154 
156  void set_face_bits_any();
157 
159  bool is_face_bits_any() const;
160 
162  bool has_face_bits(uint32_t) const;
163 
165  bool has_face_bit(uint32_t) const;
166 
168  void set_face_bits(uint32_t bits_);
169 
171  void set_face_bit(uint32_t bit_);
172 
174  uint32_t get_face_bits() const;
175 
177  void reset_face_bits();
178 
180  bool match_face_bits(uint32_t bits_) const;
181 
183  void reset_face_index();
184 
186  void set_face_index(uint32_t);
187 
189  uint32_t get_face_index() const;
190 
192  void set_face_index_any();
193 
195  bool is_face_index_any() const;
196 
198  bool is_face_index_valid() const;
199 
201  bool match_face_index(uint32_t index_) const;
202 
204  void to_string(std::string & word_) const;
205 
207  std::string to_string() const;
208 
210  bool parse(const std::string & from_);
211 
213  bool match(const face_identifier & fid_) const;
214 
216  static const face_identifier & face_bits_any();
217 
219  static const face_identifier & face_index_any();
220 
222  static const face_identifier & face_invalid();
223 
225  friend std::ostream & operator<<(std::ostream & out_, const face_identifier & face_id_);
226 
228  virtual void tree_dump(std::ostream & out_ = std::clog,
229  const std::string & title_ = "",
230  const std::string & indent_ = "",
231  bool inherit_ = false) const;
232 
233  protected:
234 
236  void _set_defaults();
237 
238  private:
239 
240  mode_type _mode_;
241  std::vector<uint32_t> _parts_;
242  uint32_t _face_bits_;
243  uint32_t _face_index_;
244 
245  };
246 
247 } // end of namespace geomtools
248 
249 #endif // GEOMTOOLS_FACE_IDENTIFIER_H
250 
251 // Local Variables: --
252 // mode: c++ --
253 // c-file-style: "gnu" --
254 // tab-width: 2 --
255 // End: --
bool is_face_bits_valid() const
Set the face bits is valid.
void set_part(unsigned int depth_, uint32_t)
Set the part number.
void reset_part(unsigned int depth_)
Reset the part number.
void reset()
Invalidate the identifier.
bool match_face_bits(uint32_t bits_) const
Check if the face bits number matches some given value.
friend std::ostream & operator<<(std::ostream &out_, const face_identifier &face_id_)
Output streaming.
static const uint32_t PART_INDEX_NONE
Special value for undefined/invalid part index.
Definition: face_identifier.h:55
void reset_face_index()
Reset the index of a face.
void append_parts(const std::vector< uint32_t > &parts_)
Append an array of parts.
static const uint32_t FACE_INDEX_NONE
Special value for undefined/invalid face index.
Definition: face_identifier.h:49
bool has_face_bits(uint32_t) const
Check if some face bits are active.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
bool can_inherit_parts(unsigned int depth_=1) const
Check if an inherited.
static const face_identifier & face_invalid()
Return a singleton invalid face identifier.
static const uint32_t bit01
Definition: bit_mask.h:28
static const uint32_t PART_INDEX_MIN
Special value for min part index.
Definition: face_identifier.h:56
Identifier of a face attached to a solid shape.
Definition: face_identifier.h:32
bool is_face_bits_any() const
Check if the bits address any face.
bool is_face_bits_mode() const
check if the identifier uses face bits
static const uint32_t PART_INDEX_ANY
Special value for any part index (wildcard)
Definition: face_identifier.h:59
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
uint32_t get_face_bits() const
Return the face bits.
bool is_many() const
Check if the identifier is valid and identifies several faces.
bool match_part(unsigned int depth_, uint32_t part_) const
Check if a part number matches a given value.
void set_face_bit(uint32_t bit_)
Set a single face bit.
void set_any_part(unsigned int depth_)
Set the part number to any value.
void _set_defaults()
Set default attributes values.
uint32_t get_part(unsigned int depth_) const
Return the part number.
bool has_mode() const
Check if the identifier has a valid mode.
void set_any_parts()
Set all part numbers to any value.
mode_type get_mode() const
Return the face identification mode.
face_identifier()
Default constructor.
bool has_face_bit(uint32_t) const
Check if a given face bit is active.
void set_face_index_any()
Set the bits to address any index.
void set_face_bits_any()
Set the bits to address any face.
static const uint32_t PART_INDEX_DEFAULT
Special value for default part index.
Definition: face_identifier.h:57
uint32_t get_parts_depth() const
Return the depth of the parts.
void reset_face_bits()
Reset the face bits.
void set_face_index(uint32_t)
Set the index of a face.
Invalid face identification mode.
Definition: face_identifier.h:39
void append_part(uint32_t part_)
Append a part.
Face identification uses identification bits.
Definition: face_identifier.h:40
void inherit_parts(face_identifier &fid_, unsigned int depth_=1) const
Build the inherited part.
static const face_identifier & face_bits_any()
Return a singleton face identifier with any bit.
const std::vector< uint32_t > & get_parts() const
Return the array of parts.
bool parse(const std::string &from_)
Parse.
static const uint32_t FACE_BITS_NONE
No valid or known face bit.
Definition: face_identifier.h:45
bool is_none() const
Check if the identifier is invalid or valid but identifies no face.
static const uint32_t FACE_INDEX_ANY
Special value for any face index (wildcard)
Definition: face_identifier.h:52
bool is_face_index_mode() const
Check if the identifier uses face index.
bool is_valid() const
Check the validity of the identifier.
bool match(const face_identifier &fid_) const
Check if a given face identifier matches the signature.
bool is_face_index_any() const
Check if the face identifier address any index.
bool has_part(unsigned int depth_) const
Check if some parts numbers are defined.
bool is_any_part(unsigned int depth_) const
Check if a part number matches the any value.
static const uint32_t PART_INDEX_MAX
Special value for max part index.
Definition: face_identifier.h:58
std::string to_string() const
Return a string.
Face identification uses indexing.
Definition: face_identifier.h:41
static const uint32_t FACE_BITS_ANY
All faces are selected.
Definition: face_identifier.h:46
bool has_parts() const
Return if the face identifier has parts.
static const uint32_t bit00
Definition: bit_mask.h:27
bool is_unique() const
Check if the identifier is valid and identifies an unique face.
Face identification uses any mode.
Definition: face_identifier.h:42
static const face_identifier & face_index_any()
Return a singleton face identifier with any index.
static const uint32_t FACE_INDEX_MAX
Special value for max face index.
Definition: face_identifier.h:51
static const uint32_t FACE_INDEX_MIN
Special value for min face index.
Definition: face_identifier.h:50
bool is_face_index_valid() const
Check if the face identifier address a valid index.
uint32_t get_face_index() const
Return the index of a face.
bool is_ok() const
Check if the identifier identifies some faces (unique or several/many)
void prepend_part(uint32_t part_)
Prepend a part.
bool match_face_index(uint32_t index_) const
Check if the face index matches some given value.
void set_face_bits(uint32_t bits_)
Set some face bits.
mode_type
Face identification mode.
Definition: face_identifier.h:38
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
bool is_invalid_part(unsigned int depth_) const
Check if a part number is invalid.