Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MaterialModifierOperation.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/* MaterialModifierOperation.h (C) 2000-2024 */
9/* */
10/* Operation to add/remove cells from a material. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_INTERNAL_MATERIALMODIFIEROPERATION_H
13#define ARCANE_MATERIALS_INTERNAL_MATERIALMODIFIEROPERATION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18#include "arcane/utils/NumArray.h"
19
21#include "arcane/materials/internal/MeshMaterialModifierImpl.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::Materials
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
35class MaterialModifierOperation
36{
37 public:
38
39 MaterialModifierOperation();
40
41 private:
42
43 MaterialModifierOperation(IMeshMaterial* mat, SmallSpan<const Int32> ids, bool is_add);
44
45 public:
46
47 static MaterialModifierOperation* createAdd(IMeshMaterial* mat, SmallSpan<const Int32> ids)
48 {
49 return new MaterialModifierOperation(mat, ids, true);
50 }
51 static MaterialModifierOperation* createRemove(IMeshMaterial* mat, SmallSpan<const Int32> ids)
52 {
53 return new MaterialModifierOperation(mat, ids, false);
54 }
55
56 public:
57
59 bool isAdd() const { return m_is_add; }
60
62 IMeshMaterial* material() const { return m_mat; }
63
65 SmallSpan<const Int32> ids() const { return m_ids.view(); }
66
67 public:
68
79 void filterIds();
80
81 private:
82
83 static void _filterValidIds(MaterialModifierOperation* operation, Int32Array& valid_ids);
85
86 private:
87
88 IMeshMaterial* m_mat = nullptr;
89 bool m_is_add = false;
91};
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96} // namespace Arcane::Materials
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101#endif
Operation to add or remove cells from a material.
IMeshMaterial * material() const
The material for which cells are to be added/removed.
bool isAdd() const
Indicates whether the operation is to add or remove cells from the material.
static Int32 _checkMaterialPresence(MaterialModifierOperation *operation)
Checks if the cells ids are already in the material mat.
static void _filterValidIds(MaterialModifierOperation *operation, Int32Array &valid_ids)
Filters the array of cells ids so that it is valid.
SmallSpan< const Int32 > ids() const
List of localId() of cells to add/remove.
View of an array of elements of type T.
Definition Span.h:805
1D data vector with value semantics (STL style).
Always enables tracing in Arcane parts concerning materials.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127
std::int32_t Int32
Signed integer type of 32 bits.