Wildmeshing Toolkit
multi_mesh_edge_split.cpp
Go to the documentation of this file.
12 
13 #include <wmtk/TriMesh.hpp>
15 
16 namespace wmtk::operations::utils {
17 
18 std::shared_ptr<invariants::InvariantCollection> multimesh_edge_split_invariants(const Mesh& m)
19 {
20  auto invariants = std::make_shared<invariants::InvariantCollection>(m);
21  //*invariants = basic_multimesh_invariant_collection(m, PrimitiveType::Edge);
22  return invariants;
23 }
24 
26  Mesh& mesh,
28  const std::vector<std::shared_ptr<const operations::BaseSplitNewAttributeStrategy>>&
29  new_attr_strategies)
30 {
32  std::integral_constant<int64_t, 1>{}, // specify that this runs on edges
34  visitor.execute_from_root(mesh, t);
35  multimesh::MultiMeshSimplexEventVisitor event_visitor(visitor);
38 
39 
40  auto cache = visitor.take_cache();
41 
43  auto update_attributes = [&](auto&& m) {
44  using T = std::remove_reference_t<decltype(m)>;
45  if constexpr (!std::is_const_v<T>) {
46  for (const auto& split_ptr : new_attr_strategies) {
47  if (&m == &split_ptr->mesh()) {
48  split_ptr->update(m, cache, tuples);
49  }
50  }
51  }
52  };
53 
54  multimesh::MultiMeshVisitor(update_attributes).execute_from_root(mesh);
55 
56  return cache;
57 }
58 
59 std::vector<simplex::Simplex> multi_mesh_edge_split_with_modified_simplices(
60  Mesh& mesh,
61  const simplex::Simplex& simplex,
62  const std::vector<std::shared_ptr<const operations::BaseSplitNewAttributeStrategy>>&
63  new_attr_strategies)
64 {
65  simplex::NavigatableSimplex nsimplex(mesh, simplex);
66  auto candidates = top_dimension_cofaces(mesh, simplex);
67  auto return_data = multi_mesh_edge_split(mesh, nsimplex, new_attr_strategies);
68 
69  for (const auto& c : candidates) {
70  if (return_data.has_variant(mesh, nsimplex)) {
71  return std::visit(
72  [&mesh](const auto& rt) -> std::vector<simplex::Simplex> {
73  if (mesh.is_free()) {
74  return rt.new_vertices(mesh);
75  } else {
76  return {simplex::Simplex::vertex(mesh, rt.m_output_tuple)};
77  }
78  },
79  return_data.get_variant(mesh, nsimplex));
80  }
81  }
82 
83  assert(return_data.has_variant(mesh, nsimplex));
84 
85  return {};
86 
87 
88  // return std::visit(
89  // [&mesh](const auto& rt) -> std::vector<simplex::Simplex> {
90  // if (mesh.is_free()) {
91  // return rt.new_vertices(mesh);
92  // } else {
93  // return {simplex::Simplex::vertex(mesh, rt.m_output_tuple)};
94  // }
95  // },
96  // return_data.get_variant(mesh, simplex));
97 }
98 } // namespace wmtk::operations::utils
bool is_free() const
Definition: Mesh.hpp:987
void execute_from_root(Mesh &mesh, const simplex::NavigatableSimplex &simplex)
OperationInOutData extract_operation_in_out(const CollapseReturnData &return_data)
MultiMeshVisitor(NodeFunctor &&) -> MultiMeshVisitor< NodeFunctor >
SplitReturnData multi_mesh_edge_split(Mesh &mesh, const simplex::NavigatableSimplex &t, const std::vector< std::shared_ptr< const operations::BaseSplitNewAttributeStrategy >> &new_attr_strategies)
std::shared_ptr< invariants::InvariantCollection > multimesh_edge_split_invariants(const Mesh &m)
std::vector< simplex::Simplex > multi_mesh_edge_split_with_modified_simplices(Mesh &mesh, const simplex::Simplex &simplex, const std::vector< std::shared_ptr< const operations::BaseSplitNewAttributeStrategy >> &new_attr_strategies)
wmtk::multimesh::operations::SplitReturnData SplitReturnData
void top_dimension_cofaces(const Simplex &simplex, SimplexCollection &simplex_collection, const bool sort_and_clean)
Get all top dimension cofaces of the given simplex.