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