Wildmeshing Toolkit
SimplexGetter.cpp
Go to the documentation of this file.
1 #include "SimplexGetter.hpp"
2 
4 
5 namespace wmtk::function::utils {
6 
7 template <typename T>
8 std::tuple<std::vector<std::decay_t<typename attribute::ConstMapResult<T>>>, int64_t>
10  const Mesh& mesh,
11  const wmtk::attribute::Accessor<T>& accessor,
12  const PrimitiveType primitive_type,
13  const simplex::Simplex& simplex_in,
14  const std::optional<wmtk::Tuple>& vertex_marker)
15 {
16  std::vector<Tuple> faces;
17  if (primitive_type == PrimitiveType::Vertex) {
18  faces = mesh.orient_vertices(simplex_in.tuple());
19  } else {
20  const simplex::Simplex simplex =
21  mesh.is_ccw(simplex_in.tuple())
22  ? simplex_in
24  mesh,
25  simplex_in.primitive_type(),
26  mesh.switch_tuple(simplex_in.tuple(), PrimitiveType::Vertex));
27 
28  assert(mesh.is_ccw(simplex.tuple()));
29  faces = wmtk::simplex::faces_single_dimension_tuples(mesh, simplex, primitive_type);
30  }
31 
32  std::vector<std::decay_t<typename attribute::ConstMapResult<T>>> ret;
33  ret.reserve(faces.size());
34  int64_t vertex_marker_index = -1;
35 
36  std::transform(
37  faces.begin(),
38  faces.end(),
39  std::back_inserter(ret),
40  [&](const Tuple& face_tuple) {
41  auto value = accessor.const_vector_attribute(face_tuple);
42  return value;
43  });
44 
45  // if we have a vertex marker
46 
47  if (vertex_marker.has_value()) {
48  const auto& variable_tuple = vertex_marker.value();
49  for (size_t i = 0; i < faces.size(); ++i) {
51  mesh,
52  primitive_type,
53  faces[i],
54  variable_tuple)) {
55  vertex_marker_index = i;
56  break;
57  }
58  }
59  assert(vertex_marker_index >= 0);
60  }
61  return {ret, vertex_marker_index};
62 }
63 
64 template std::tuple<std::vector<std::decay_t<typename attribute::ConstMapResult<char>>>, int64_t>
66  const Mesh& mesh,
67  const wmtk::attribute::Accessor<char>& accessor,
68  const PrimitiveType primitive_type,
69  const simplex::Simplex& simplex,
70  const std::optional<wmtk::Tuple>& vertex_marker);
71 
72 template std::tuple<std::vector<std::decay_t<typename attribute::ConstMapResult<int64_t>>>, int64_t>
74  const Mesh& mesh,
75  const wmtk::attribute::Accessor<int64_t>& accessor,
76  const PrimitiveType primitive_type,
77  const simplex::Simplex& simplex,
78  const std::optional<wmtk::Tuple>& vertex_marker);
79 
80 template std::tuple<std::vector<std::decay_t<typename attribute::ConstMapResult<double>>>, int64_t>
82  const Mesh& mesh,
83  const wmtk::attribute::Accessor<double>& accessor,
84  const PrimitiveType primitive_type,
85  const simplex::Simplex& simplex,
86  const std::optional<wmtk::Tuple>& vertex_marker);
87 
88 template std::
89  tuple<std::vector<std::decay_t<typename attribute::ConstMapResult<Rational>>>, int64_t>
91  const Mesh& mesh,
93  const PrimitiveType primitive_type,
94  const simplex::Simplex& simplex,
95  const std::optional<wmtk::Tuple>& vertex_marker);
96 } // namespace wmtk::function::utils
virtual std::vector< Tuple > orient_vertices(const Tuple &t) const =0
virtual bool is_ccw(const Tuple &tuple) const =0
TODO this needs dimension?
virtual Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const =0
switch the orientation of the Tuple of the given dimension
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
const Tuple & tuple() const
Definition: Simplex.hpp:53
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51
static bool equal(const Mesh &m, const Simplex &s0, const Simplex &s1)
std::tuple< std::vector< std::decay_t< typename attribute::ConstMapResult< T > > >, int64_t > get_simplex_attributes(const Mesh &mesh, const wmtk::attribute::Accessor< T > &accessor, const PrimitiveType primitive_type, const simplex::Simplex &simplex_in, const std::optional< wmtk::Tuple > &vertex_marker)
get attributes from a simplex
std::vector< Tuple > faces_single_dimension_tuples(const Mesh &mesh, const Simplex &simplex, const PrimitiveType face_type)
SimplexCollection faces(const Mesh &mesh, const Simplex &simplex, const bool sort_and_clean)
Returns all faces of a simplex.
Definition: faces.cpp:10