Wildmeshing Toolkit
Rounding.cpp
Go to the documentation of this file.
1 #include "Rounding.hpp"
2 
3 #include <wmtk/Mesh.hpp>
6 #include <wmtk/utils/Logger.hpp>
7 
8 
9 namespace wmtk::operations {
10 
12  : AttributesUpdate(m)
13  , m_coordinate_handle(coordinate)
14 {}
15 
16 std::vector<simplex::Simplex> Rounding::execute(const simplex::Simplex& simplex)
17 {
18  assert(simplex.primitive_type() == PrimitiveType::Vertex);
19 
20  auto accessor = mesh().create_accessor(m_coordinate_handle);
21 
22  // auto& pos = accessor.vector_attribute(simplex.tuple());
23  for (int i = 0; i < mesh().get_attribute_dimension(m_coordinate_handle); ++i) {
24  accessor.vector_attribute(simplex.tuple())[i].round();
25  }
26  // accessor.vector_attribute(simplex.tuple()) = pos;
27 
28  return AttributesUpdate::execute(simplex);
29 }
30 
31 } // namespace wmtk::operations
int64_t get_attribute_dimension(const TypedAttributeHandle< T > &handle) const
Definition: Mesh.hpp:943
attribute::Accessor< T, Mesh, D > create_accessor(const attribute::MeshAttributeHandle &handle)
Handle that represents attributes for some mesh.
virtual std::vector< simplex::Simplex > execute(const simplex::Simplex &simplex) override
returns an empty vector in case of failure
const Mesh & mesh() const
Definition: Operation.hpp:45
Rounding(Mesh &m, TypedAttributeHandle< Rational > &coordinate)
Definition: Rounding.cpp:11
TypedAttributeHandle< Rational > & m_coordinate_handle
Definition: Rounding.hpp:17
std::vector< simplex::Simplex > execute(const simplex::Simplex &simplex) override
returns an empty vector in case of failure
Definition: Rounding.cpp:16
const Tuple & tuple() const
Definition: Simplex.hpp:53
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51