Wildmeshing Toolkit
AttributeTransferStrategyBase.cpp
Go to the documentation of this file.
1 
3 #include <wmtk/Mesh.hpp>
5 
7 
8 namespace wmtk::operations {
10  const attribute::MeshAttributeHandle& my_handle)
11  : m_handle(my_handle)
12 {}
15 {
16  return const_cast<const Mesh&>(const_cast<AttributeTransferStrategyBase*>(this)->mesh());
17 }
18 
20 {
22  auto tuples = m_handle.mesh().get_all(pt);
23 
24  for (const Tuple& t : tuples) {
25  run(simplex::Simplex(m_handle.mesh(), pt, t));
26  }
27 }
28 
31  const attribute::MeshAttributeHandle& parent,
32  const simplex::Simplex& s)
33 {
34  return get_parent_simplices(me.mesh(), parent.mesh(), s, parent.primitive_type());
35 }
36 
38  const Mesh& m,
39  const Mesh& parent,
40  const simplex::Simplex& s,
41  PrimitiveType parent_primitive_type)
42 {
43  const PrimitiveType my_primitive_type = s.primitive_type();
44 
45 
46  // the set of simplices that can be traversed without crossing a mesh-mesh edge more than once
47  std::vector<Tuple> parent_tuples = m.lub_map_tuples(parent, s);
48 
49  if (my_primitive_type != parent_primitive_type) {
50  // lambda for running either of the cases
51  std::vector<Tuple> r;
52  if (parent_tuples.size() == 1) {
54  m,
55  simplex::Simplex(m, my_primitive_type, parent_tuples[0]),
56  parent_primitive_type);
57  } else {
58  for (const auto& parent_tup : parent_tuples) {
59  std::vector<Tuple> c = simplex::neighbors_single_dimension_tuples(
60  m,
61  simplex::Simplex(m, my_primitive_type, parent_tup),
62  parent_primitive_type);
63  std::copy(c.begin(), c.end(), std::back_inserter(r));
64  }
65  if (parent_tuples.size() > 1) {
66  simplex::utils::unique_homogeneous_simplices_inline(m, parent_primitive_type, r);
67  }
68  }
69  parent_tuples = std::move(r);
70  }
71  return parent_tuples;
72 }
73 
75  const wmtk::attribute::MeshAttributeHandle& attr) const
76 {
77  return handle() == attr;
78 }
79 } // namespace wmtk::operations
std::vector< Tuple > get_all(PrimitiveType type) const
Generate a vector of Tuples from global vertex/edge/triangle/tetrahedron index.
Definition: Mesh.cpp:18
std::vector< Tuple > lub_map_tuples(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh using LUB mesh as root
AttributeTransferStrategyBase(const attribute::MeshAttributeHandle &my_handle)
virtual void run(const simplex::Simplex &s) const =0
static std::vector< Tuple > get_parent_simplices(const Mesh &m, const Mesh &parent, const simplex::Simplex &s, PrimitiveType parent_primitive_type)
bool matches_attribute(const wmtk::attribute::MeshAttributeHandle &attr) const
const attribute::MeshAttributeHandle & handle() const
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51
void unique_homogeneous_simplices_inline(const Mesh &m, PrimitiveType pt, std::vector< Tuple > &tups)
std::vector< Tuple > neighbors_single_dimension_tuples(const Mesh &m, const Simplex &s, const PrimitiveType tpt)