Wildmeshing Toolkit
local_switch_tuple.hxx
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdexcept>
9 
10 
11 namespace wmtk::autogen::tri_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  switch (pt) {
18  return Tuple(
19  auto_2d_table_vertex[offset][0],
20  auto_2d_table_vertex[offset][1],
21  TupleInspector::local_fid(tuple),
22  TupleInspector::global_cid(tuple));
23 
25  return Tuple(
26  auto_2d_table_edge[offset][0],
27  auto_2d_table_edge[offset][1],
28  TupleInspector::local_fid(tuple),
29  TupleInspector::global_cid(tuple));
30 
33  default: assert(false); // "Tuple switch: Invalid primitive type"
34  }
35  return Tuple();
36 }
37 inline Tuple local_switch_tuple(const Tuple& t, int8_t valid_tuple_index)
38 {
39  int8_t input_index = valid_index_from_tuple(t);
40  const int64_t global_cid = wmtk::utils::TupleInspector::global_cid(t);
41  const int8_t product_result = auto_valid_switch_product_table[input_index][valid_tuple_index];
42  return tuple_from_valid_index(global_cid, product_result);
43 }
44 
45 namespace internal {
47 {
49 }
51 {
53 }
54 } // namespace internal
55 } // namespace wmtk::autogen::tri_mesh
static int64_t global_cid(const Tuple &t)
int8_t switch_primitive_to_valid_tuple_index(wmtk::PrimitiveType pt)
int64_t local_id_table_offset(const Tuple &t)
const int64_t auto_2d_table_edge[9][2]
int8_t valid_index_from_tuple(const Tuple &t)
const int8_t auto_valid_tuple_switch_indices[4]
Tuple local_switch_tuple(const Tuple &t, PrimitiveType pt)
Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index)
const int8_t auto_valid_switch_product_table[6][6]
const int64_t auto_2d_table_vertex[9][2]
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.