Skip to content

Commit

Permalink
Create SetMesh1dApiDimension and SetMesh2dApiDimension functions (#315
Browse files Browse the repository at this point in the history
…| GRIDEDIT-973_expose_undo_redo)
  • Loading branch information
lucacarniato authored Mar 21, 2024
1 parent 0cf62b2 commit 442a942
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
24 changes: 12 additions & 12 deletions libs/MeshKernelApi/include/MeshKernelApi/MeshKernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,6 @@ namespace meshkernelapi
/// @returns Error code
MKERNEL_API int mkernel_allocate_state(int projectionType, int& meshKernelId);

/// @brief Attempt to undo by one undo-action.
/// @param[in] meshKernelId The id of the mesh state.
/// @param[out] undone Indicates if the undo action was actually undone
/// @returns Error code
MKERNEL_API int mkernel_undo_state(int meshKernelId, bool& undone);

/// @brief Attempt to redo by one undo-action.
/// @param[in] meshKernelId The id of the mesh state.
/// @param[out] redone Indicates if the redo action was actually redone
/// @returns Error code
MKERNEL_API int mkernel_redo_state(int meshKernelId, bool& redone);

/// @brief Clear the undo state.
/// @param[in] meshKernelId The id of the mesh state.
/// @returns Error code
Expand Down Expand Up @@ -1433,6 +1421,18 @@ namespace meshkernelapi
int startIndex,
int endIndex);

/// @brief Attempt to redo by one undo-action.
/// @param[in] meshKernelId The id of the mesh state.
/// @param[out] redone Indicates if the redo action was actually redone
/// @returns Error code
MKERNEL_API int mkernel_redo_state(int meshKernelId, bool& redone);

/// @brief Attempt to undo by one undo-action.
/// @param[in] meshKernelId The id of the mesh state.
/// @param[out] undone Indicates if the undo action was actually undone
/// @returns Error code
MKERNEL_API int mkernel_undo_state(int meshKernelId, bool& undone);

#ifdef __cplusplus
}
#endif
Expand Down
15 changes: 15 additions & 0 deletions libs/MeshKernelApi/include/MeshKernelApi/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ namespace meshkernelapi
faceIndex++;
}
}

SetMesh2dApiDimensions(mesh2d, mesh2dApi);
}

/// @brief Sets the meshkernelapi::CurvilinearGrid data
Expand All @@ -384,6 +386,18 @@ namespace meshkernelapi
}
}

/// @brief Sets dimensions members of meshkernelapi::Mesh1D instance
/// @param[in] mesh1d The meshkernel::Mesh1D instance
/// @param[out] mesh1dApi The output meshkernelapi::Mesh1D instance
static void SetMesh1dApiDimension(const meshkernel::Mesh1D& mesh1d,
Mesh1D& mesh1dApi)
{
mesh1dApi.num_nodes = static_cast<int>(mesh1d.GetNumNodes());
mesh1dApi.num_valid_nodes = static_cast<int>(mesh1d.GetNumValidNodes());
mesh1dApi.num_edges = static_cast<int>(mesh1d.GetNumEdges());
mesh1dApi.num_valid_edges = static_cast<int>(mesh1d.GetNumValidEdges());
}

/// @brief Sets a meshkernelapi::Mesh1D data
/// @param[in] mesh1d The input meshkernel::Mesh1D instance
/// @param[out] mesh1dApi The output meshkernelapi::Mesh1D instance
Expand All @@ -404,6 +418,7 @@ namespace meshkernelapi
mesh1dApi.edge_nodes[edgeIndex] = static_cast<int>(mesh1d.GetEdge(e).second);
edgeIndex++;
}
SetMesh1dApiDimension(mesh1d, mesh1dApi);
}

/// @brief Generate a rectangular curvilinear grid
Expand Down
5 changes: 1 addition & 4 deletions libs/MeshKernelApi/src/MeshKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,7 @@ namespace meshkernelapi
throw meshkernel::MeshKernelError("The selected mesh kernel id does not exist.");
}

mesh1d.num_nodes = static_cast<int>(meshKernelState[meshKernelId].m_mesh1d->GetNumNodes());
mesh1d.num_valid_nodes = static_cast<int>(meshKernelState[meshKernelId].m_mesh1d->GetNumValidNodes());
mesh1d.num_edges = static_cast<int>(meshKernelState[meshKernelId].m_mesh1d->GetNumEdges());
mesh1d.num_valid_edges = static_cast<int>(meshKernelState[meshKernelId].m_mesh1d->GetNumValidEdges());
SetMesh1dApiDimension(*meshKernelState[meshKernelId].m_mesh1d, mesh1d);
}
catch (...)
{
Expand Down

0 comments on commit 442a942

Please sign in to comment.