325 long nPreviousCells = m_numbering.size();
331 long firstChangedFlatId = std::min(nCurrentCells, nPreviousCells);
332 long firstChangedId = m_patch->
getCells().getSizeMarker(firstChangedFlatId, Element::NULL_ID);
333 for (
auto &adaptionInfo : adaptionData) {
334 if (adaptionInfo.entity != adaption::ENTITY_CELL) {
338 for (
const auto ¤tId : adaptionInfo.current) {
339 long currentFlatId = m_patch->
getCells().evalFlatIndex(currentId);
340 if (currentFlatId < firstChangedFlatId) {
341 firstChangedId = currentId;
342 firstChangedFlatId = currentFlatId;
348 m_mapping.resize(nCurrentCells);
349 for (
long flatId = 0; flatId < firstChangedFlatId; ++flatId) {
350 m_mapping[flatId] = flatId;
354 if (firstChangedId < 0) {
359 std::unordered_set<long> removedIds;
360 for (
auto &adaptionInfo : adaptionData) {
361 if (adaptionInfo.entity != adaption::ENTITY_CELL) {
365 for (
const auto &previousId : adaptionInfo.previous) {
366 removedIds.insert(previousId);
369 long nRemovedCells = removedIds.size();
372 std::unordered_map<long, long> previousFlatIds;
373 std::unordered_map<long, long> removedFlatIds;
374 previousFlatIds.reserve(nCurrentCells - firstChangedFlatId - nRemovedCells);
375 removedFlatIds.reserve(nRemovedCells);
376 for (
long previousFlatId = firstChangedFlatId; previousFlatId < nPreviousCells; ++previousFlatId) {
377 long previousId = m_numbering[previousFlatId];
378 if (removedIds.count(previousId) > 0) {
379 removedFlatIds.insert({{previousId, previousFlatId}});
381 previousFlatIds.insert({{previousId, previousFlatId}});
386 for (
auto &adaptionInfo : adaptionData) {
387 if (adaptionInfo.entity != adaption::ENTITY_CELL) {
393 if (adaptionInfo.previous.size() > 0) {
394 ancestorFlatId = removedFlatIds.at(adaptionInfo.previous[0]);
400 for (
const auto ¤tId : adaptionInfo.current) {
401 previousFlatIds.insert({{currentId, ancestorFlatId}});
405 std::unordered_map<long, long>().swap(removedFlatIds);
408 m_numbering.resize(nCurrentCells);
409 auto cellIterator = m_patch->
getCells().find(firstChangedId);
410 for (
long flatId = firstChangedFlatId; flatId < nCurrentCells; ++flatId) {
411 long cellId = cellIterator->getId();
413 m_numbering[flatId] = cellId;
414 m_mapping[flatId] = previousFlatIds[cellId];