Wildmeshing Toolkit
local_switch_tuple.hxx
Go to the documentation of this file.
1 #pragma once
2 #include <cassert>
3 #include <stdexcept>
9 
10 namespace wmtk::autogen::edge_mesh {
11 inline Tuple local_switch_tuple(const Tuple& tuple, PrimitiveType pt)
12 {
13  using namespace utils;
14  const int64_t global_cid = TupleInspector::global_cid(tuple);
15  switch (pt) {
17  return Tuple(
18  1 - TupleInspector::local_vid(tuple),
19  TupleInspector::local_eid(tuple),
20  TupleInspector::local_fid(tuple),
21  global_cid);
22 
26  default: assert(false); // "Tuple switch: Invalid primitive type"
27  }
28  return Tuple();
29 }
30 
31 inline Tuple local_switch_tuple(const Tuple& t, int8_t valid_tuple_index)
32 {
33  int8_t input_index = valid_index_from_tuple(t);
34  const int64_t global_cid = wmtk::utils::TupleInspector::global_cid(t);
35  const int8_t product_result = auto_valid_switch_product_table[input_index][valid_tuple_index];
36  return tuple_from_valid_index(global_cid, product_result);
37 }
38 
39 namespace internal {
41 {
43 }
45 {
47 }
48 } // namespace internal
49 } // namespace wmtk::autogen::edge_mesh
static int64_t global_cid(const Tuple &t)
int8_t switch_primitive_to_valid_tuple_index(wmtk::PrimitiveType pt)
Tuple local_switch_tuple(const Tuple &t, PrimitiveType pt)
const int8_t auto_valid_switch_product_table[2][2]
Tuple tuple_from_valid_index(int64_t global_cid, int8_t valid_tuple_index)
int8_t valid_index_from_tuple(const Tuple &t)
const int8_t auto_valid_tuple_switch_indices[3]
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.