Wildmeshing Toolkit
AttributeFlatCache.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <Eigen/Core>
3 #include <map>
4 #include <memory>
5 #include "AttributeCacheData.hpp"
6 #include "MapTypes.hpp"
7 
8 
9 namespace wmtk::attribute {
10 template <typename T>
11 class Attribute;
12 template <typename T, int Dim>
13 class AccessorBase;
14 namespace internal {
15 template <typename T>
17 {
18 public:
20 
23 
24 
31 
32 
33  template <typename Derived>
34  void try_caching(int64_t index, const Eigen::MatrixBase<Derived>& value);
35  void try_caching(int64_t index, const T& value);
36 
37 
38  const T* get_value(int64_t index, size_t dim) const;
39 
40  void clear();
41  size_t size() const { return m_indices.size(); }
42 
43  void apply_to(Attribute<T>& attribute) const;
44  void apply_to(AttributeFlatCache<T>& other) const;
45 
46  // applyes to some other buffer that was passed in
47  void apply_to(const Attribute<T>& attribute, std::vector<T>& other) const;
48 
49  const std::vector<T>& buffer() const { return m_buffer; }
50  const std::vector<std::pair<size_t, size_t>>& indices() const { return m_indices; }
51 
52 protected:
53  std::vector<T> m_buffer;
54  std::vector<std::pair<size_t, size_t>> m_indices;
55 };
56 
57 } // namespace internal
58 } // namespace wmtk::attribute
59 
60 #include "AttributeFlatCache.hxx"
This class stores data of type T in a vector.
Definition: Attribute.hpp:32
void try_caching(int64_t index, const Eigen::MatrixBase< Derived > &value)
void apply_to(Attribute< T > &attribute) const
const std::vector< std::pair< size_t, size_t > > & indices() const
std::vector< std::pair< size_t, size_t > > m_indices
AttributeFlatCache(AttributeFlatCache &&)=default
AttributeFlatCache & operator=(AttributeFlatCache &&)=default
AttributeFlatCache & operator=(const AttributeFlatCache &)=delete
const T * get_value(int64_t index, size_t dim) const
AttributeFlatCache(const AttributeFlatCache &)=delete
typename VectorResult< T, R >::MapType MapResult
the default map type used by attributes is a map of our vector type.
Definition: MapTypes.hpp:21
typename VectorResult< T, R >::ConstMapType ConstMapResult
Definition: MapTypes.hpp:23