diff --git a/libs/MeshKernelApi/include/MeshKernelApi/MKStateUndoAction.hpp b/libs/MeshKernelApi/include/MeshKernelApi/MKStateUndoAction.hpp index 3efddee82..b5a27bcdb 100644 --- a/libs/MeshKernelApi/include/MeshKernelApi/MKStateUndoAction.hpp +++ b/libs/MeshKernelApi/include/MeshKernelApi/MKStateUndoAction.hpp @@ -50,7 +50,7 @@ namespace meshkernelapi /// @brief Constructor. /// /// Keeps a reference to the active MeshKernelState and copies its pointers - MKStateUndoAction(MeshKernelState& mkState); + explicit MKStateUndoAction(MeshKernelState& mkState); private: /// @brief Swap the pointer in the active state (referred to by m_mkStateReference) with the copies of the pointers. diff --git a/libs/MeshKernelApi/src/MKStateUndoAction.cpp b/libs/MeshKernelApi/src/MKStateUndoAction.cpp index 79cc5ade6..cfc6611cd 100644 --- a/libs/MeshKernelApi/src/MKStateUndoAction.cpp +++ b/libs/MeshKernelApi/src/MKStateUndoAction.cpp @@ -1,3 +1,30 @@ +//---- GPL --------------------------------------------------------------------- +// +// Copyright (C) Stichting Deltares, 2011-2024. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +// contact: delft3d.support@deltares.nl +// Stichting Deltares +// P.O. Box 177 +// 2600 MH Delft, The Netherlands +// +// All indications and logos of, and references to, "Delft3D" and "Deltares" +// are registered trademarks of Stichting Deltares, and remain the property of +// Stichting Deltares. All rights reserved. +// +//------------------------------------------------------------------------------ + #include "MeshKernelApi/MKStateUndoAction.hpp" std::unique_ptr<meshkernelapi::MKStateUndoAction> meshkernelapi::MKStateUndoAction::Create(MeshKernelState& mkState) diff --git a/libs/MeshKernelApi/src/MeshKernel.cpp b/libs/MeshKernelApi/src/MeshKernel.cpp index baa1db9b9..186727f63 100644 --- a/libs/MeshKernelApi/src/MeshKernel.cpp +++ b/libs/MeshKernelApi/src/MeshKernel.cpp @@ -738,9 +738,6 @@ namespace meshkernelapi throw meshkernel::MeshKernelError("The selected mesh kernel id does not exist."); } - auto mk = meshKernelState[meshKernelId]; - - // TODO should it be an error if the this is not true, the mesh probably does not exist. if (meshKernelState[meshKernelId].m_mesh2d->GetNumNodes() > 0) { meshKernelState[meshKernelId].m_mesh2d->Administrate(); diff --git a/libs/MeshKernelApi/tests/src/UndoTests.cpp b/libs/MeshKernelApi/tests/src/UndoTests.cpp index 3cdcdab44..945290b8b 100644 --- a/libs/MeshKernelApi/tests/src/UndoTests.cpp +++ b/libs/MeshKernelApi/tests/src/UndoTests.cpp @@ -203,12 +203,7 @@ bool CheckUndoStateCount(const int meshKernelId, const int expectedCommitted, co int restoredCount; int errorCode = mkapi::mkernel_undo_state_count_for_id(meshKernelId, committedCount, restoredCount); - if (errorCode != mk::ExitCode::Success) - { - return false; - } - - return committedCount == expectedCommitted && restoredCount == expectedRestored; + return errorCode == mk::ExitCode::Success && committedCount == expectedCommitted && restoredCount == expectedRestored; } TEST(UndoTests, BasicAllocationDeallocationTest) @@ -911,10 +906,7 @@ TEST(UndoTests, UnstructuredGridConnection) 6.0, 6.0, 6.0, 7.0, 7.0, 7.0, 8.0, 8.0, 8.0}; // Shift the nodes of subdomain 1 slightly to match the generated mesh - for (size_t i = 0; i < expectedNodesDisconnectedX.size(); ++i) - { - expectedNodesDisconnectedX[i] += fraction * clg2DeltaX; - } + std::ranges::for_each (expectedNodesDisconnectedX, [fraction, clg2DeltaX](double& value){value += fraction * clg2DeltaX;}); for (size_t i = 0; i < static_cast<size_t>(mesh2d.num_nodes); ++i) {