12#ifndef ARCANE_MESH_DYNAMICMESHKINDINFOS_H
13#define ARCANE_MESH_DYNAMICMESHKINDINFOS_H
17#include "arcane/utils/Array.h"
18#include "arcane/utils/String.h"
19#include "arcane/utils/HashTableMap.h"
20#include "arcane/utils/TraceAccessor.h"
23#include "arcane/core/ItemGroup.h"
24#include "arcane/core/ItemInternal.h"
27#include "arcane/mesh/ItemInternalMap.h"
34#define ARCANE_ENABLE_EVENT_FOR_DYNAMICMESHKINDINFO
60 using ItemInternalMapData = ItemInternalMap::BaseData;
87 void prepareForDump();
103 ItemInternal* itemInternal(
Int32 local_id)
const {
return m_internals[local_id]; }
108 bool need_alloc =
false;
110#ifdef ARCANE_ENABLE_EVENT_FOR_DYNAMICMESHKINDINFO
111 _notifyAdd(next, unique_id);
113 if (m_has_unique_id_map)
115 _badSameUniqueId(unique_id);
123#ifdef ARCANE_ENABLE_EVENT_FOR_DYNAMICMESHKINDINFO
124 _notifyAdd(next, unique_id);
126 if (m_has_unique_id_map)
128 _badSameUniqueId(unique_id);
136 _checkActiveItem(item);
138 _setSuppressed(item);
139 if (m_has_unique_id_map) {
141 if (uid != NULL_ITEM_UNIQUE_ID)
145 m_removed_items.add(item->
localId());
146#ifdef ARCANE_ENABLE_EVENT_FOR_DYNAMICMESHKINDINFO
156 _checkActiveItem(item);
158 _setSuppressed(item);
159#ifndef REMOVE_UID_ON_DETACH
160 if (m_has_unique_id_map)
164 m_removed_items.add(item->
localId());
165#ifdef ARCANE_ENABLE_EVENT_FOR_DYNAMICMESHKINDINFO
180 _checkActiveItem(item);
184#ifdef REMOVE_UID_ON_DETACH
185 if (m_has_unique_id_map)
198 if (!m_has_unique_id_map)
204 item_data.setValue(
_allocOne(need_alloc));
205#ifdef ARCANE_ENABLE_EVENT_FOR_DYNAMICMESHKINDINFO
206 _notifyAdd(item_data.value(), uid);
209 return item_data.value();
216 if (!m_has_unique_id_map)
227 Integer nbItem()
const {
return m_nb_item; }
229 eItemKind kind()
const {
return m_kind; }
233 return !m_added_items.empty() || !m_removed_items.empty();
236 void beginCompactItems(ItemFamilyCompactInfos& compact_infos);
254 void allocMany(Int64ConstArrayView uids, Int32ArrayView lids);
281 bool do_fatal)
const;
284 bool do_fatal)
const;
288 return m_item_family;
291 void setItemFamily(ItemFamily* item_family);
293 bool hasUniqueIdMap()
const
295 return m_has_unique_id_map;
298 void setHasUniqueIdMap(
bool v);
300 void printFreeInternals(Integer max_print);
304 EventObservableView<const ItemFamilyItemListChangedEventArgs&> itemListChangedEvent();
323 Integer nb_free2 = m_free_internals_in_multi_buffer.size();
325 new_item = m_free_internals_in_multi_buffer.back();
326 m_free_internals_in_multi_buffer.popBack();
331 new_item->setLocalId(lid);
333 _updateItemSharedInfoInternalView();
336 m_added_items.add(lid);
354 bool m_use_new_finalize;
355 bool m_is_first_finalize;
356 bool m_has_unique_id_map;
382 int f = item->
flags();
390 int f = item->
flags();
398 void _badSameUniqueId(
Int64 unique_id)
const;
399 void _badUniqueIdMap()
const;
400 void _updateItemSharedInfoInternalView();
403 if (m_item_list_change_event.hasObservers())
404 _notifyRemove2(item);
406 void _notifyAdd(ItemInternal* item, Int64 uid)
408 if (m_item_list_change_event.hasObservers())
409 _notifyAdd2(item, uid);
411 void _notifyRemove2(ItemInternal* item);
412 void _notifyAdd2(ItemInternal* item, Int64 uid);
File containing event management mechanisms.
Modifiable view of an array of type T.
Constant view of an array of type T.
Base class for an event handler.
ItemUniqueId uniqueId() const
Unique number of the entity.
Int32 flags() const
Flags of the entity.
Int32 localId() const
Local number (in the subdomain) of the entity.
Information to manage the compaction of entities of a family.
Flags for entity characteristics.
@ II_Suppressed
The entity has just been suppressed.
@ II_Added
The entity has just been added.
Internal structure of a mesh entity.
Internal shared structure of a mesh entity.
Buffer for multiple allocation.
void setDetached(bool v)
Sets the detached state of the entity.
void setFlags(Int32 f)
Sets the entity flags.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
Integer m_nb_item
Group of all entities.
String m_kind_name
Name of the entity kind (Node, Cell, ...).
Integer maxUsedLocalId() const
Largest local ID used.
MultiBufferT< ItemInternal > * m_item_internals_buffer
Buffer to store an instance of ItemInternal.
void finalizeMeshChanged()
Reallocates and recalculates structures after mesh modification.
ItemGroup allItems() const
Group of all entities.
void removeOne(ItemInternal *item)
Removes the entity item.
ItemInternal * allocOne(Int64 unique_id, bool &need_alloc)
Adds an entity with a unique ID unique_id.
UniqueArray< ItemInternal * > m_internals
ItemInternals of the entities.
ItemInternal * findOrAllocOne(Int64 uid, bool &is_alloc)
Finds the entity with unique ID unique_id and creates it if it does not exist.
ConstArrayView< ItemInternal * > itemsInternal() const
Internal list of ItemInternals.
ItemInternal * _allocOne(bool &need_alloc)
Adds an entity.
Int32ConstArrayView addedItems() const
List of entities added or removed since the last endUpdate().
DynamicMeshKindInfos(IMesh *mesh, eItemKind kind, const String &kind_name)
Creates an instance for a given mesh and kind.
ItemInternal * allocOne(Int64 unique_id)
Adds an entity with a unique ID unique_id.
void removeDetachedOne(ItemInternal *item)
Removes the detached entity item.
ItemFamilyCompactInfos * m_compact_infos
Temporary while oldToNewLocalIds() and newToOldLocalIds() exist.
String m_all_group_name
Name of the group containing all entities.
void detachOne(ItemInternal *item)
Detaches the entity item.
ItemInternalMap m_items_map
Hash table for uniqueId() -> ItemInternal* conversion.
Int32UniqueArray m_free_internals
List of free ItemInternals from m_item_internals_buffer.
ItemInternal * findOne(Int64 uid)
Finds the entity with unique ID uid.
IMesh * m_mesh
Associated mesh.
bool hasNoItemInternal() const
Whether the family holds no ItemInternal at all.
eItemKind m_kind
Corresponding kind.
ItemFamily * m_item_family
Associated mesh family.
Associative array of ItemInternal.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
eItemKind
Mesh entity type.
std::int32_t Int32
Signed integer type of 32 bits.