Wildmeshing Toolkit
local_switch_tuple.hxx
Go to the documentation of this file.
1 #pragma once
2 #include <cassert>
3 #include <stdexcept>
9 
10 
11 namespace wmtk::autogen::tet_mesh {
12 inline Tuple local_switch_tuple(const Tuple& tuple, PrimitiveType pt)
13 {
14  using namespace utils;
15  const int64_t offset = local_id_table_offset(tuple);
16 
17 
18  const int64_t global_cid = TupleInspector::global_cid(tuple);
19  switch (pt) {
21  return Tuple(
22  auto_3d_table_vertex[offset][0],
23  auto_3d_table_vertex[offset][1],
24  auto_3d_table_vertex[offset][2],
25  global_cid);
26 
28  return Tuple(
29  auto_3d_table_edge[offset][0],
30  auto_3d_table_edge[offset][1],
31  auto_3d_table_edge[offset][2],
32  global_cid);
34  return Tuple(
35  auto_3d_table_face[offset][0],
36  auto_3d_table_face[offset][1],
37  auto_3d_table_face[offset][2],
38  global_cid);
39 
41  default: assert(false); // "Tuple switch: Invalid primitive type"
42  }
43  return Tuple();
44 }
45 
46 inline Tuple local_switch_tuple(const Tuple& t, int8_t valid_tuple_index)
47 {
48  int8_t input_index = valid_index_from_tuple(t);
49  const int64_t global_cid = wmtk::utils::TupleInspector::global_cid(t);
50  const int8_t product_result = auto_valid_switch_product_table[input_index][valid_tuple_index];
51  return tuple_from_valid_index(global_cid, product_result);
52 }
53 
54 namespace internal {
56 {
58 }
60 {
62 }
63 } // namespace internal
64 } // namespace wmtk::autogen::tet_mesh
static int64_t global_cid(const Tuple &t)
int8_t switch_primitive_to_valid_tuple_index(wmtk::PrimitiveType pt)
const int64_t auto_3d_table_face[96][3]
const int8_t auto_valid_switch_product_table[24][24]
Tuple local_switch_tuple(const Tuple &t, PrimitiveType pt)
const int64_t auto_3d_table_vertex[96][3]
const int8_t auto_valid_tuple_switch_indices[5]
int8_t valid_index_from_tuple(const Tuple &t)
const int64_t auto_3d_table_edge[96][3]
int64_t local_id_table_offset(const Tuple &t)
Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index)
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.