Wildmeshing Toolkit
Loading...
Searching...
No Matches
AttributeFlatCache.hpp
Go to the documentation of this file.
1#pragma once
2#include <Eigen/Core>
3#include <map>
4#include <memory>
6#include "MapTypes.hpp"
7
8
9namespace wmtk::attribute {
10template <typename T>
11class Attribute;
12template <typename T, int Dim>
13class AccessorBase;
14namespace internal {
15template <typename T>
17{
18public:
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
52protected:
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
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
std::vector< std::pair< size_t, size_t > > m_indices
AttributeFlatCache & operator=(const AttributeFlatCache &)=delete
AttributeFlatCache(AttributeFlatCache &&)=default
const T * get_value(int64_t index, size_t dim) const
const std::vector< std::pair< size_t, size_t > > & indices() const
AttributeFlatCache(const AttributeFlatCache &)=delete
AttributeFlatCache & operator=(AttributeFlatCache &&)=default
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