8#include <kernel/geometry/intern/adaptive_refinement_utils.hpp>
9#include <kernel/geometry/intern/congruency_mapping.hpp>
10#include <kernel/geometry/intern/face_index_mapping.hpp>
11#include <kernel/geometry/intern/refinement_field.hpp>
12#include <kernel/geometry/subdivision_levels.hpp>
13#include <kernel/shape.hpp>
21 template<
typename Shape_>
22 static std::bitset<Shape::FaceTraits<Shape_, 0>::count>
23 orient_bitset(
const std::bitset<Shape::FaceTraits<Shape_, 0>::count>& bits,
int orientation)
25 using CongruencyMapping = CongruencyMapping<Shape_, 0>;
26 static constexpr const int num_bits = Shape::FaceTraits<Shape_, 0>::count;
28 std::bitset<num_bits> result = 0;
30 for(
int current_bit = 0; current_bit < num_bits; current_bit++)
32 if(bits[std::size_t(current_bit)])
34 std::size_t mapped_bit = std::size_t(CongruencyMapping::map(orientation, current_bit));
35 result[mapped_bit] =
true;
42 template<
typename Shape_>
47 std::bitset<num_vertices> bits;
55 explicit VertexMarking(std::uint64_t markings) : bits(markings)
59 explicit VertexMarking(std::bitset<num_vertices> markings) : bits(markings)
65 for(
int i = 0; i < num_vertices; i++)
67 bits[i] = (tuple[i] > 0);
73 return VertexMarking((1ULL << (std::size_t)num_vertices) - 1ULL);
79 return (bits |
other.bits) == bits;
82 bool is_vertex_marked(
int vertex)
const
84 ASSERT(vertex < num_vertices);
85 return bits[std::size_t(vertex)];
90 return (bits ^
other.bits).count();
94 template<
typename Shape_>
97 return lhs._markings == rhs._markings;
100 template<
typename Shape_>
101 bool operator!=(
const VertexMarking<Shape_>& lhs,
const VertexMarking<Shape_>& rhs)
103 return !(lhs == rhs);
106 template<
typename Shape_>
107 std::ostream& operator<<(std::ostream& stream,
const VertexMarking<Shape_>& type)
109 stream <<
"VertexMarkings<" << Shape_::name() <<
"> { markings: " << type.bits <<
" }";
113 template<
typename Shape_>
118 std::bitset<num_vertices> _type;
120 template<
typename S_>
123 template<
typename S_>
126 template<
typename T_>
127 friend struct std::hash;
143 const Intern::template RefinementFieldTuple<std::uint64_t, num_vertices>& markings) :
146 for(
int i = 0; i < num_vertices; i++)
148 _type[std::size_t(i)] = (markings[i] > 0);
152 bool is_full_refinement()
const
157 bool is_zero_refinement()
const
166 using Mapping = Intern::FaceIndexMapping<Shape_, dim_, 0>;
170 std::bitset<num_verts> result;
171 for(
int i(0); i < num_verts; i++)
173 auto vertex =
static_cast<Index>(Mapping::map(face, i));
174 result[std::size_t(i)] = _type[vertex];
210 Index to_number()
const
212 return _type.to_ulong();
215 Index num_marked()
const
217 return _type.count();
221 template<
typename Shape_>
224 return lhs._type == rhs._type;
227 template<
typename Shape_>
228 bool operator!=(
const StandardRefinementType<Shape_>& lhs,
const StandardRefinementType<Shape_>& rhs)
230 return !(lhs == rhs);
233 template<
typename Shape_>
234 std::ostream& operator<<(std::ostream& stream,
const StandardRefinementType<Shape_>& type)
236 stream <<
"StandardRefinementType<" << Shape_::name() <<
"> { type: " << type._type <<
" }";
242 std::uint64_t level = 0;
243 bool is_isolated =
false;
254 return a.level == b.level && a.is_isolated == b.is_isolated;
257 inline bool operator!=(
const IsolatedPointVertexMarking& a,
const IsolatedPointVertexMarking& b)
262 inline std::ostream& operator<<(std::ostream& stream,
const IsolatedPointVertexMarking& marking)
264 stream <<
"IsolatedPointVertexMarking{ level: " << unsigned(marking.level) <<
", is_isolated: " << marking.is_isolated <<
" }";
268 template<
typename Shape_>
273 std::bitset<num_vertices> _type;
276 template<
typename S_>
279 template<
typename S_>
282 template<
typename T_>
283 friend struct std::hash;
297 _type(markings.bits),
303 const Intern::template RefinementFieldTuple<IsolatedPointVertexMarking, num_vertices>& markings) :
307 for(
int i = 0; i < num_vertices; i++)
309 _type[std::size_t(i)] = (markings[i].level > 0);
310 _isolated = _isolated || markings[i].is_isolated;
314 bool is_full_refinement()
const
319 bool is_zero_refinement()
const
328 using Mapping = Intern::FaceIndexMapping<Shape_, dim_, 0>;
332 std::bitset<num_verts> result_bits;
334 for(
int i(0); i < num_verts; i++)
336 auto vertex =
static_cast<Index>(Mapping::map(face, i));
337 result_bits[std::size_t(i)] = _type[vertex];
374 Index to_number()
const
376 return _type.to_ulong();
379 Index num_marked()
const
381 return _type.count();
385 template<
typename Shape_>
388 return lhs._type == rhs._type && lhs._isolated == rhs._isolated;
391 template<
typename Shape_>
392 bool operator!=(
const IsolatedPointRefinementType<Shape_>& lhs,
const IsolatedPointRefinementType<Shape_>& rhs)
394 return !(lhs == rhs);
397 template<
typename Shape_>
398 std::ostream& operator<<(std::ostream& stream,
const IsolatedPointRefinementType<Shape_>& type)
400 stream <<
"IsolatedPointRefinementType<" << Shape_::name() <<
"> { type: " << type._type
401 <<
", isolated: " <<
stringify(type._isolated) <<
" }";
409 template<
typename Shape_>
410 struct hash<
FEAT::Geometry::StandardRefinementType<Shape_>>
412 static constexpr int num_vertices = FEAT::Shape::template FaceTraits<Shape_, 0>::count;
416 return std::hash<std::bitset<num_vertices>>{}(type._type);
420 template<
typename Shape_>
421 struct hash<
FEAT::Geometry::IsolatedPointRefinementType<Shape_>>
423 static constexpr int num_vertices = FEAT::Shape::template FaceTraits<Shape_, 0>::count;
427 auto h1 = std::hash<std::bitset<num_vertices>>{}(type._type);
428 auto h2 = std::hash<bool>{}(type._isolated);
429 return h1 ^ (h2 << 1UL);
#define ASSERT(expr)
Debug-Assertion macro definition.
@ other
generic/other permutation strategy
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.
Tuple-type for SubdivisionLevels.
Face traits tag struct template.