3 #include <spdlog/spdlog.h>
8 : m_char_attributes(size)
9 , m_long_attributes(size)
10 , m_double_attributes(size)
11 , m_rational_attributes(size)
12 , m_capacities(size, 0)
19 std::map<std::string, const wmtk::utils::Hashable*> ret;
54 for (int64_t dim = 0; dim <
m_capacities.size(); ++dim) {
55 if (!writer.
write(dim))
continue;
67 for (int64_t dim = 0; dim <
m_capacities.size(); ++dim) {
82 assert(dimension < this->
size());
90 assert(more_capacities.size() ==
size());
91 for (int64_t dim = 0; dim <
size(); ++dim) {
97 assert(dimension < this->
size());
107 const std::vector<int64_t>& at_least_capacities)
109 assert(at_least_capacities.size() ==
size());
110 for (int64_t dim = 0; dim <
size(); ++dim) {
116 const int64_t current_capacity =
m_capacities[dimension];
117 const int64_t target_capacity = current_capacity +
size;
122 assert(more_capacities.size() ==
size());
123 for (int64_t dim = 0; dim <
size(); ++dim) {
156 for (int64_t j = 0; j <
size(); ++j) {
182 std::string name = std::visit(
184 using T = std::decay_t<decltype(val)>;
185 return this->
get_name(std::get<T>(attr));
210 ma.pop_scope(apply_updates);
213 ma.pop_scope(apply_updates);
216 ma.pop_scope(apply_updates);
219 ma.pop_scope(apply_updates);
226 ma.rollback_current_scope();
229 ma.rollback_current_scope();
232 ma.rollback_current_scope();
235 ma.rollback_current_scope();
242 ma.change_to_parent_scope();
245 ma.change_to_parent_scope();
248 ma.change_to_parent_scope();
251 ma.change_to_parent_scope();
258 ma.change_to_child_scope();
261 ma.change_to_child_scope();
264 ma.change_to_child_scope();
267 ma.change_to_child_scope();
273 std::vector<MeshAttributeHandle::HandleVariant> handles;
275 auto run = [&](
auto type) {
276 using T = std::decay_t<decltype(type)>;
278 const std::vector<MeshAttributes<T>>& mesh_attributes = get<T>();
279 for (
size_t pt_index = 0; pt_index < mesh_attributes.size(); ++pt_index) {
286 size_t count = mesh_attributes[pt_index].attribute_count();
287 const auto active_handles = mesh_attributes[pt_index].active_attributes();
289 active_handles.begin(),
290 active_handles.end(),
291 std::back_inserter(handles),
303 template <
typename T>
304 class ClearAttrDataT :
public std::array<std::vector<AttributeHandle>, 5>
308 class ClearAttrData :
public ClearAttrDataT<char>,
309 public ClearAttrDataT<int64_t>,
310 public ClearAttrDataT<double>,
311 public ClearAttrDataT<Rational>
314 template <
typename T>
315 ClearAttrDataT<T>& get();
317 template <
typename T>
318 ClearAttrDataT<T>& ClearAttrData::get()
320 return static_cast<ClearAttrDataT<T>&
>(*this);
324 const std::vector<attribute::MeshAttributeHandle::HandleVariant>& custom_attributes)
330 ClearAttrData customs;
333 [&](
auto&& val) noexcept {
334 using HandleType =
typename std::decay_t<decltype(val)>;
335 if constexpr (attribute::MeshAttributeHandle::template handle_type_is_basic<
337 using T =
typename HandleType::Type;
348 auto run = [&](
auto t) {
349 using T =
typename std::decay_t<decltype(t)>;
350 auto& mycustoms = customs.get<T>();
351 const auto& attributes = get<T>();
353 for (
size_t ptype_id = 0; ptype_id < attributes.size(); ++ptype_id) {
357 get<T>(primitive_type).remove_attributes(mycustoms[ptype_id]);
370 [&](
auto&& val) noexcept {
371 using HandleType =
typename std::decay_t<decltype(val)>;
372 if constexpr (attribute::MeshAttributeHandle::template handle_type_is_basic<
374 using T =
typename HandleType::Type;
375 get<T>(val).remove_attribute(val.base_handle());
virtual bool write(const int dim)=0
virtual void write_capacities(const std::vector< int64_t > &capacities)=0
Internal handle representation used by MeshAttributes.
std::vector< MeshAttributes< double > > m_double_attributes
AttributeScopeHandle create_scope(Mesh &m)
std::vector< MeshAttributes< char > > m_char_attributes
void set_capacities(std::vector< int64_t > capacities)
void serialize(MeshWriter &writer) const
void pop_scope(bool apply_updates=true)
void guarantee_at_least_attributes(int64_t dimension, int64_t size)
AttributeManager(int64_t size)
void reserve_attributes_to_fit()
std::map< std::string, const wmtk::utils::Hashable * > child_hashables() const override
bool operator==(const AttributeManager &other) const
void change_to_child_scope() const
void change_to_parent_scope() const
std::vector< int64_t > m_capacities
std::map< std::string, std::size_t > child_hashes() const override
std::vector< MeshAttributes< Rational > > m_rational_attributes
void clear_attributes(const std::vector< attribute::MeshAttributeHandle::HandleVariant > &custom_attributes)
Remove all custom attributes besides the one passed in.
void assert_capacity_valid() const
void rollback_current_scope()
void guarantee_more_attributes(int64_t dimension, int64_t size)
std::vector< MeshAttributeHandle::HandleVariant > get_all_attributes() const
void reserve_more_attributes(int64_t dimension, int64_t size)
std::string get_name(const TypedAttributeHandle< T > &attr) const
void delete_attribute(const attribute::MeshAttributeHandle::HandleVariant &to_delete)
void reserve_attributes(int64_t dimension, int64_t size)
std::vector< MeshAttributes< int64_t > > m_long_attributes
This handle is a wrapper for the MeshManager scope funtions.
std::variant< TypedAttributeHandle< char >, TypedAttributeHandle< int64_t >, TypedAttributeHandle< double >, TypedAttributeHandle< wmtk::Rational > > HandleVariant
Handle that represents attributes for some mesh.
std::map< std::string, std::size_t > child_hashes() const override
constexpr PrimitiveType get_primitive_type_from_id(int8_t id)
Get the primitive type corresponding to its unique integer id.
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.