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);
257 void finishCompactItems(ItemFamilyCompactInfos& compact_infos);
259 void itemsUniqueIdToLocalId(ArrayView<Int64> ids,
bool do_fatal)
const;
260 void itemsUniqueIdToLocalId(Int32ArrayView local_ids,
261 Int64ConstArrayView unique_ids,
262 bool do_fatal)
const;
263 void itemsUniqueIdToLocalId(Int32ArrayView local_ids,
264 ConstArrayView<ItemUniqueId> unique_ids,
265 bool do_fatal)
const;
267 ItemFamily* itemFamily()
const
269 return m_item_family;
272 void setItemFamily(ItemFamily* item_family);
274 bool hasUniqueIdMap()
const
276 return m_has_unique_id_map;
279 void setHasUniqueIdMap(
bool v);
281 void printFreeInternals(Integer max_print);
285 EventObservableView<const ItemFamilyItemListChangedEventArgs&> itemListChangedEvent();
304 Integer nb_free2 = m_free_internals_in_multi_buffer.size();
306 new_item = m_free_internals_in_multi_buffer.back();
307 m_free_internals_in_multi_buffer.popBack();
312 new_item->setLocalId(lid);
314 _updateItemSharedInfoInternalView();
317 m_added_items.add(lid);
335 bool m_use_new_finalize;
336 bool m_is_first_finalize;
337 bool m_has_unique_id_map;
363 int f = item->
flags();
371 int f = item->
flags();
379 void _badSameUniqueId(
Int64 unique_id)
const;
380 void _badUniqueIdMap()
const;
381 void _updateItemSharedInfoInternalView();
384 if (m_item_list_change_event.hasObservers())
385 _notifyRemove2(item);
387 void _notifyAdd(ItemInternal* item, Int64 uid)
389 if (m_item_list_change_event.hasObservers())
390 _notifyAdd2(item, uid);
392 void _notifyRemove2(ItemInternal* item);
393 void _notifyAdd2(ItemInternal* item, Int64 uid);
File containing event management mechanisms.
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.
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.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
eItemKind
Mesh entity type.
std::int32_t Int32
Signed integer type of 32 bits.