Wildmeshing Toolkit
EdgeOperationData.cpp
Go to the documentation of this file.
1 
2 #include <array>
3 #include <vector>
4 #include <wmtk/Tuple.hpp>
5 #include <wmtk/utils/Logger.hpp>
6 
7 #include <wmtk/Mesh.hpp>
8 #include "EdgeOperationData.hpp"
11 namespace wmtk::operations {
12 
15 EdgeOperationData::EdgeOperationData(EdgeOperationData&&) = default;
16 EdgeOperationData& EdgeOperationData::operator=(EdgeOperationData&&) = default;
17 auto EdgeOperationData::tuple_from_id(const Mesh& m, const PrimitiveType type, const int64_t gid)
18  -> Tuple
19 {
20  return m.tuple_from_id(type, gid);
21 }
23 EdgeOperationData::simplex_from_id(const Mesh& m, const PrimitiveType type, const int64_t gid)
24 {
25  return m.simplex_from_id(type, gid);
26 }
28 {
29  m_op_data = std::make_unique<internal::SplitAlternateFacetData>();
30 }
32 {
33  m_op_data = std::make_unique<internal::CollapseAlternateFacetData>();
34 }
35 
37 {
38  const auto& ptr = std::get<std::unique_ptr<internal::SplitAlternateFacetData>>(m_op_data);
39  if (!bool(ptr)) {
40  throw std::runtime_error(
41  "Split alternate facet data does not exist, ptr in variant was null");
42  }
43  return *ptr;
44 }
46 {
47  const auto& ptr = std::get<std::unique_ptr<internal::CollapseAlternateFacetData>>(m_op_data);
48  if (!bool(ptr)) {
49  throw std::runtime_error(
50  "Collapse alternate facet data does not exist, ptr in variant was null");
51  }
52  return *ptr;
53 }
55 {
56  auto& ptr = std::get<std::unique_ptr<internal::SplitAlternateFacetData>>(m_op_data);
57  if (!bool(ptr)) {
58  throw std::runtime_error(
59  "Split alternate facet data does not exist, ptr in variant was null");
60  }
61  return *ptr;
62 }
64 {
65  auto& ptr = std::get<std::unique_ptr<internal::CollapseAlternateFacetData>>(m_op_data);
66  if (!bool(ptr)) {
67  throw std::runtime_error(
68  "Collapse alternate facet data does not exist, ptr in variant was null");
69  }
70  return *ptr;
71 }
72 std::vector<int64_t>
74 {
75  mesh.guarantee_more_attributes(type, count);
76 
77  auto ret = mesh.request_simplex_indices(type, count);
78  // wmtk::logger()
79  // .trace("Requesting {} {}-simplices. got [{}]", count, int(type), fmt::join(ret, ","));
80  return ret;
81 }
82 
83 } // namespace wmtk::operations
void guarantee_more_attributes(PrimitiveType type, int64_t size)
simplex::NavigatableSimplex simplex_from_id(const PrimitiveType type, const int64_t gid) const
Definition: Mesh.cpp:130
std::vector< int64_t > request_simplex_indices(PrimitiveType type, int64_t count)
EdgeOperationData & operator=(EdgeOperationData &&)
const internal::SplitAlternateFacetData & const_split_facet_data() const
Returns facet data held if the edge operation was a split - throws if data does not exist.
internal::SplitAlternateFacetData & split_facet_data()
Returns facet data held if the edge operation was a split - throws if data does not exist.
static Tuple tuple_from_id(const Mesh &m, const PrimitiveType type, const int64_t gid)
std::variant< std::unique_ptr< internal::SplitAlternateFacetData >, std::unique_ptr< internal::CollapseAlternateFacetData > > m_op_data
static std::vector< int64_t > request_simplex_indices(Mesh &mesh, const PrimitiveType type, int64_t count)
static simplex::Simplex simplex_from_id(const Mesh &m, const PrimitiveType type, const int64_t gid)
internal::CollapseAlternateFacetData & collapse_facet_data()
Returns facet data held if the edge operation was a collapse- throws if data does not exist.
const internal::CollapseAlternateFacetData & const_collapse_facet_data() const
Returns facet data held if the edge operation was a collapse- throws if data does not exist.