Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
MeshMaterialBackup.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MeshMaterialBackup.h (C) 2000-2023 */
9/* */
10/* Saving/restoring material and medium values. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_MESHMATERIALBACKUP_H
13#define ARCANE_MATERIALS_MESHMATERIALBACKUP_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/ArrayView.h"
19#include "arcane/utils/Array.h"
20#include "arcane/utils/Ref.h"
21#include "arcane/utils/String.h"
22
23#include "arcane/core/ItemUniqueId.h"
24
26
27#include <map>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane::Materials
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38/*!
39 * \ingroup ArcaneMaterials
40 * \brief Saving/restoring material and medium values.
41 *
42 * Instances of this class can only be used for a single save and a single restore.
43 *
44 * It is possible to specify the name of a compression service
45 * for the data before saving via the setCompressorServiceName() method.
46 * If this method is not called, the default value is that of
47 * IMeshMaterialMng::dataCompressorServiceName().
48 */
49class ARCANE_MATERIALS_EXPORT MeshMaterialBackup
50: public TraceAccessor
51{
52 struct VarData;
53
54 public:
55
56 MeshMaterialBackup(IMeshMaterialMng* mm, bool use_unique_ids);
57 ~MeshMaterialBackup();
58
59 public:
60
61 //! Name of the service used to compress the data.
62 void setCompressorServiceName(const String& name);
63 const String& compressorServiceName() const { return m_compressor_service_name; }
64
65 public:
66
67 void saveValues();
68 void restoreValues();
69
70 private:
71
72 IMeshMaterialMng* m_material_mng;
73 bool m_use_unique_ids;
74 std::map<IMeshMaterialVariable*, VarData*> m_saved_data;
75 std::map<IMeshComponent*, SharedArray<Int32>> m_ids_array;
76 std::map<IMeshComponent*, SharedArray<ItemUniqueId>> m_unique_ids_array;
78 bool m_use_v2 = false;
79 String m_compressor_service_name;
80
81 private:
82
83 void _save();
84 void _restore();
85 void _saveIds(IMeshComponent* component);
86 bool _isValidComponent(IMeshMaterialVariable* var, IMeshComponent* component);
87 void _saveV1();
88 void _saveV2();
89 void _restoreV1();
90 void _restoreV2();
91};
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96} // namespace Arcane::Materials
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101#endif
Interface of a component (material or environment) of a mesh.
Interface for the material and environment manager of a mesh.
Interface of a material variable on a mesh.
void setCompressorServiceName(const String &name)
Name of the service used to compress the data.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
Always enables tracing in Arcane parts concerning materials.
class ARCANE_MATERIALS_EXPORT(64) SimdMatVarIndex
SIMD indexer on a component.