@@ -70,7 +70,8 @@ apply(MaterialModifierOperation* operation)
70
70
{
71
71
bool is_add = operation->isAdd ();
72
72
IMeshMaterial* mat = operation->material ();
73
- ConstArrayView<Int32> ids = operation->ids ();
73
+ ConstArrayView<Int32> orig_ids = operation->ids ();
74
+ ConstArrayView<Int32> ids = orig_ids;
74
75
75
76
auto * true_mat = ARCANE_CHECK_POINTER (dynamic_cast <MeshMaterial*>(mat));
76
77
@@ -157,9 +158,9 @@ apply(MaterialModifierOperation* operation)
157
158
// d'ajout) ou les mailles partielles en mailles pures (en cas de
158
159
// suppression).
159
160
info (4 ) << " Transform PartialPure for material name=" << true_mat->name ();
160
- _switchComponentItemsForMaterials (true_mat);
161
+ _switchCellsForMaterials (true_mat, orig_ids );
161
162
info (4 ) << " Transform PartialPure for environment name=" << env->name ();
162
- _switchComponentItemsForEnvironments (env);
163
+ _switchCellsForEnvironments (env, orig_ids );
163
164
164
165
// Si je suis mono-mat, alors mat->cells()<=>env->cells() et il ne faut
165
166
// mettre à jour que l'un des deux groupes.
@@ -194,7 +195,8 @@ apply(MaterialModifierOperation* operation)
194
195
* (suppression d'un matériau)
195
196
*/
196
197
void IncrementalComponentModifier::
197
- _switchComponentItemsForMaterials (const MeshMaterial* modified_mat)
198
+ _switchCellsForMaterials (const MeshMaterial* modified_mat,
199
+ ConstArrayView<Int32> ids)
198
200
{
199
201
const bool is_add = m_work_info.isAdd ();
200
202
@@ -207,16 +209,13 @@ _switchComponentItemsForMaterials(const MeshMaterial* modified_mat)
207
209
m_work_info.pure_local_ids .clear ();
208
210
m_work_info.partial_indexes .clear ();
209
211
210
- const MeshEnvironment* env = mat->trueEnvironment ();
211
- if (env != true_env)
212
- ARCANE_FATAL (" BAD ENV" );
213
212
MeshMaterialVariableIndexer* indexer = mat->variableIndexer ();
214
213
215
214
info (4 ) << " TransformCells (V3) is_add?=" << is_add << " indexer=" << indexer->name ();
216
215
217
- _computeCellsToTransform (mat);
218
-
216
+ _computeCellsToTransformForMaterial (mat, ids);
219
217
indexer->transformCellsV2 (m_work_info);
218
+ m_work_info.resetTransformedCells (ids);
220
219
221
220
info (4 ) << " NB_MAT_TRANSFORM=" << m_work_info.pure_local_ids .size () << " name=" << mat->name ();
222
221
@@ -242,7 +241,8 @@ _switchComponentItemsForMaterials(const MeshMaterial* modified_mat)
242
241
* en pure (dans le cas de suppression d'un matériau)
243
242
*/
244
243
void IncrementalComponentModifier::
245
- _switchComponentItemsForEnvironments (const IMeshEnvironment* modified_env)
244
+ _switchCellsForEnvironments (const IMeshEnvironment* modified_env,
245
+ ConstArrayView<Int32> ids)
246
246
{
247
247
const bool is_add = m_work_info.isAdd ();
248
248
@@ -264,8 +264,9 @@ _switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env)
264
264
265
265
info (4 ) << " TransformCells (V2) is_add?=" << is_add << " indexer=" << indexer->name ();
266
266
267
- _computeCellsToTransform ( );
267
+ _computeCellsToTransformForEnvironments (ids );
268
268
indexer->transformCellsV2 (m_work_info);
269
+ m_work_info.resetTransformedCells (ids);
269
270
270
271
info (4 ) << " NB_ENV_TRANSFORM=" << m_work_info.pure_local_ids .size ()
271
272
<< " name=" << env->name ();
@@ -283,7 +284,7 @@ _switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env)
283
284
* \brief Calcule les mailles à transformer pour le matériau \at mat.
284
285
*/
285
286
void IncrementalComponentModifier::
286
- _computeCellsToTransform (const MeshMaterial* mat)
287
+ _computeCellsToTransformForMaterial (const MeshMaterial* mat, ConstArrayView<Int32> ids )
287
288
{
288
289
const MeshEnvironment* env = mat->trueEnvironment ();
289
290
const Int16 env_id = env->componentId ();
@@ -293,23 +294,25 @@ _computeCellsToTransform(const MeshMaterial* mat)
293
294
ConstituentConnectivityList* connectivity = m_all_env_data->componentConnectivityList ();
294
295
ConstArrayView<Int16> cells_nb_env = connectivity->cellsNbEnvironment ();
295
296
296
- ENUMERATE_ (Cell, icell, all_cells ) {
297
+ for (Int32 local_id : ids ) {
297
298
bool do_transform = false ;
299
+ CellLocalId cell_id (local_id);
298
300
// En cas d'ajout on passe de pure à partiel s'il y a plusieurs milieux ou
299
301
// plusieurs matériaux dans le milieu.
300
302
// En cas de supression, on passe de partiel à pure si on est le seul matériau
301
303
// et le seul milieu.
304
+ const Int16 nb_env = cells_nb_env[local_id];
302
305
if (is_add) {
303
- do_transform = cells_nb_env[icell. itemLocalId ()] > 1 ;
306
+ do_transform = (nb_env > 1 ) ;
304
307
if (!do_transform)
305
- do_transform = connectivity->cellNbMaterial (icell , env_id) > 1 ;
308
+ do_transform = connectivity->cellNbMaterial (cell_id , env_id) > 1 ;
306
309
}
307
310
else {
308
- do_transform = cells_nb_env[icell. itemLocalId ()] == 1 ;
311
+ do_transform = (nb_env == 1 ) ;
309
312
if (do_transform)
310
- do_transform = connectivity->cellNbMaterial (icell , env_id) == 1 ;
313
+ do_transform = connectivity->cellNbMaterial (cell_id , env_id) == 1 ;
311
314
}
312
- m_work_info.setTransformedCell (icell , do_transform);
315
+ m_work_info.setTransformedCell (cell_id , do_transform);
313
316
}
314
317
}
315
318
@@ -320,22 +323,22 @@ _computeCellsToTransform(const MeshMaterial* mat)
320
323
* d'un milieu.
321
324
*/
322
325
void IncrementalComponentModifier::
323
- _computeCellsToTransform ( )
326
+ _computeCellsToTransformForEnvironments (ConstArrayView<Int32> ids )
324
327
{
325
328
ConstituentConnectivityList* connectivity = m_all_env_data->componentConnectivityList ();
326
329
ConstArrayView<Int16> cells_nb_env = connectivity->cellsNbEnvironment ();
327
330
CellGroup all_cells = m_material_mng->mesh ()->allCells ();
328
331
const bool is_add = m_work_info.isAdd ();
329
332
330
- ENUMERATE_ (Cell, icell, all_cells ) {
333
+ for (Int32 lid : ids ) {
331
334
bool do_transform = false ;
332
335
// En cas d'ajout on passe de pure à partiel s'il y a plusieurs milieux.
333
336
// En cas de supression, on passe de partiel à pure si on est le seul milieu.
334
337
if (is_add)
335
- do_transform = cells_nb_env[icell. itemLocalId () ] > 1 ;
338
+ do_transform = cells_nb_env[lid ] > 1 ;
336
339
else
337
- do_transform = cells_nb_env[icell. itemLocalId () ] == 1 ;
338
- m_work_info.setTransformedCell (icell , do_transform);
340
+ do_transform = cells_nb_env[lid ] == 1 ;
341
+ m_work_info.setTransformedCell (CellLocalId (lid) , do_transform);
339
342
}
340
343
}
341
344
0 commit comments