From f85bb56e9b3d11d46c30ccc6dcff32070e2833f2 Mon Sep 17 00:00:00 2001 From: Luca Carniato Date: Wed, 27 Mar 2024 16:56:57 +0100 Subject: [PATCH 1/5] Add Mesh2dInsertEdgeFromCoordinates --- src/MeshKernelNET/Api/IMeshKernelApi.cs | 19 +++++++++++++++++++ src/MeshKernelNET/Api/MeshKernelApi.cs | 20 ++++++++++++++++++++ src/MeshKernelNET/Native/MeshKernelDll.cs | 22 ++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/MeshKernelNET/Api/IMeshKernelApi.cs b/src/MeshKernelNET/Api/IMeshKernelApi.cs index d90a414..ab606ca 100644 --- a/src/MeshKernelNET/Api/IMeshKernelApi.cs +++ b/src/MeshKernelNET/Api/IMeshKernelApi.cs @@ -1040,6 +1040,25 @@ int Mesh2dInitializeOrthogonalization(int meshKernelId, /// Error code int Mesh2dInsertEdge(int meshKernelId, int startVertexIndex, int endVertexIndex, ref int edgeIndex); + /// @brief Insert a new mesh2d edge from 2 coordinates + /// The id of the mesh state + /// The index of the first node to connect + /// The index of the second node to connect + /// The index of the first node to connect + /// The index of the second node to connect + /// The index of the first node + /// The index of the second node + /// The index of the new generated edge + /// Error code + int Mesh2dInsertEdgeFromCoordinates(int meshKernelId, + double firstNodeX, + double firstNodeY, + double secondNodeX, + double secondNodeY, + ref int firstNodeIndex, + ref int secondNodeIndex, + ref int edgeIndex); + /// /// Inserts a new vertex /// diff --git a/src/MeshKernelNET/Api/MeshKernelApi.cs b/src/MeshKernelNET/Api/MeshKernelApi.cs index 2d4a26b..3956aa9 100644 --- a/src/MeshKernelNET/Api/MeshKernelApi.cs +++ b/src/MeshKernelNET/Api/MeshKernelApi.cs @@ -971,6 +971,26 @@ public int Mesh2dInsertEdge(int meshKernelId, int startVertexIndex, int endVerte return MeshKernelDll.Mesh2dInsertEdge(meshKernelId, startVertexIndex, endVertexIndex, ref edgeIndex); } + /// + public int Mesh2dInsertEdgeFromCoordinates(int meshKernelId, + double firstNodeX, + double firstNodeY, + double secondNodeX, + double secondNodeY, + ref int firstNodeIndex, + ref int secondNodeIndex, + ref int edgeIndex) + { + return MeshKernelDll.Mesh2dInsertEdgeFromCoordinates(meshKernelId, + firstNodeX, + firstNodeY, + secondNodeX, + secondNodeY, + ref firstNodeIndex, + ref secondNodeIndex, + ref edgeIndex); + } + public int Mesh2dInsertNode(int meshKernelId, double xCoordinate, double yCoordinate, ref int vertexIndex) { return MeshKernelDll.Mesh2dInsertNode(meshKernelId, xCoordinate, yCoordinate, ref vertexIndex); diff --git a/src/MeshKernelNET/Native/MeshKernelDll.cs b/src/MeshKernelNET/Native/MeshKernelDll.cs index 0c7784d..565e3db 100644 --- a/src/MeshKernelNET/Native/MeshKernelDll.cs +++ b/src/MeshKernelNET/Native/MeshKernelDll.cs @@ -1271,6 +1271,28 @@ internal static extern int Mesh2dInitializeOrthogonalization([In] int meshKernel [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_edge", CallingConvention = CallingConvention.Cdecl)] internal static extern int Mesh2dInsertEdge([In] int meshKernelId, [In] int startVertexIndex, [In] int endVertexIndex, [In][Out] ref int edgeIndex); + /// + /// Insert a new mesh2d edge from 2 coordinates + /// + /// The id of the mesh state + /// The index of the first node to connect + /// The index of the second node to connect + /// The index of the first node to connect + /// The index of the second node to connect + /// The index of the first node + /// The index of the second node + /// The index of the new generated edge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_edge_from_coordinates", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dInsertEdgeFromCoordinates([In] int meshKernelId, + [In] double firstNodeX, + [In] double firstNodeY, + [In] double secondNodeX, + [In] double secondNodeY, + [In][Out] ref int firstNodeIndex, + [In][Out] ref int secondNodeIndex, + [In][Out] ref int edgeIndex); + /// /// Insert a new mesh2d edge connecting two nodes /// From a258f39cea5e8fded969162d6780c6c74bfeff76 Mon Sep 17 00:00:00 2001 From: Luca Carniato Date: Wed, 27 Mar 2024 17:44:43 +0100 Subject: [PATCH 2/5] Add Mesh2dInsertEdgeFromCoordinatesThroughApi --- Directory.Packages.props | 2 +- src/MeshKernelNET/Native/MeshKernelDll.cs | 3400 +++++++++--------- test/MeshKernelNETTest/Api/MeshKernelTest.cs | 58 + 3 files changed, 1759 insertions(+), 1701 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index ef9d810..0a07bb5 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,7 +3,7 @@ true - + diff --git a/src/MeshKernelNET/Native/MeshKernelDll.cs b/src/MeshKernelNET/Native/MeshKernelDll.cs index 565e3db..82607c2 100644 --- a/src/MeshKernelNET/Native/MeshKernelDll.cs +++ b/src/MeshKernelNET/Native/MeshKernelDll.cs @@ -1,1702 +1,1702 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using MeshKernelNET.Helpers; - -namespace MeshKernelNET.Native -{ - // never hit by code coverage because tests use remoting and this only contains dll imports - [ExcludeFromCodeCoverage] - internal static class MeshKernelDll - { - private const string MeshKernelDllName = "MeshKernelApi.dll"; - - static MeshKernelDll() - { - string dir = Path.GetDirectoryName(typeof(MeshKernelDll).Assembly.Location); - NativeLibrary.LoadNativeDll(MeshKernelDllName, Path.Combine(dir, @"win-x64\native")); - } - - /// - /// Create a new mesh state and return the generated - /// - /// - /// - /// Cartesian (0), spherical (1) or spherical accurate(2) mesh - /// Identifier for the created grid state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_allocate_state", CallingConvention = CallingConvention.Cdecl)] - internal static extern int AllocateState([In] int projectionType, [In][Out] ref int meshKernelId); - - /// - /// Clear the undo state - /// - /// The id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_clear_undo_state", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ClearUndoState([In] int meshKernelId); - - /// - /// Computes 1d-2d contacts, where 1d nodes are connected to the closest 2d faces at the boundary - /// (ggeo_make1D2DRiverLinks_dll) - /// - /// The id of the mesh state - /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) - /// The polygon selecting the faces to connect - /// - /// The radius used for searching neighboring faces, if equal to doubleMissingValue, the search - /// radius will be calculated internally - /// - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_boundary", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ContactsComputeBoundary([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative polygons, [In] double searchRadius); - - /// - /// Computes 1d-2d contacts, where a single 1d node is connected to multiple 2d face circumcenters - /// (ggeo_make1D2Dembeddedlinks_dll) - /// - /// The id of the mesh state - /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_multiple", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ContactsComputeMultiple([In] int meshKernelId, [In] IntPtr oneDNodeMask); - - /// - /// Computes 1d-2d contacts, where each single 1d node is connected to one mesh2d face circumcenter - /// (ggeo_make1D2Dinternalnetlinks_dll) - /// - /// The id of the mesh state - /// The mask to apply to 1d nodes (1 = connect node, 0 = do not connect) - /// The polygons selecting the area where the 1d-2d contacts will be generated - /// - /// The projection factor used for generating the contacts when 1d nodes are not inside the - /// 2d mesh - /// - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_single", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ContactsComputeSingle([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative polygons, [In] double projectionFactor); - - /// - /// Computes 1d-2d contacts, where 1d nodes are connected to the 2d faces mass centers containing the input point - /// (ggeo_make1D2Dstreetinletpipes_dll) - /// - /// The id of the mesh state - /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) - /// The points selecting the faces to connect - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_with_points", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ContactsComputeWithPoints([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative points); - - /// - /// Computes 1d-2d contacts, where a 2d face per polygon is connected to the closest 1d node - /// (ggeo_make1D2Droofgutterpipes_dll) - /// - /// The id of the mesh state - /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) - /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) - /// The polygons to connect - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_with_polygons", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ContactsComputeWithPolygons([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative polygons); - - /// - /// Gets the 1d-2d contacts indices (from index / to indices) - /// - /// The id of the mesh state - /// Contacts data - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_get_data", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ContactsGetData([In] int meshKernelId, [In][Out] ref ContactsNative contacts); - - /// - /// Gets the number of 1d-2d contacts - /// - /// The id of the mesh state - /// Contacts data, filled on the dimension part - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_get_dimensions", CallingConvention = CallingConvention.Cdecl)] - internal static extern int ContactsGetDimensions([In] int meshKernelId, [In][Out] ref ContactsNative contacts); - - /// - /// Make curvilinear grid from splines with an advancing front. - /// - /// Id of the mesh state - /// The input splines corners - /// The input parameters to generate the curvilinear grid - /// The parameters of the advancing front algorithm - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeOrthogonalGridFromSplines([In] int meshKernelId, - [In] ref GeometryListNative geometryListNative, - [In] ref CurvilinearParametersNative curvilinearParametersNative, - [In] ref SplinesToCurvilinearParametersNative splinesToCurvilinearParametersNative); - - /// - /// Computes the curvature of a curvilinear grid. - /// - /// Id of the mesh state - /// The direction in which to compute the smoothness (0 for M direction, 1 for N direction) - /// The grid curvature values in the selected direction - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_curvature", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeCurvature([In] int meshKernelId, [In] int direction, [In][Out] IntPtr curvature); - - /// - /// Computes the smoothness of a curvilinear grid. - /// - /// Id of the mesh state - /// The direction in which to compute the smoothness (0 for m direction, 1 for n direction) - /// The grid smoothness values in the selected direction - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_smoothness", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeSmoothness([In] int meshKernelId, [In] int direction, [In][Out] IntPtr smoothness); - - /// - /// Computes a curvilinear mesh in a polygon. 3 separate polygon nodes need to be selected. - /// - /// >Id of the mesh state - /// The input polygons - /// The first selected node - /// The second selected node - /// - /// The third node< - /// Use (true/false) the fourth polygon side to compute the curvilinear grid - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_transfinite_from_polygon", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeTransfiniteFromPolygon([In] int meshKernelId, - [In] ref GeometryListNative geometryListNative, - [In] int firstNode, - [In] int secondNode, - [In] int thirdNode, - [In] bool useFourthSide); - - /// - /// Generates curvilinear grid from splines with transfinite interpolation - /// - /// The id of the mesh state - /// The splines - /// The curvilinear parameters - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_transfinite_from_splines", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeTransfiniteFromSplines([In] int meshKernelId, - [In] ref GeometryListNative geometryListNativeIn, - [In] ref CurvilinearParametersNative curvilinearParametersNative); - - /// - /// Computes a curvilinear mesh in a triangle. 3 separate polygon nodes need to be selected. - /// - /// >Id of the mesh state - /// The input polygons - /// The first selected node - /// The second selected node - /// The third node - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_transfinite_from_triangle", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeTransfiniteFromTriangle([In] int meshKernelId, - [In] ref GeometryListNative geometryListNative, - [In] int firstNode, - [In] int secondNode, - [In] int thirdNode); - - /// - /// Convert a curviliner mesh stored in meshkernel to an unstructured curvilinear mesh - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_convert_to_mesh2d", CallingConvention = CallingConvention.Cdecl)] - public static extern int CurvilinearConvertToMesh2D([In] int meshKernelId); - - /// - /// Delete the node closest to a point - /// - /// Id of the mesh state - /// The x coordinate of the point - /// The y coordinate of the point - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_delete_node", CallingConvention = CallingConvention.Cdecl)] - public static extern int CurvilinearDeleteNode([In] int meshKernelId, [In] double xPointCoordinate, [In] double yPointCoordinate); - - /// - /// Finalizes curvilinear grid from splines algorithm - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_delete_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] - public static extern int CurvilinearDeleteOrthogonalGridFromSplines([In] int meshKernelId); - - /// - /// Directional curvilinear grid de-refinement. Grid lines are removed perpendicularly to the segment defined by - /// lowerLeftCorner and xUpperRightCorner. - /// - /// Id of the mesh state - /// The x coordinate of the lower left corner of the block to de-refine - /// The y coordinate of the lower left corner of the block to de-refine - /// The x coordinate of the upper right corner of the block to de-refine - /// The y coordinate of the upper right corner of the block to de-refine - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_derefine", CallingConvention = CallingConvention.Cdecl)] - public static extern int CurvilinearDerefine([In] int meshKernelId, - [In] double xLowerLeftCorner, - [In] double yLowerLeftCorner, - [In] double xUpperRightCorner, - [In] double yUpperRightCorner); - - /// - /// Finalizes the line shift algorithm - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_finalize_line_shift", CallingConvention = CallingConvention.Cdecl)] - public static extern int CurvilinearFinalizeLineShift([In] int meshKernelId); - - /// - /// Finalizes the curvilinear orthogonalization algorithm - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_finalize_orthogonalize", CallingConvention = CallingConvention.Cdecl)] - public static extern int CurvilinearFinalizeOrthogonalize([In] int meshKernelId); - - /// - /// Gets the curvilinear grid data as a CurvilinearGrid struct (converted as set of edges and nodes) - /// - /// Id of the mesh state - /// The structure containing the curvilinear grid arrays - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_get_data", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearGetData([In] int meshKernelId, [In][Out] ref CurvilinearGridNative curvilinearGridNative); - - /// - /// Gets the curvilinear grid dimensions as a CurvilinearGrid struct (converted as set of edges and nodes). - /// - /// Id of the mesh state - /// The structure containing the dimensions of the curvilinear grid - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_get_dimensions", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearGetDimensions([In] int meshKernelId, [In][Out] ref CurvilinearGridNative curvilinearGridNative); - - /// - /// Initializes the curvilinear line shift algorithm - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_initialize_line_shift", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearInitializeLineShift([In] int meshKernelId); - - /// - /// Generates a curvilinear grid from splines with the advancing front method. Initialization step (interactive) - /// - /// Id of the mesh state - /// The input splines corners - /// The input parameters to generate the curvilinear grid - /// The parameters of the advancing front algorithm - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_initialize_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearInitializeOrthogonalGridFromSplines([In] int meshKernelId, - [In] ref GeometryListNative geometryListNative, - [In] ref CurvilinearParametersNative curvilinearParametersNative, - [In] ref SplinesToCurvilinearParametersNative splinesToCurvilinearParameters); - - /// - /// Initializes the orthogonal curvilinear algorithm - /// - /// The id of the mesh state - /// The orthogonalization parameters to use in the algorithm - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_initialize_orthogonalize", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearInitializeOrthogonalize([In] int meshKernelId, - [In] ref OrthogonalizationParametersNative orthogonalizationParameters); - - /// - /// Inserts a new face on a curvilinear grid. The new face will be inserted on top of the closest edge by linear - /// extrapolation. - /// - /// Id of the mesh state - /// - /// The x coordinate of the point used for finding the closest face/param> - /// The y coordinate of the point used for finding the closest face - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_insert_face", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearInsertFace([In] int meshKernelId, [In] double xCoordinate, [In] double yCoordinate); - - /// - /// One advancement of the front in curvilinear grid from splines (interactive) - /// - /// The id of the mesh state - /// - /// The layer index/param> - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_iterate_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearIterateOrthogonalGridFromSplines([In] int meshKernelId, [In] int layer); - - /// - /// Attracts/repulses grid lines in a block towards another set grid line - /// - /// The id of the mesh state - /// - /// The attraction/repulsion parameter. If positive the grid lines will be attracted - /// towards the set line, if negative the lines will be repulsed - /// - /// The x coordinate of the first node of the set line - /// The y coordinate of the first node of the set line - /// The x coordinate of the second node of the set line - /// The y coordinate of the second node of the set line - /// The x coordinate of the lower left corner of the block where the operation is performed - /// The y coordinate of the lower left corner of the block where the operation is performed - /// - /// The x coordinate of the upper right corner of the block where the operation is - /// performed - /// - /// - /// The y coordinate of the upper right corner of the block where the operation is - /// performed - /// - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_line_attraction_repulsion", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearLineAttractionRepulsion([In] int meshKernelId, - [In] double repulsionParameter, - [In] double xFirstNodeOnTheLine, - [In] double yFirstNodeOnTheLine, - [In] double xSecondNodeOnTheLine, - [In] double ySecondNodeOnTheLine, - [In] double xLowerLeftCorner, - [In] double yLowerLeftCorner, - [In] double xUpperRightCorner, - [In] double yUpperRightCorner); - - /// - /// Mirrors a boundary gridline outwards. The boundary grid line is defined by its starting and ending points - /// - /// The id of the mesh state - /// The x coordinate of the first node of the set line - /// The x coordinate of the first node of the set line - /// The y coordinate of the first node of the set line - /// The x coordinate of the second node of the set line - /// The y coordinate of the second node of the set line - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_line_mirror", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearLineMirror([In] int meshKernelId, - [In] double mirroringFactor, - [In] double xFirstGridLineNode, - [In] double yFirstGridLineNode, - [In] double xSecondGridLineNode, - [In] double ySecondGridLineNode); - - /// @brief Computes the new grid, shifting the line towards the moved nodes and distributing the shifting in block specified before - /// The id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_line_shift", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearLineShift([In] int meshKernelId); - - /// - /// Make a rectangular grid - /// - /// Id of the mesh state - /// The structure containing the make grid parameters - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_rectangular_grid", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeRectangularGrid([In] int meshKernelId, - [In] ref MakeGridParametersNative makeGridParametersNative); - - /// - /// Make a rectangular grid from polygons - /// - /// Id of the mesh state - /// The structure containing the make grid parameters - /// The polygon to account for - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_rectangular_grid_from_polygon", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeRectangularGridFromPolygon([In] int meshKernelId, - [In] ref MakeGridParametersNative makeGridParametersNative, - [In] ref GeometryListNative geometryListNative); - - /// - /// Makes rectangular grid based on a defined on an extension - /// - /// Id of the mesh state - /// The structure containing the make grid parameters - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_rectangular_grid_on_extension", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearComputeRectangularGridOnExtension([In] int meshKernelId, [In] ref MakeGridParametersNative makeGridParametersNative); - - /// - /// Moves a point of a curvilinear grid from one location to another - /// - /// The id of the mesh state - /// The x coordinate of point to move - /// The y coordinate of point to move - /// The new x coordinate of the point - /// The new y coordinate of the point - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_move_node", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearMoveNode([In] int meshKernelId, - [In] double xFromPoint, - [In] double yFromPoint, - [In] double xToPoint, - [In] double yToPoint); - - /// - /// Moves a node of the line to shift, the operation can be performed multiple times. - /// - /// The id of the mesh state - /// The x coordinate of the node to move (the closest curvilinear grid node will be found) - /// The y coordinate of the node to move (the closest curvilinear grid node will be found) - /// The x coordinate of the new node position - /// The y coordinate of the new node position - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_move_node_line_shift", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearMoveNodeLineShift([In] int meshKernelId, - [In] double xFromCoordinate, - [In] double yFromCoordinate, - [In] double xToCoordinate, - [In] double yToCoordinate); - - /// - /// Orthogonalize a curvilinear grid - /// - /// The id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_orthogonalize", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearOrthogonalize([In] int meshKernelId); - - /// - /// Directional curvilinear grid refinement. Additional gridlines are added perpendicularly to the segment defined by - /// lowerLeftCorner and xUpperRightCorner. - /// - /// The id of the mesh state - /// The x coordinate of the lower left corner of the block to refine - /// The y coordinate of the lower left corner of the block to refine - /// The x coordinate of the upper right corner of the block to refine - /// The y coordinate of the upper right corner of the block to refine - /// The number of grid lines to add between the firstPoint and the secondPoint - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_refine", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearRefine([In] int meshKernelId, - [In] double xLowerLeftCorner, - [In] double yLowerLeftCorner, - [In] double xUpperRightCorner, - [In] double yUpperRightCorner, - [In] int refinement); - - /// - /// Converts curvilinear grid to mesh and refreshes the state (interactive) - /// - /// The id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_refresh_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearRefreshOrthogonalGridFromSplines([In] int meshKernelId); - - /// - /// Sets the curvilinear grid - /// - /// The id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearSet([In] int meshKernelId, [In] ref CurvilinearGridNative grid); - - /// - /// Defines a block on the curvilinear where the shifting is distributed - /// - /// The id of the mesh state - /// The x coordinate of the lower left corner of the block - /// The y coordinate of the lower left corner of the block - /// The x coordinate of the upper right corner of the block - /// The y coordinate of the upper right corner of the block - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_block_line_shift", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearSetBlockLineShift([In] int meshKernelId, - [In] double xLowerLeftCorner, - [In] double yLowerLeftCorner, - [In] double xUpperRightCorner, - [In] double yUpperRightCorner); - - /// - /// efine a block on the curvilinear grid where to perform orthogonalization - /// - /// The meshKernelId of the block to orthogonalize - /// The xLowerLeftCorner of the block to orthogonalize - /// The yLowerLeftCorner of the block to orthogonalize - /// The xUpperRightCorner of the block to orthogonalize - /// The yUpperRightCorner of the block to orthogonalize - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_block_orthogonalize", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearSetBlockOrthogonalize([In] int meshKernelId, - [In] double xLowerLeftCorner, - [In] double yLowerLeftCorner, - [In] double xUpperRightCorner, - [In] double yUpperRightCorner); - - /// - /// Freezes a line in the curvilinear orthogonalization process - /// - /// The id of the mesh state - /// The x coordinate of the first point of the line to freeze - /// The y coordinate of the first point of the line to freeze - /// The x coordinate of the second point of the line to freeze - /// The y coordinate of the second point of the line to freeze - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_frozen_lines_orthogonalize", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearSetFrozenLinesOrthogonalize([In] int meshKernelId, - [In] double xFirstGridLineNode, - [In] double yFirstGridLineNode, - [In] double xSecondGridLineNode, - [In] double ySecondGridLineNode); - - /// - /// Sets the start and end nodes of the line to shift - /// - /// The meshKernelId of the block to orthogonalize - /// The x coordinate of the first curvilinear grid node to shift - /// The y coordinate of the first curvilinear grid node to shift - /// The x coordinate of the second curvilinear grid node to shift - /// The y coordinate of the second curvilinear grid node to shift - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_line_line_shift", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearSetLineLineShift([In] int meshKernelId, - [In] double xFirstGridLineNode, - [In] double yFirstGridLineNode, - [In] double xSecondGridLineNode, - [In] double ySecondGridLineNode); - - /// - /// Smooths a curvilinear grid - /// - /// The meshKernelId of the block to orthogonalize - /// The number of smoothing iterations to perform - /// The x coordinate of the lower left corner of the block to smooth - /// The y coordinate of the lower left corner of the block to smooth - /// The x coordinate of the right corner of the block to smooth - /// The y coordinate of the upper right corner of the block to smooth - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_smoothing", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearSmoothing([In] int meshKernelId, - [In] int smoothingIterations, - [In] double xLowerLeftCorner, - [In] double yLowerLeftCorner, - [In] double xUpperRightCorner, - [In] double yUpperRightCorner); - - /// - /// Smooths a curvilinear grid along the direction specified by a segment - /// - /// The id of the mesh state - /// The number of smoothing iterations to perform - /// The x coordinate of the first curvilinear grid node - /// The y coordinate of the first curvilinear grid node - /// The x coordinate of the second curvilinear grid node - /// The y coordinate of the second curvilinear grid node - /// The x coordinate of the lower left corner of the smoothing area - /// The y coordinate of the lower left corner of the smoothing area - /// The x coordinate of the upper right corner of the smoothing area - /// The y coordinate of the upper right corner of the smoothing area - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_smoothing_directional", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CurvilinearSmoothingDirectional([In] int meshKernelId, - [In] int smoothingIterations, - [In] double xFirstGridlineNode, - [In] double yFirstGridlineNode, - [In] double xSecondGridLineNode, - [In] double ySecondGridLineNode, - [In] double xLowerLeftCornerSmoothingArea, - [In] double yLowerLeftCornerSmoothingArea, - [In] double xUpperRightCornerSmoothingArea, - [In] double yUpperRightCornerSmoothingArea); - - /// - /// Deallocate mesh state - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_deallocate_state", CallingConvention = CallingConvention.Cdecl)] - internal static extern int DeallocateState([In] int meshKernelId); - - /// - /// Gets an int indicating the closest point averaging method type - /// - /// The int indicating the closest point averaging method type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_closest_point", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAveragingMethodClosestPoint([In][Out] ref int method); - - /// - /// Gets an int indicating the inverse distance weights averaging method type - /// - /// The int indicating the inverse weight distance averaging method type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_inverse_distance_weighting", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAveragingMethodInverseDistanceWeighting([In][Out] ref int method); - - /// - /// Gets an int indicating the max value averaging method type - /// - /// The int indicating the max value averaging method type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_max", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAveragingMethodMax([In][Out] ref int method); - - /// - /// Gets an int indicating the minimum averaging method type - /// - /// The int indicating the minimum averaging method type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_min", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAveragingMethodMin([In][Out] ref int method); - - /// - /// Gets an int indicating the minimum absolute value averaging method type - /// - /// The int indicating the minimum absolute value averaging method type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_min_absolute_value", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAveragingMethodMinAbsoluteValue([In][Out] ref int method); - - /// - /// Gets an int indicating the simple averaging method type - /// - /// The int indicating the averaging method type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_simple_averaging", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAveragingMethodSimpleAveraging([In][Out] ref int method); - - /// - /// Gets an int indicating the edge location type - /// - /// The int indicating the edge location type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_edges_location_type", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetEdgesLocationType([In][Out] ref int type); - - /// - /// Gets a pointer to error message - /// - /// The pointer to the latest error message - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetError([In][Out] IntPtr message); - - /// - /// Gets the success exit code - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_success", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeSuccess([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type MeshKernelError - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_meshkernel_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeMeshKernelError([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type NotImplementedError - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_not_implemented_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeNotImplementedError([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type AlgorithmError - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_algorithm_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeAlgorithmError([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type ConstraintError - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_constraint_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeConstraintError([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type MeshGeometryError - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_mesh_geometry_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeMeshGeometryError([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type LinearAlgebraError - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_linear_algebra_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeLinearAlgebraError([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type RangeError - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_range_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeRangeError([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type StdLibException - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_stdlib_exception", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeStdLibException([In][Out] ref int exitCode); - - /// - /// Gets the exit code of an exception of type UnknownException - /// - /// The exit code - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_unknown_exception", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetExitCodeUnknownException([In][Out] ref int exitCode); - - /// - /// Gets an int indicating the faces location type - /// - /// The int indicating the face location type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_faces_location_type", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetFacesLocationType([In][Out] ref int type); - - /// - /// get geometry error - /// - /// The index of the erroneous entity - /// The entity type (node, edge or face, see MeshLocations) - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_geometry_error", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetGeometryError([In][Out] ref int invalidIndex, [In][Out] ref int type); - - /// - /// Gets an int indicating the node location type - /// - /// The int indicating the node location type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_nodes_location_type", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetNodesLocationType([In][Out] ref int type); - - /// - /// Gets the coordinate projection of the meshkernel state - /// - /// The id of the mesh state - /// The int indicating the projection type - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetProjection([In] int meshKernelId, [In][Out] ref int projection); - - /// - /// Gets an int indicating the cartesian projection - /// - /// The int indicating the cartesian projection - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection_cartesian", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetProjectionCartesian([In][Out] ref int projection); - - /// - /// Gets an int indicating the spherical projection - /// - /// The int indicating the spherical projection - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection_spherical", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetProjectionSpherical([In][Out] ref int projection); - - /// - /// Gets an int indicating the spherical accurate projection - /// - /// The int indicating the spherical accurate projection - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection_spherical_accurate", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetProjectionSphericalAccurate([In][Out] ref int projection); - - /// - /// Get spline intermediate points - /// - /// The input corner nodes of the splines - /// The output spline - /// The number of spline vertices between the corners points - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_splines", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetSplines([In] ref GeometryListNative geometryListNativeIn, - [In][Out] ref GeometryListNative geometryListNativeOut, - [In] int numberOfPointsBetweenVertices); - - /// - /// Gets the version string - /// - /// The version string - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_version", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetVersion([In][Out] IntPtr version); - - /// - /// Gets the Mesh1D data - /// - /// The id of the mesh state - /// The mesh1d of the block to orthogonalize - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh1d_get_data", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh1dGetData([In] int meshKernelId, [In][Out] ref Mesh1DNative mesh1d); - - /// - /// Gets the Mesh1D data dimensions - /// - /// The id of the mesh state - /// The structure containing the dimensions of the Mesh1D - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh1d_get_dimensions", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh1dGetDimensions([In] int meshKernelId, [In][Out] ref Mesh1DNative mesh1d); - - /// - /// Sets the meshkernel::Mesh1D state - /// - /// The id of the mesh state - /// The mesh1d - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh1d_set", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh1dSet(int meshKernelId, [In] ref Mesh1DNative mesh1d); - - /// - /// AveragingInterpolation interpolation - /// - /// The id of the mesh state - /// The samples coordinates and values - /// The location type - /// The averaging method - /// The relative search size around the location - /// - /// The minimum number of samples used for some interpolation algorithms to perform a valid - /// interpolation - /// - /// The interpolation results with x and y coordinates - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_averaging_interpolation", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dAveragingInterpolation([In] int meshKernelId, - [In] ref GeometryListNative samples, - [In] int locationType, - [In] int averagingMethodType, - [In] double relativeSearchSize, - [In] int minNumSamples, - [In][Out] ref GeometryListNative results); - - /// - /// Performs inner orthogonalization iteration, by slowly moving the mesh nodes to new optimal positions (interactive mode) - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_compute_inner_ortogonalization_iteration", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dComputeInnerOrtogonalizationIteration([In] int meshKernelId); - - /// - /// Mesh2d orthogonalization - /// - /// Id of the mesh state - /// The option to determine how to snap to land boundaries - /// The structure containing the orthogonalization parameters - /// The polygon where to perform the orthogonalization - /// The land boundaries to account for in the orthogonalization process - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_compute_orthogonalization", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dComputeOrthogonalization([In] int meshKernelId, - [In] int projectToLandBoundaryOption, - [In] ref OrthogonalizationParametersNative orthogonalizationParametersNative, - [In] ref GeometryListNative geometryListNativePolygon, - [In] ref GeometryListNative geometryListNativeLandBoundaries); - - /// - /// Converts the projection of a mesh2d - /// - /// The id of the mesh state - /// The new projection for the mesh - /// The UTM zone and information string - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_convert_projection", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dConvertProjection([In] int meshKernelId, - [In] int projection, - [In][MarshalAs(UnmanagedType.LPStr)] string zone); - - /// - /// Count the number of hanging edges in a mesh2d. - /// - /// The id of the mesh state - /// The number of hanging edges - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_hanging_edges", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dCountHangingEdges([In] int meshKernelId, [In][Out] ref int numEdges); - - /// - /// Counts the number of polygon vertices contained in the mesh boundary polygon - /// - /// Id of the mesh state - /// The number of polygon points - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_mesh_boundaries_as_polygons", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dCountMeshBoundariesAsPolygons([In] int meshKernelId, [In][Out] ref int numberOfPolygonVertices); - - /// - /// Counts the mesh2d small flow edge centers - /// - /// The id of the mesh state - /// The smallFlowEdgesLengthThreshold of the block to orthogonalize - /// The numSmallFlowEdges of the block to orthogonalize - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_small_flow_edge_centers", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dCountSmallFlowEdgeCenters([In] int meshKernelId, - [In] double smallFlowEdgesLengthThreshold, - [In][Out] ref int numSmallFlowEdges); - - /// - /// Deletes a mesh in a polygon using several options - /// - /// Id of the mesh state - /// The polygon where to perform the operation - /// The deletion option (to be detailed) - /// Inverts the deletion of selected features - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete", CallingConvention = CallingConvention.Cdecl)] - public static extern int Mesh2dDelete([In] int meshKernelId, [In] ref GeometryListNative geometryListNative, [In] int deletionOption, [In] bool invertDeletion); - - /// - /// Deletes the closest mesh edge within the search radius from the input point - /// - /// Id of the mesh state - /// x coordinate of the vertex - /// y coordinate of the vertex - /// The x coordinate of the lower left corner of the bounding box - /// The y coordinate of the lower left corner of the bounding box - /// The x coordinate of the upper right corner of the bounding box - /// The y coordinate of the upper right corner of the bounding box - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_edge", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dDeleteEdge([In] int meshKernelId, - [In] double xCoordinate, - [In] double yCoordinate, - [In] double xLowerLeftBoundingBox, - [In] double yLowerLeftBoundingBox, - [In] double xUpperRightBoundingBox, - [In] double yUpperRightBoundingBox); - - /// - /// Deletes all hanging edges. An hanging edge is an edge where one of the two nodes is not connected. - /// - /// The id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_hanging_edges", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dDeleteHangingEdges([In] int meshKernelId); - - /// - /// Deletes a mesh2d node - /// - /// Id of the mesh state - /// The index of the node to delete - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_node", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dDeleteNode([In] int meshKernelId, [In] int nodeIndex); - - /// - /// Clean up back-end orthogonalization algorithm (interactive mode) - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_orthogonalization", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dDeleteOrthogonalization([In] int meshKernelId); - - /// - /// Deletes all small mesh2d flow edges and small triangles. The flow edges are the edges connecting faces circumcenters. - /// - /// The id of the mesh state - /// The configurable threshold for detecting the small flow edges - /// - /// The ratio of the face area to the average area of neighboring non triangular - /// faces - /// - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_small_flow_edges_and_small_triangles", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dDeleteSmallFlowEdgesAndSmallTriangles([In] int meshKernelId, - [In] double smallFlowEdgesThreshold, - [In] double minFractionalAreaTriangles); - - /// - /// Finalizes the orthogonalization outer iteration, computing the new coefficients for grid adaption and the new face - /// circumcenters (interactive mode). - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_finalize_inner_ortogonalization_iteration", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dFinalizeInnerOrtogonalizationIteration([In] int meshKernelId); - - /// - /// Flips mesh2d edges, to optimize the mesh smoothness. This operation is usually performed after - /// `mkernel_mesh2d_refine_based_on_samples` or `mkernel_mesh2d_refine_based_on_polygon`. - /// - /// Id of the mesh state - /// - /// The option to triangulate also non triangular cells (if activated squares becomes - /// triangles) - /// - /// The option to determine how to snap to land boundaries - /// - /// The polygon where to perform the edge flipping (num_coordinates = 0 for an empty - /// polygon) - /// - /// - /// The land boundaries to account for when flipping the edges (num_coordinates = 0 for no - /// land boundaries) - /// - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_flip_edges", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dFlipEdges([In] int meshKernelId, - [In] int isTriangulationRequired, - [In] int projectToLandBoundaryOption, - [In] ref GeometryListNative selectingPolygon, - [In] ref GeometryListNative landBoundaries); - - /// - /// Get the coordinate of the closest vertex - /// - /// Id of the mesh state - /// The x coordinate of the input node - /// The y coordinate of the input node - /// The x coordinate of the lower left corner of the bounding box - /// The y coordinate of the lower left corner of the bounding box - /// The x coordinate of the upper right corner of the bounding box - /// The y coordinate of the upper right corner of the bounding box - /// The radii where to search for mesh nodes - /// The x coordinate of the found Mesh2DNative node - /// The y coordinate of the found Mesh2DNative node - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_closest_node", CallingConvention = CallingConvention.Cdecl)] - public static extern int Mesh2dGetClosestNode([In] int meshKernelId, - [In] double xCoordinateIn, - [In] double yCoordinateIn, - [In] double searchRadius, - [In] double xLowerLeftBoundingBox, - [In] double yLowerLeftBoundingBox, - [In] double xUpperRightBoundingBox, - [In] double yUpperRightBoundingBox, - [In][Out] ref double xCoordinateOut, - [In][Out] ref double yCoordinateOut); - - /// - /// Gets the mesh state as a structure including faces information - /// - /// Id of the mesh state - /// Grid data - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_data", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetData([In] int meshKernelId, - [In][Out] ref Mesh2DNative mesh2DNative); - - /// - /// Gets the mesh2d dimensions structure - /// - /// Id of the mesh state - /// Grid data - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_dimensions", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2DGetDimensions([In] int meshKernelId, - [In][Out] ref Mesh2DNative mesh2DNative); - - /// - /// Deletes the closest mesh edge within the search radius from the input point - /// - /// Id of the mesh state - /// x coordinate of the vertex - /// y coordinate of the vertex - /// The x coordinate of the lower left corner of the bounding box - /// The y coordinate of the lower left corner of the bounding box - /// The x coordinate of the upper right corner of the bounding box - /// The y coordinate of the upper right corner of the bounding box - /// The edge index - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_edge", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetEdge([In] int meshKernelId, - [In] double xCoordinate, - [In] double yCoordinate, - [In] double xLowerLeftBoundingBox, - [In] double yLowerLeftBoundingBox, - [In] double xUpperRightBoundingBox, - [In] double yUpperRightBoundingBox, - [In][Out] ref int edgeIndex); - - /// - /// Gets the indices of hanging edges. An hanging edge is an edge where one of the two nodes is not connected. - /// - /// The id of the mesh state - /// Pointer to memory where the indices of the hanging edges will be stored - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_hanging_edges", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetHangingEdges([In] int meshKernelId, [In][Out] IntPtr edges); - - /// - /// Retrives the mesh boundary polygon - /// - /// Id of the mesh state - /// The output network boundary polygon - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_mesh_boundaries_as_polygons", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetMeshBoundariesAsPolygons([In] int meshKernelId, [In][Out] ref GeometryListNative geometryListNative); - - /// - /// Finds the mesh2d node closest to a point, within a search radius - /// - /// The id of the mesh state - /// The x coordinate of the point - /// The y coordinate of the point - /// The search radius - /// The x coordinate of the lower left corner of the bounding box - /// The y coordinate of the lower left corner of the bounding box - /// The x coordinate of the upper right corner of the bounding box - /// The y coordinate of the upper right corner of the bounding box - /// the index of the closest vertex - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_node_index", CallingConvention = CallingConvention.Cdecl)] - public static extern int Mesh2dGetNodeIndex([In] int meshKernelId, - [In] double xCoordinateIn, - [In] double yCoordinateIn, - [In] double searchRadius, - [In] double xLowerLeftBoundingBox, - [In] double yLowerLeftBoundingBox, - [In] double xUpperRightBoundingBox, - [In] double yUpperRightBoundingBox, - [In][Out] ref int vertexIndex); - - /// - /// Gets the selected mesh node indexes - /// - /// Id of the mesh state - /// The input polygons - /// Selection of the nodes inside the polygon (1) or outside (0) - /// The selected vertices nodes - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_nodes_in_polygons", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetSelectedVerticesInPolygon([In] int meshKernelId, - [In] ref GeometryListNative geometryListIn, - [In] int inside, - [In][Out] IntPtr selectedVerticesPtr); - - /// - /// Gets the mass centers of obtuse mesh2d triangles. Obtuse triangles are those having one edge longer than the sum of the - /// other two - /// - /// The id of the mesh state - /// The result of the block to orthogonalize - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_obtuse_triangles_mass_centers", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetObtuseTrianglesMassCenters([In] int meshKernelId, [In][Out] ref GeometryListNative result); - - /// - /// Gets the orthogonality - /// - /// Id of the mesh state - /// The orthogonality values of each edge - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_orthogonality", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetOrthogonality([In] int meshKernelId, [In][Out] ref GeometryListNative geometryListIn); - - /// - /// Counts the number of selected mesh node indexes - /// - /// Id of the mesh state - /// The input polygons - /// Selection of the nodes inside the polygon (1) or outside (0) - /// The number of selected nodes - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_nodes_in_polygons", CallingConvention = CallingConvention.Cdecl)] - internal static extern int CountVerticesInPolygon([In] int meshKernelId, - [In] ref GeometryListNative geometryListIn, - [In] int inside, - [In][Out] ref int numberOfMeshVertices); - - /// - /// Counts the number of polygon nodes contained in the mesh boundary polygons computed in function - /// `mkernel_mesh2d_get_mesh_boundaries_as_polygons` - /// - /// The id of the mesh state - /// The numObtuseTriangles of the block to orthogonalize - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_obtuse_triangles", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dCountObtuseTriangles([In] int meshKernelId, [In][Out] ref int numObtuseTriangles); - - /// - /// Gets the small mesh2d flow edges. The flow edges are the edges connecting faces circumcenters - /// - /// The id of the mesh state - /// The smallFlowEdgesThreshold of the block to orthogonalize - /// The result of the block to orthogonalize - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_small_flow_edge_centers", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetSmallFlowEdgeCenters([In] int meshKernelId, [In] double smallFlowEdgesThreshold, [In][Out] ref GeometryListNative result); - - /// - /// Gets the smoothness, expressed as the ratio between the values of two neighboring faces areas. - /// - /// Id of the mesh state - /// The smoothness values of each edge - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_smoothness", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dGetSmoothness([In] int meshKernelId, [In][Out] ref GeometryListNative geometryListIn); - - /// - /// Orthogonalization initialization (first function to use in interactive mode) - /// - /// Id of the mesh state - /// The option to determine how to snap to land boundaries - /// The structure containing the user defined orthogonalization parameters - /// The polygon where to perform the orthogonalization - /// The land boundaries to account for in the orthogonalization process - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_initialize_orthogonalization", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dInitializeOrthogonalization([In] int meshKernelId, - [In] int projectToLandBoundaryOption, - [In] ref OrthogonalizationParametersNative orthogonalizationParametersNative, - [In] ref GeometryListNative geometryListNativePolygon, - [In] ref GeometryListNative geometryListNativeLandBoundaries); - - /// - /// Insert a new edge connecting - /// - /// and - /// - /// - /// Id of the mesh state - /// The index of the first vertex to connect - /// The index of the second vertex to connect - /// The index of the new edge - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_edge", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dInsertEdge([In] int meshKernelId, [In] int startVertexIndex, [In] int endVertexIndex, [In][Out] ref int edgeIndex); - - /// - /// Insert a new mesh2d edge from 2 coordinates - /// - /// The id of the mesh state - /// The index of the first node to connect - /// The index of the second node to connect - /// The index of the first node to connect - /// The index of the second node to connect - /// The index of the first node - /// The index of the second node - /// The index of the new generated edge - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_edge_from_coordinates", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dInsertEdgeFromCoordinates([In] int meshKernelId, - [In] double firstNodeX, - [In] double firstNodeY, - [In] double secondNodeX, - [In] double secondNodeY, - [In][Out] ref int firstNodeIndex, - [In][Out] ref int secondNodeIndex, - [In][Out] ref int edgeIndex); - - /// - /// Insert a new mesh2d edge connecting two nodes - /// - /// Id of the mesh state - /// The index of the first node to connect - /// The index of the second node to connect - /// The index of the new generated edge - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_node", CallingConvention = CallingConvention.Cdecl)] - public static extern int Mesh2dInsertNode([In] int meshKernelId, [In] double xCoordinate, [In] double yCoordinate, [In][Out] ref int vertexIndex); - - /// - /// Gets the edges intersected by a polygon, with additional information on the intersections - /// - /// The id of the mesh state - /// An input polygon, defined as a series of points - /// - /// The indices of the intersected edge nodes. The first node of the edge is on the left (the - /// virtual node), the second node of the edge is on the right (the inner node) - /// - /// For each intersected edge, the edge index - /// - /// For each intersection, the location of the intersection expressed as adimensional distance - /// from the edge starting node - /// - /// - /// For each intersection, the location of the intersection expressed as adimensional - /// distance from the polygon segment start - /// - /// For each intersection, the segment index - /// For each intersection, the face index - /// For each intersection, the number of intersections - /// For each intersection, the index of the intersected edge - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_intersections_from_polygon", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dIntersectionsFromPolygon([In] int meshKernelId, - [In] ref GeometryListNative boundaryPolygon, - [In][Out] IntPtr edgeNodes, - [In][Out] IntPtr edgeIndex, - [In][Out] IntPtr edgeDistances, - [In][Out] IntPtr segmentDistances, - [In][Out] IntPtr segmentIndexes, - [In][Out] IntPtr faceIndexes, - [In][Out] IntPtr faceNumEdges, +using System; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Runtime.InteropServices; +using MeshKernelNET.Helpers; + +namespace MeshKernelNET.Native +{ + // never hit by code coverage because tests use remoting and this only contains dll imports + [ExcludeFromCodeCoverage] + internal static class MeshKernelDll + { + private const string MeshKernelDllName = "MeshKernelApi.dll"; + + static MeshKernelDll() + { + string dir = Path.GetDirectoryName(typeof(MeshKernelDll).Assembly.Location); + NativeLibrary.LoadNativeDll(MeshKernelDllName, Path.Combine(dir, @"win-x64\native")); + } + + /// + /// Create a new mesh state and return the generated + /// + /// + /// + /// Cartesian (0), spherical (1) or spherical accurate(2) mesh + /// Identifier for the created grid state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_allocate_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int AllocateState([In] int projectionType, [In][Out] ref int meshKernelId); + + /// + /// Clear the undo state + /// + /// The id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_clear_undo_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ClearUndoState([In] int meshKernelId); + + /// + /// Computes 1d-2d contacts, where 1d nodes are connected to the closest 2d faces at the boundary + /// (ggeo_make1D2DRiverLinks_dll) + /// + /// The id of the mesh state + /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) + /// The polygon selecting the faces to connect + /// + /// The radius used for searching neighboring faces, if equal to doubleMissingValue, the search + /// radius will be calculated internally + /// + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_boundary", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ContactsComputeBoundary([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative polygons, [In] double searchRadius); + + /// + /// Computes 1d-2d contacts, where a single 1d node is connected to multiple 2d face circumcenters + /// (ggeo_make1D2Dembeddedlinks_dll) + /// + /// The id of the mesh state + /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_multiple", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ContactsComputeMultiple([In] int meshKernelId, [In] IntPtr oneDNodeMask); + + /// + /// Computes 1d-2d contacts, where each single 1d node is connected to one mesh2d face circumcenter + /// (ggeo_make1D2Dinternalnetlinks_dll) + /// + /// The id of the mesh state + /// The mask to apply to 1d nodes (1 = connect node, 0 = do not connect) + /// The polygons selecting the area where the 1d-2d contacts will be generated + /// + /// The projection factor used for generating the contacts when 1d nodes are not inside the + /// 2d mesh + /// + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_single", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ContactsComputeSingle([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative polygons, [In] double projectionFactor); + + /// + /// Computes 1d-2d contacts, where 1d nodes are connected to the 2d faces mass centers containing the input point + /// (ggeo_make1D2Dstreetinletpipes_dll) + /// + /// The id of the mesh state + /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) + /// The points selecting the faces to connect + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_with_points", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ContactsComputeWithPoints([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative points); + + /// + /// Computes 1d-2d contacts, where a 2d face per polygon is connected to the closest 1d node + /// (ggeo_make1D2Droofgutterpipes_dll) + /// + /// The id of the mesh state + /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) + /// The mask to apply to 1d nodes (1 = generate a connection, 0 = do not generate a connection) + /// The polygons to connect + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_compute_with_polygons", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ContactsComputeWithPolygons([In] int meshKernelId, [In] IntPtr oneDNodeMask, [In] ref GeometryListNative polygons); + + /// + /// Gets the 1d-2d contacts indices (from index / to indices) + /// + /// The id of the mesh state + /// Contacts data + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_get_data", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ContactsGetData([In] int meshKernelId, [In][Out] ref ContactsNative contacts); + + /// + /// Gets the number of 1d-2d contacts + /// + /// The id of the mesh state + /// Contacts data, filled on the dimension part + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_contacts_get_dimensions", CallingConvention = CallingConvention.Cdecl)] + internal static extern int ContactsGetDimensions([In] int meshKernelId, [In][Out] ref ContactsNative contacts); + + /// + /// Make curvilinear grid from splines with an advancing front. + /// + /// Id of the mesh state + /// The input splines corners + /// The input parameters to generate the curvilinear grid + /// The parameters of the advancing front algorithm + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeOrthogonalGridFromSplines([In] int meshKernelId, + [In] ref GeometryListNative geometryListNative, + [In] ref CurvilinearParametersNative curvilinearParametersNative, + [In] ref SplinesToCurvilinearParametersNative splinesToCurvilinearParametersNative); + + /// + /// Computes the curvature of a curvilinear grid. + /// + /// Id of the mesh state + /// The direction in which to compute the smoothness (0 for M direction, 1 for N direction) + /// The grid curvature values in the selected direction + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_curvature", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeCurvature([In] int meshKernelId, [In] int direction, [In][Out] IntPtr curvature); + + /// + /// Computes the smoothness of a curvilinear grid. + /// + /// Id of the mesh state + /// The direction in which to compute the smoothness (0 for m direction, 1 for n direction) + /// The grid smoothness values in the selected direction + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_smoothness", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeSmoothness([In] int meshKernelId, [In] int direction, [In][Out] IntPtr smoothness); + + /// + /// Computes a curvilinear mesh in a polygon. 3 separate polygon nodes need to be selected. + /// + /// >Id of the mesh state + /// The input polygons + /// The first selected node + /// The second selected node + /// + /// The third node< + /// Use (true/false) the fourth polygon side to compute the curvilinear grid + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_transfinite_from_polygon", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeTransfiniteFromPolygon([In] int meshKernelId, + [In] ref GeometryListNative geometryListNative, + [In] int firstNode, + [In] int secondNode, + [In] int thirdNode, + [In] bool useFourthSide); + + /// + /// Generates curvilinear grid from splines with transfinite interpolation + /// + /// The id of the mesh state + /// The splines + /// The curvilinear parameters + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_transfinite_from_splines", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeTransfiniteFromSplines([In] int meshKernelId, + [In] ref GeometryListNative geometryListNativeIn, + [In] ref CurvilinearParametersNative curvilinearParametersNative); + + /// + /// Computes a curvilinear mesh in a triangle. 3 separate polygon nodes need to be selected. + /// + /// >Id of the mesh state + /// The input polygons + /// The first selected node + /// The second selected node + /// The third node + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_transfinite_from_triangle", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeTransfiniteFromTriangle([In] int meshKernelId, + [In] ref GeometryListNative geometryListNative, + [In] int firstNode, + [In] int secondNode, + [In] int thirdNode); + + /// + /// Convert a curviliner mesh stored in meshkernel to an unstructured curvilinear mesh + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_convert_to_mesh2d", CallingConvention = CallingConvention.Cdecl)] + public static extern int CurvilinearConvertToMesh2D([In] int meshKernelId); + + /// + /// Delete the node closest to a point + /// + /// Id of the mesh state + /// The x coordinate of the point + /// The y coordinate of the point + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_delete_node", CallingConvention = CallingConvention.Cdecl)] + public static extern int CurvilinearDeleteNode([In] int meshKernelId, [In] double xPointCoordinate, [In] double yPointCoordinate); + + /// + /// Finalizes curvilinear grid from splines algorithm + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_delete_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] + public static extern int CurvilinearDeleteOrthogonalGridFromSplines([In] int meshKernelId); + + /// + /// Directional curvilinear grid de-refinement. Grid lines are removed perpendicularly to the segment defined by + /// lowerLeftCorner and xUpperRightCorner. + /// + /// Id of the mesh state + /// The x coordinate of the lower left corner of the block to de-refine + /// The y coordinate of the lower left corner of the block to de-refine + /// The x coordinate of the upper right corner of the block to de-refine + /// The y coordinate of the upper right corner of the block to de-refine + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_derefine", CallingConvention = CallingConvention.Cdecl)] + public static extern int CurvilinearDerefine([In] int meshKernelId, + [In] double xLowerLeftCorner, + [In] double yLowerLeftCorner, + [In] double xUpperRightCorner, + [In] double yUpperRightCorner); + + /// + /// Finalizes the line shift algorithm + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_finalize_line_shift", CallingConvention = CallingConvention.Cdecl)] + public static extern int CurvilinearFinalizeLineShift([In] int meshKernelId); + + /// + /// Finalizes the curvilinear orthogonalization algorithm + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_finalize_orthogonalize", CallingConvention = CallingConvention.Cdecl)] + public static extern int CurvilinearFinalizeOrthogonalize([In] int meshKernelId); + + /// + /// Gets the curvilinear grid data as a CurvilinearGrid struct (converted as set of edges and nodes) + /// + /// Id of the mesh state + /// The structure containing the curvilinear grid arrays + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_get_data", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearGetData([In] int meshKernelId, [In][Out] ref CurvilinearGridNative curvilinearGridNative); + + /// + /// Gets the curvilinear grid dimensions as a CurvilinearGrid struct (converted as set of edges and nodes). + /// + /// Id of the mesh state + /// The structure containing the dimensions of the curvilinear grid + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_get_dimensions", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearGetDimensions([In] int meshKernelId, [In][Out] ref CurvilinearGridNative curvilinearGridNative); + + /// + /// Initializes the curvilinear line shift algorithm + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_initialize_line_shift", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearInitializeLineShift([In] int meshKernelId); + + /// + /// Generates a curvilinear grid from splines with the advancing front method. Initialization step (interactive) + /// + /// Id of the mesh state + /// The input splines corners + /// The input parameters to generate the curvilinear grid + /// The parameters of the advancing front algorithm + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_initialize_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearInitializeOrthogonalGridFromSplines([In] int meshKernelId, + [In] ref GeometryListNative geometryListNative, + [In] ref CurvilinearParametersNative curvilinearParametersNative, + [In] ref SplinesToCurvilinearParametersNative splinesToCurvilinearParameters); + + /// + /// Initializes the orthogonal curvilinear algorithm + /// + /// The id of the mesh state + /// The orthogonalization parameters to use in the algorithm + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_initialize_orthogonalize", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearInitializeOrthogonalize([In] int meshKernelId, + [In] ref OrthogonalizationParametersNative orthogonalizationParameters); + + /// + /// Inserts a new face on a curvilinear grid. The new face will be inserted on top of the closest edge by linear + /// extrapolation. + /// + /// Id of the mesh state + /// + /// The x coordinate of the point used for finding the closest face/param> + /// The y coordinate of the point used for finding the closest face + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_insert_face", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearInsertFace([In] int meshKernelId, [In] double xCoordinate, [In] double yCoordinate); + + /// + /// One advancement of the front in curvilinear grid from splines (interactive) + /// + /// The id of the mesh state + /// + /// The layer index/param> + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_iterate_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearIterateOrthogonalGridFromSplines([In] int meshKernelId, [In] int layer); + + /// + /// Attracts/repulses grid lines in a block towards another set grid line + /// + /// The id of the mesh state + /// + /// The attraction/repulsion parameter. If positive the grid lines will be attracted + /// towards the set line, if negative the lines will be repulsed + /// + /// The x coordinate of the first node of the set line + /// The y coordinate of the first node of the set line + /// The x coordinate of the second node of the set line + /// The y coordinate of the second node of the set line + /// The x coordinate of the lower left corner of the block where the operation is performed + /// The y coordinate of the lower left corner of the block where the operation is performed + /// + /// The x coordinate of the upper right corner of the block where the operation is + /// performed + /// + /// + /// The y coordinate of the upper right corner of the block where the operation is + /// performed + /// + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_line_attraction_repulsion", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearLineAttractionRepulsion([In] int meshKernelId, + [In] double repulsionParameter, + [In] double xFirstNodeOnTheLine, + [In] double yFirstNodeOnTheLine, + [In] double xSecondNodeOnTheLine, + [In] double ySecondNodeOnTheLine, + [In] double xLowerLeftCorner, + [In] double yLowerLeftCorner, + [In] double xUpperRightCorner, + [In] double yUpperRightCorner); + + /// + /// Mirrors a boundary gridline outwards. The boundary grid line is defined by its starting and ending points + /// + /// The id of the mesh state + /// The x coordinate of the first node of the set line + /// The x coordinate of the first node of the set line + /// The y coordinate of the first node of the set line + /// The x coordinate of the second node of the set line + /// The y coordinate of the second node of the set line + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_line_mirror", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearLineMirror([In] int meshKernelId, + [In] double mirroringFactor, + [In] double xFirstGridLineNode, + [In] double yFirstGridLineNode, + [In] double xSecondGridLineNode, + [In] double ySecondGridLineNode); + + /// @brief Computes the new grid, shifting the line towards the moved nodes and distributing the shifting in block specified before + /// The id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_line_shift", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearLineShift([In] int meshKernelId); + + /// + /// Make a rectangular grid + /// + /// Id of the mesh state + /// The structure containing the make grid parameters + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_rectangular_grid", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeRectangularGrid([In] int meshKernelId, + [In] ref MakeGridParametersNative makeGridParametersNative); + + /// + /// Make a rectangular grid from polygons + /// + /// Id of the mesh state + /// The structure containing the make grid parameters + /// The polygon to account for + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_rectangular_grid_from_polygon", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeRectangularGridFromPolygon([In] int meshKernelId, + [In] ref MakeGridParametersNative makeGridParametersNative, + [In] ref GeometryListNative geometryListNative); + + /// + /// Makes rectangular grid based on a defined on an extension + /// + /// Id of the mesh state + /// The structure containing the make grid parameters + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_compute_rectangular_grid_on_extension", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearComputeRectangularGridOnExtension([In] int meshKernelId, [In] ref MakeGridParametersNative makeGridParametersNative); + + /// + /// Moves a point of a curvilinear grid from one location to another + /// + /// The id of the mesh state + /// The x coordinate of point to move + /// The y coordinate of point to move + /// The new x coordinate of the point + /// The new y coordinate of the point + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_move_node", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearMoveNode([In] int meshKernelId, + [In] double xFromPoint, + [In] double yFromPoint, + [In] double xToPoint, + [In] double yToPoint); + + /// + /// Moves a node of the line to shift, the operation can be performed multiple times. + /// + /// The id of the mesh state + /// The x coordinate of the node to move (the closest curvilinear grid node will be found) + /// The y coordinate of the node to move (the closest curvilinear grid node will be found) + /// The x coordinate of the new node position + /// The y coordinate of the new node position + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_move_node_line_shift", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearMoveNodeLineShift([In] int meshKernelId, + [In] double xFromCoordinate, + [In] double yFromCoordinate, + [In] double xToCoordinate, + [In] double yToCoordinate); + + /// + /// Orthogonalize a curvilinear grid + /// + /// The id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_orthogonalize", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearOrthogonalize([In] int meshKernelId); + + /// + /// Directional curvilinear grid refinement. Additional gridlines are added perpendicularly to the segment defined by + /// lowerLeftCorner and xUpperRightCorner. + /// + /// The id of the mesh state + /// The x coordinate of the lower left corner of the block to refine + /// The y coordinate of the lower left corner of the block to refine + /// The x coordinate of the upper right corner of the block to refine + /// The y coordinate of the upper right corner of the block to refine + /// The number of grid lines to add between the firstPoint and the secondPoint + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_refine", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearRefine([In] int meshKernelId, + [In] double xLowerLeftCorner, + [In] double yLowerLeftCorner, + [In] double xUpperRightCorner, + [In] double yUpperRightCorner, + [In] int refinement); + + /// + /// Converts curvilinear grid to mesh and refreshes the state (interactive) + /// + /// The id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_refresh_orthogonal_grid_from_splines", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearRefreshOrthogonalGridFromSplines([In] int meshKernelId); + + /// + /// Sets the curvilinear grid + /// + /// The id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearSet([In] int meshKernelId, [In] ref CurvilinearGridNative grid); + + /// + /// Defines a block on the curvilinear where the shifting is distributed + /// + /// The id of the mesh state + /// The x coordinate of the lower left corner of the block + /// The y coordinate of the lower left corner of the block + /// The x coordinate of the upper right corner of the block + /// The y coordinate of the upper right corner of the block + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_block_line_shift", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearSetBlockLineShift([In] int meshKernelId, + [In] double xLowerLeftCorner, + [In] double yLowerLeftCorner, + [In] double xUpperRightCorner, + [In] double yUpperRightCorner); + + /// + /// efine a block on the curvilinear grid where to perform orthogonalization + /// + /// The meshKernelId of the block to orthogonalize + /// The xLowerLeftCorner of the block to orthogonalize + /// The yLowerLeftCorner of the block to orthogonalize + /// The xUpperRightCorner of the block to orthogonalize + /// The yUpperRightCorner of the block to orthogonalize + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_block_orthogonalize", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearSetBlockOrthogonalize([In] int meshKernelId, + [In] double xLowerLeftCorner, + [In] double yLowerLeftCorner, + [In] double xUpperRightCorner, + [In] double yUpperRightCorner); + + /// + /// Freezes a line in the curvilinear orthogonalization process + /// + /// The id of the mesh state + /// The x coordinate of the first point of the line to freeze + /// The y coordinate of the first point of the line to freeze + /// The x coordinate of the second point of the line to freeze + /// The y coordinate of the second point of the line to freeze + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_frozen_lines_orthogonalize", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearSetFrozenLinesOrthogonalize([In] int meshKernelId, + [In] double xFirstGridLineNode, + [In] double yFirstGridLineNode, + [In] double xSecondGridLineNode, + [In] double ySecondGridLineNode); + + /// + /// Sets the start and end nodes of the line to shift + /// + /// The meshKernelId of the block to orthogonalize + /// The x coordinate of the first curvilinear grid node to shift + /// The y coordinate of the first curvilinear grid node to shift + /// The x coordinate of the second curvilinear grid node to shift + /// The y coordinate of the second curvilinear grid node to shift + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_set_line_line_shift", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearSetLineLineShift([In] int meshKernelId, + [In] double xFirstGridLineNode, + [In] double yFirstGridLineNode, + [In] double xSecondGridLineNode, + [In] double ySecondGridLineNode); + + /// + /// Smooths a curvilinear grid + /// + /// The meshKernelId of the block to orthogonalize + /// The number of smoothing iterations to perform + /// The x coordinate of the lower left corner of the block to smooth + /// The y coordinate of the lower left corner of the block to smooth + /// The x coordinate of the right corner of the block to smooth + /// The y coordinate of the upper right corner of the block to smooth + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_smoothing", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearSmoothing([In] int meshKernelId, + [In] int smoothingIterations, + [In] double xLowerLeftCorner, + [In] double yLowerLeftCorner, + [In] double xUpperRightCorner, + [In] double yUpperRightCorner); + + /// + /// Smooths a curvilinear grid along the direction specified by a segment + /// + /// The id of the mesh state + /// The number of smoothing iterations to perform + /// The x coordinate of the first curvilinear grid node + /// The y coordinate of the first curvilinear grid node + /// The x coordinate of the second curvilinear grid node + /// The y coordinate of the second curvilinear grid node + /// The x coordinate of the lower left corner of the smoothing area + /// The y coordinate of the lower left corner of the smoothing area + /// The x coordinate of the upper right corner of the smoothing area + /// The y coordinate of the upper right corner of the smoothing area + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_curvilinear_smoothing_directional", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CurvilinearSmoothingDirectional([In] int meshKernelId, + [In] int smoothingIterations, + [In] double xFirstGridlineNode, + [In] double yFirstGridlineNode, + [In] double xSecondGridLineNode, + [In] double ySecondGridLineNode, + [In] double xLowerLeftCornerSmoothingArea, + [In] double yLowerLeftCornerSmoothingArea, + [In] double xUpperRightCornerSmoothingArea, + [In] double yUpperRightCornerSmoothingArea); + + /// + /// Deallocate mesh state + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_deallocate_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int DeallocateState([In] int meshKernelId); + + /// + /// Gets an int indicating the closest point averaging method type + /// + /// The int indicating the closest point averaging method type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_closest_point", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetAveragingMethodClosestPoint([In][Out] ref int method); + + /// + /// Gets an int indicating the inverse distance weights averaging method type + /// + /// The int indicating the inverse weight distance averaging method type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_inverse_distance_weighting", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetAveragingMethodInverseDistanceWeighting([In][Out] ref int method); + + /// + /// Gets an int indicating the max value averaging method type + /// + /// The int indicating the max value averaging method type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_max", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetAveragingMethodMax([In][Out] ref int method); + + /// + /// Gets an int indicating the minimum averaging method type + /// + /// The int indicating the minimum averaging method type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_min", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetAveragingMethodMin([In][Out] ref int method); + + /// + /// Gets an int indicating the minimum absolute value averaging method type + /// + /// The int indicating the minimum absolute value averaging method type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_min_absolute_value", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetAveragingMethodMinAbsoluteValue([In][Out] ref int method); + + /// + /// Gets an int indicating the simple averaging method type + /// + /// The int indicating the averaging method type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_averaging_method_simple_averaging", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetAveragingMethodSimpleAveraging([In][Out] ref int method); + + /// + /// Gets an int indicating the edge location type + /// + /// The int indicating the edge location type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_edges_location_type", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetEdgesLocationType([In][Out] ref int type); + + /// + /// Gets a pointer to error message + /// + /// The pointer to the latest error message + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetError([In][Out] IntPtr message); + + /// + /// Gets the success exit code + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_success", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeSuccess([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type MeshKernelError + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_meshkernel_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeMeshKernelError([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type NotImplementedError + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_not_implemented_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeNotImplementedError([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type AlgorithmError + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_algorithm_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeAlgorithmError([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type ConstraintError + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_constraint_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeConstraintError([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type MeshGeometryError + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_mesh_geometry_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeMeshGeometryError([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type LinearAlgebraError + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_linear_algebra_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeLinearAlgebraError([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type RangeError + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_range_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeRangeError([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type StdLibException + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_stdlib_exception", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeStdLibException([In][Out] ref int exitCode); + + /// + /// Gets the exit code of an exception of type UnknownException + /// + /// The exit code + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_exit_code_unknown_exception", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetExitCodeUnknownException([In][Out] ref int exitCode); + + /// + /// Gets an int indicating the faces location type + /// + /// The int indicating the face location type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_faces_location_type", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetFacesLocationType([In][Out] ref int type); + + /// + /// get geometry error + /// + /// The index of the erroneous entity + /// The entity type (node, edge or face, see MeshLocations) + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_geometry_error", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetGeometryError([In][Out] ref int invalidIndex, [In][Out] ref int type); + + /// + /// Gets an int indicating the node location type + /// + /// The int indicating the node location type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_nodes_location_type", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetNodesLocationType([In][Out] ref int type); + + /// + /// Gets the coordinate projection of the meshkernel state + /// + /// The id of the mesh state + /// The int indicating the projection type + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetProjection([In] int meshKernelId, [In][Out] ref int projection); + + /// + /// Gets an int indicating the cartesian projection + /// + /// The int indicating the cartesian projection + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection_cartesian", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetProjectionCartesian([In][Out] ref int projection); + + /// + /// Gets an int indicating the spherical projection + /// + /// The int indicating the spherical projection + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection_spherical", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetProjectionSpherical([In][Out] ref int projection); + + /// + /// Gets an int indicating the spherical accurate projection + /// + /// The int indicating the spherical accurate projection + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_projection_spherical_accurate", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetProjectionSphericalAccurate([In][Out] ref int projection); + + /// + /// Get spline intermediate points + /// + /// The input corner nodes of the splines + /// The output spline + /// The number of spline vertices between the corners points + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_splines", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetSplines([In] ref GeometryListNative geometryListNativeIn, + [In][Out] ref GeometryListNative geometryListNativeOut, + [In] int numberOfPointsBetweenVertices); + + /// + /// Gets the version string + /// + /// The version string + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_version", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetVersion([In][Out] IntPtr version); + + /// + /// Gets the Mesh1D data + /// + /// The id of the mesh state + /// The mesh1d of the block to orthogonalize + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh1d_get_data", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh1dGetData([In] int meshKernelId, [In][Out] ref Mesh1DNative mesh1d); + + /// + /// Gets the Mesh1D data dimensions + /// + /// The id of the mesh state + /// The structure containing the dimensions of the Mesh1D + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh1d_get_dimensions", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh1dGetDimensions([In] int meshKernelId, [In][Out] ref Mesh1DNative mesh1d); + + /// + /// Sets the meshkernel::Mesh1D state + /// + /// The id of the mesh state + /// The mesh1d + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh1d_set", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh1dSet(int meshKernelId, [In] ref Mesh1DNative mesh1d); + + /// + /// AveragingInterpolation interpolation + /// + /// The id of the mesh state + /// The samples coordinates and values + /// The location type + /// The averaging method + /// The relative search size around the location + /// + /// The minimum number of samples used for some interpolation algorithms to perform a valid + /// interpolation + /// + /// The interpolation results with x and y coordinates + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_averaging_interpolation", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dAveragingInterpolation([In] int meshKernelId, + [In] ref GeometryListNative samples, + [In] int locationType, + [In] int averagingMethodType, + [In] double relativeSearchSize, + [In] int minNumSamples, + [In][Out] ref GeometryListNative results); + + /// + /// Performs inner orthogonalization iteration, by slowly moving the mesh nodes to new optimal positions (interactive mode) + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_compute_inner_ortogonalization_iteration", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dComputeInnerOrtogonalizationIteration([In] int meshKernelId); + + /// + /// Mesh2d orthogonalization + /// + /// Id of the mesh state + /// The option to determine how to snap to land boundaries + /// The structure containing the orthogonalization parameters + /// The polygon where to perform the orthogonalization + /// The land boundaries to account for in the orthogonalization process + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_compute_orthogonalization", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dComputeOrthogonalization([In] int meshKernelId, + [In] int projectToLandBoundaryOption, + [In] ref OrthogonalizationParametersNative orthogonalizationParametersNative, + [In] ref GeometryListNative geometryListNativePolygon, + [In] ref GeometryListNative geometryListNativeLandBoundaries); + + /// + /// Converts the projection of a mesh2d + /// + /// The id of the mesh state + /// The new projection for the mesh + /// The UTM zone and information string + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_convert_projection", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dConvertProjection([In] int meshKernelId, + [In] int projection, + [In][MarshalAs(UnmanagedType.LPStr)] string zone); + + /// + /// Count the number of hanging edges in a mesh2d. + /// + /// The id of the mesh state + /// The number of hanging edges + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_hanging_edges", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dCountHangingEdges([In] int meshKernelId, [In][Out] ref int numEdges); + + /// + /// Counts the number of polygon vertices contained in the mesh boundary polygon + /// + /// Id of the mesh state + /// The number of polygon points + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_mesh_boundaries_as_polygons", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dCountMeshBoundariesAsPolygons([In] int meshKernelId, [In][Out] ref int numberOfPolygonVertices); + + /// + /// Counts the mesh2d small flow edge centers + /// + /// The id of the mesh state + /// The smallFlowEdgesLengthThreshold of the block to orthogonalize + /// The numSmallFlowEdges of the block to orthogonalize + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_small_flow_edge_centers", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dCountSmallFlowEdgeCenters([In] int meshKernelId, + [In] double smallFlowEdgesLengthThreshold, + [In][Out] ref int numSmallFlowEdges); + + /// + /// Deletes a mesh in a polygon using several options + /// + /// Id of the mesh state + /// The polygon where to perform the operation + /// The deletion option (to be detailed) + /// Inverts the deletion of selected features + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete", CallingConvention = CallingConvention.Cdecl)] + public static extern int Mesh2dDelete([In] int meshKernelId, [In] ref GeometryListNative geometryListNative, [In] int deletionOption, [In] bool invertDeletion); + + /// + /// Deletes the closest mesh edge within the search radius from the input point + /// + /// Id of the mesh state + /// x coordinate of the vertex + /// y coordinate of the vertex + /// The x coordinate of the lower left corner of the bounding box + /// The y coordinate of the lower left corner of the bounding box + /// The x coordinate of the upper right corner of the bounding box + /// The y coordinate of the upper right corner of the bounding box + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_edge", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dDeleteEdge([In] int meshKernelId, + [In] double xCoordinate, + [In] double yCoordinate, + [In] double xLowerLeftBoundingBox, + [In] double yLowerLeftBoundingBox, + [In] double xUpperRightBoundingBox, + [In] double yUpperRightBoundingBox); + + /// + /// Deletes all hanging edges. An hanging edge is an edge where one of the two nodes is not connected. + /// + /// The id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_hanging_edges", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dDeleteHangingEdges([In] int meshKernelId); + + /// + /// Deletes a mesh2d node + /// + /// Id of the mesh state + /// The index of the node to delete + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_node", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dDeleteNode([In] int meshKernelId, [In] int nodeIndex); + + /// + /// Clean up back-end orthogonalization algorithm (interactive mode) + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_orthogonalization", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dDeleteOrthogonalization([In] int meshKernelId); + + /// + /// Deletes all small mesh2d flow edges and small triangles. The flow edges are the edges connecting faces circumcenters. + /// + /// The id of the mesh state + /// The configurable threshold for detecting the small flow edges + /// + /// The ratio of the face area to the average area of neighboring non triangular + /// faces + /// + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_delete_small_flow_edges_and_small_triangles", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dDeleteSmallFlowEdgesAndSmallTriangles([In] int meshKernelId, + [In] double smallFlowEdgesThreshold, + [In] double minFractionalAreaTriangles); + + /// + /// Finalizes the orthogonalization outer iteration, computing the new coefficients for grid adaption and the new face + /// circumcenters (interactive mode). + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_finalize_inner_ortogonalization_iteration", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dFinalizeInnerOrtogonalizationIteration([In] int meshKernelId); + + /// + /// Flips mesh2d edges, to optimize the mesh smoothness. This operation is usually performed after + /// `mkernel_mesh2d_refine_based_on_samples` or `mkernel_mesh2d_refine_based_on_polygon`. + /// + /// Id of the mesh state + /// + /// The option to triangulate also non triangular cells (if activated squares becomes + /// triangles) + /// + /// The option to determine how to snap to land boundaries + /// + /// The polygon where to perform the edge flipping (num_coordinates = 0 for an empty + /// polygon) + /// + /// + /// The land boundaries to account for when flipping the edges (num_coordinates = 0 for no + /// land boundaries) + /// + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_flip_edges", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dFlipEdges([In] int meshKernelId, + [In] int isTriangulationRequired, + [In] int projectToLandBoundaryOption, + [In] ref GeometryListNative selectingPolygon, + [In] ref GeometryListNative landBoundaries); + + /// + /// Get the coordinate of the closest vertex + /// + /// Id of the mesh state + /// The x coordinate of the input node + /// The y coordinate of the input node + /// The x coordinate of the lower left corner of the bounding box + /// The y coordinate of the lower left corner of the bounding box + /// The x coordinate of the upper right corner of the bounding box + /// The y coordinate of the upper right corner of the bounding box + /// The radii where to search for mesh nodes + /// The x coordinate of the found Mesh2DNative node + /// The y coordinate of the found Mesh2DNative node + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_closest_node", CallingConvention = CallingConvention.Cdecl)] + public static extern int Mesh2dGetClosestNode([In] int meshKernelId, + [In] double xCoordinateIn, + [In] double yCoordinateIn, + [In] double searchRadius, + [In] double xLowerLeftBoundingBox, + [In] double yLowerLeftBoundingBox, + [In] double xUpperRightBoundingBox, + [In] double yUpperRightBoundingBox, + [In][Out] ref double xCoordinateOut, + [In][Out] ref double yCoordinateOut); + + /// + /// Gets the mesh state as a structure including faces information + /// + /// Id of the mesh state + /// Grid data + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_data", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetData([In] int meshKernelId, + [In][Out] ref Mesh2DNative mesh2DNative); + + /// + /// Gets the mesh2d dimensions structure + /// + /// Id of the mesh state + /// Grid data + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_dimensions", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2DGetDimensions([In] int meshKernelId, + [In][Out] ref Mesh2DNative mesh2DNative); + + /// + /// Deletes the closest mesh edge within the search radius from the input point + /// + /// Id of the mesh state + /// x coordinate of the vertex + /// y coordinate of the vertex + /// The x coordinate of the lower left corner of the bounding box + /// The y coordinate of the lower left corner of the bounding box + /// The x coordinate of the upper right corner of the bounding box + /// The y coordinate of the upper right corner of the bounding box + /// The edge index + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_edge", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetEdge([In] int meshKernelId, + [In] double xCoordinate, + [In] double yCoordinate, + [In] double xLowerLeftBoundingBox, + [In] double yLowerLeftBoundingBox, + [In] double xUpperRightBoundingBox, + [In] double yUpperRightBoundingBox, + [In][Out] ref int edgeIndex); + + /// + /// Gets the indices of hanging edges. An hanging edge is an edge where one of the two nodes is not connected. + /// + /// The id of the mesh state + /// Pointer to memory where the indices of the hanging edges will be stored + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_hanging_edges", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetHangingEdges([In] int meshKernelId, [In][Out] IntPtr edges); + + /// + /// Retrives the mesh boundary polygon + /// + /// Id of the mesh state + /// The output network boundary polygon + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_mesh_boundaries_as_polygons", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetMeshBoundariesAsPolygons([In] int meshKernelId, [In][Out] ref GeometryListNative geometryListNative); + + /// + /// Finds the mesh2d node closest to a point, within a search radius + /// + /// The id of the mesh state + /// The x coordinate of the point + /// The y coordinate of the point + /// The search radius + /// The x coordinate of the lower left corner of the bounding box + /// The y coordinate of the lower left corner of the bounding box + /// The x coordinate of the upper right corner of the bounding box + /// The y coordinate of the upper right corner of the bounding box + /// the index of the closest vertex + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_node_index", CallingConvention = CallingConvention.Cdecl)] + public static extern int Mesh2dGetNodeIndex([In] int meshKernelId, + [In] double xCoordinateIn, + [In] double yCoordinateIn, + [In] double searchRadius, + [In] double xLowerLeftBoundingBox, + [In] double yLowerLeftBoundingBox, + [In] double xUpperRightBoundingBox, + [In] double yUpperRightBoundingBox, + [In][Out] ref int vertexIndex); + + /// + /// Gets the selected mesh node indexes + /// + /// Id of the mesh state + /// The input polygons + /// Selection of the nodes inside the polygon (1) or outside (0) + /// The selected vertices nodes + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_nodes_in_polygons", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetSelectedVerticesInPolygon([In] int meshKernelId, + [In] ref GeometryListNative geometryListIn, + [In] int inside, + [In][Out] IntPtr selectedVerticesPtr); + + /// + /// Gets the mass centers of obtuse mesh2d triangles. Obtuse triangles are those having one edge longer than the sum of the + /// other two + /// + /// The id of the mesh state + /// The result of the block to orthogonalize + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_obtuse_triangles_mass_centers", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetObtuseTrianglesMassCenters([In] int meshKernelId, [In][Out] ref GeometryListNative result); + + /// + /// Gets the orthogonality + /// + /// Id of the mesh state + /// The orthogonality values of each edge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_orthogonality", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetOrthogonality([In] int meshKernelId, [In][Out] ref GeometryListNative geometryListIn); + + /// + /// Counts the number of selected mesh node indexes + /// + /// Id of the mesh state + /// The input polygons + /// Selection of the nodes inside the polygon (1) or outside (0) + /// The number of selected nodes + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_nodes_in_polygons", CallingConvention = CallingConvention.Cdecl)] + internal static extern int CountVerticesInPolygon([In] int meshKernelId, + [In] ref GeometryListNative geometryListIn, + [In] int inside, + [In][Out] ref int numberOfMeshVertices); + + /// + /// Counts the number of polygon nodes contained in the mesh boundary polygons computed in function + /// `mkernel_mesh2d_get_mesh_boundaries_as_polygons` + /// + /// The id of the mesh state + /// The numObtuseTriangles of the block to orthogonalize + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_count_obtuse_triangles", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dCountObtuseTriangles([In] int meshKernelId, [In][Out] ref int numObtuseTriangles); + + /// + /// Gets the small mesh2d flow edges. The flow edges are the edges connecting faces circumcenters + /// + /// The id of the mesh state + /// The smallFlowEdgesThreshold of the block to orthogonalize + /// The result of the block to orthogonalize + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_small_flow_edge_centers", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetSmallFlowEdgeCenters([In] int meshKernelId, [In] double smallFlowEdgesThreshold, [In][Out] ref GeometryListNative result); + + /// + /// Gets the smoothness, expressed as the ratio between the values of two neighboring faces areas. + /// + /// Id of the mesh state + /// The smoothness values of each edge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_get_smoothness", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dGetSmoothness([In] int meshKernelId, [In][Out] ref GeometryListNative geometryListIn); + + /// + /// Orthogonalization initialization (first function to use in interactive mode) + /// + /// Id of the mesh state + /// The option to determine how to snap to land boundaries + /// The structure containing the user defined orthogonalization parameters + /// The polygon where to perform the orthogonalization + /// The land boundaries to account for in the orthogonalization process + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_initialize_orthogonalization", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dInitializeOrthogonalization([In] int meshKernelId, + [In] int projectToLandBoundaryOption, + [In] ref OrthogonalizationParametersNative orthogonalizationParametersNative, + [In] ref GeometryListNative geometryListNativePolygon, + [In] ref GeometryListNative geometryListNativeLandBoundaries); + + /// + /// Insert a new edge connecting + /// + /// and + /// + /// + /// Id of the mesh state + /// The index of the first vertex to connect + /// The index of the second vertex to connect + /// The index of the new edge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_edge", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dInsertEdge([In] int meshKernelId, [In] int startVertexIndex, [In] int endVertexIndex, [In][Out] ref int edgeIndex); + + /// + /// Insert a new mesh2d edge from 2 coordinates + /// + /// The id of the mesh state + /// The index of the first node to connect + /// The index of the second node to connect + /// The index of the first node to connect + /// The index of the second node to connect + /// The index of the first node + /// The index of the second node + /// The index of the new generated edge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_edge_from_coordinates", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dInsertEdgeFromCoordinates([In] int meshKernelId, + [In] double firstNodeX, + [In] double firstNodeY, + [In] double secondNodeX, + [In] double secondNodeY, + [In][Out] ref int firstNodeIndex, + [In][Out] ref int secondNodeIndex, + [In][Out] ref int edgeIndex); + + /// + /// Insert a new mesh2d edge connecting two nodes + /// + /// Id of the mesh state + /// The index of the first node to connect + /// The index of the second node to connect + /// The index of the new generated edge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_insert_node", CallingConvention = CallingConvention.Cdecl)] + public static extern int Mesh2dInsertNode([In] int meshKernelId, [In] double xCoordinate, [In] double yCoordinate, [In][Out] ref int vertexIndex); + + /// + /// Gets the edges intersected by a polygon, with additional information on the intersections + /// + /// The id of the mesh state + /// An input polygon, defined as a series of points + /// + /// The indices of the intersected edge nodes. The first node of the edge is on the left (the + /// virtual node), the second node of the edge is on the right (the inner node) + /// + /// For each intersected edge, the edge index + /// + /// For each intersection, the location of the intersection expressed as adimensional distance + /// from the edge starting node + /// + /// + /// For each intersection, the location of the intersection expressed as adimensional + /// distance from the polygon segment start + /// + /// For each intersection, the segment index + /// For each intersection, the face index + /// For each intersection, the number of intersections + /// For each intersection, the index of the intersected edge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_intersections_from_polygon", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dIntersectionsFromPolygon([In] int meshKernelId, + [In] ref GeometryListNative boundaryPolygon, + [In][Out] IntPtr edgeNodes, + [In][Out] IntPtr edgeIndex, + [In][Out] IntPtr edgeDistances, + [In][Out] IntPtr segmentDistances, + [In][Out] IntPtr segmentIndexes, + [In][Out] IntPtr faceIndexes, + [In][Out] IntPtr faceNumEdges, [In][Out] IntPtr faceEdgeIndex); - - /// - /// Compute the global mesh with a given number of points along the longitude and latitude directions. - /// - /// Id of the mesh state - /// The number of points along the longitude - /// The number of points along the latitude (half hemisphere) - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_global", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMakeGlobal(int meshKernelId, int numLongitudeNodes, int numLatitudeNodes); - - /// - /// Make a triangular grid in a polygon - /// - /// Id of the mesh state - /// The polygon where to triangulate - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_triangular_mesh_from_polygon", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMakeTriangularMeshFromPolygon([In] int meshKernelId, [In] ref GeometryListNative geometryListNative); - - /// - /// Make a triangular mesh from samples - /// - /// Id of the mesh state - /// The samples where to triangulate - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_triangular_mesh_from_samples", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMakeTriangularMeshFromSamples([In] int meshKernelId, [In] ref GeometryListNative geometryListNative); - - /// - /// Makes a rectangular mesh - /// - /// The id of the mesh state - /// The structure containing the make grid parameters - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_rectangular_mesh", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMakeRectangularMesh([In] int meshKernelId, - [In] ref MakeGridParametersNative makeGridParameters); - - /// - /// Makes a rectangular mesh from a polygon - /// - /// The id of the mesh state - /// The structure containing the make grid parameters - /// The polygons to account for - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_rectangular_mesh_from_polygon", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMakeRectangularMeshFromPolygon([In] int meshKernelId, - [In] ref MakeGridParametersNative makeGridParameters, - [In] ref GeometryListNative geometryList); - - /// - /// Makes a rectangular mesh on a defined extension - /// - /// The id of the mesh state - /// The structure containing the make grid parameters - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_rectangular_mesh_on_extension", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMakeRectangularMeshOnExtension([In] int meshKernelId, - [In] ref MakeGridParametersNative makeGridParameters); - - /// - /// Merges vertices, effectively removing small edges. The merging distance is computed internally based on the minimum - /// edge size. - /// - /// Id of the mesh state - /// - /// The polygon where to perform the operation. If empty the operation is performed over - /// the entire mesh - /// - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_merge_nodes", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMergeNodes([In] int meshKernelId, [In] ref GeometryListNative geometryListNative); - - /// - /// Merges vertices within a defined distance in a polygon, effectively removing small edges - /// - /// Id of the mesh state - /// - /// The polygon where to perform the operation. If empty the operation is performed over - /// the entire mesh - /// - /// The distance below which two nodes will be merged - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_merge_nodes_with_merging_distance", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMergeNodesWithMergingDistance([In] int meshKernelId, [In] ref GeometryListNative geometryListNative, [In] double mergingDistance); - - /// - /// Merges vertex - /// - /// to - /// - /// - /// Id of the mesh state - /// The index of the first vertex to merge - /// The index of the second vertex to merge - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_merge_two_nodes", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMergeTwoNodes([In] int meshKernelId, [In] int startVertexIndex, [In] int endVertexIndex); - - /// - /// Function to move a selected node to a new position - /// - /// Id of the mesh state - /// The new x coordinate - /// The new y coordinate - /// The index of the mesh2d node to be moved - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_move_node", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dMoveNode([In] int meshKernelId, - [In] double xCoordinate, - [In] double yCoordinate, - [In] int nodeIndex); - - /// - /// Prepare outer orthogonalization iteration (interactive mode) - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_prepare_outer_iteration_orthogonalization", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dPrepareOuterIterationOrthogonalization([In] int meshKernelId); - - /// - /// Refine based on gridded samples - /// - /// The id of the mesh state - /// The gridded samples - /// The mesh refinement parameters - /// Use nodal refinement - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_refine_based_on_gridded_samples", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dRefineBasedOnGriddedSamples([In] int meshKernelId, - [In] ref GriddedSamplesNative griddedSamplesNative, - [In] ref MeshRefinementParametersNative meshRefinementParameters, - [In] bool useNodalRefinement); - - /// - /// Refine a grid based on polygon - /// - /// Id of the mesh state - /// The closed polygon where to perform the refinement - /// The settings for the mesh refinement algorithm - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_refine_based_on_polygon", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dRefineBasedOnPolygon([In] int meshKernelId, - [In] ref GeometryListNative geometryListNative, - [In] ref MeshRefinementParametersNative meshRefinementParametersNative); - - /// - /// Refine a grid based on the samples contained in the geometry list - /// - /// Id of the mesh state - /// The sample set - /// - /// The relative search radius relative to the face size, used for some interpolation - /// algorithms - /// - /// The minimum number of samples used for some averaging algorithms - /// The mesh refinement parameters - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_refine_based_on_samples", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dRefineBasedOnSamples([In] int meshKernelId, - [In] ref GeometryListNative geometryListNative, - [In] double relativeSearchRadius, - [In] int minimumNumSamples, - [In] ref MeshRefinementParametersNative meshRefinementParameters); - - /// - /// Rotates a mesh2d about a given point by a given angle - /// - /// Id of the mesh state - /// >X-coordinate of the centre of rotation - /// Y-coordinate of the centre of rotation> - /// Angle of rotation in degrees - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_rotate", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dRotate([In] int meshKernelId, - [In] double centreX, - [In] double centreY, - [In] double angle); - - /// - /// Translates a mesh2d - /// - /// Id of the mesh state - /// X-component of the translation vector - /// Y-component of the translation vector - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_translate", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dTranslate([In] int meshKernelId, - [In] double translationX, - [In] double translationY); - - /// - /// Synchronize provided mesh ( - /// - /// and - /// - /// ) with the mesh state with - /// - /// - /// Id of the mesh state - /// Mesh dimensions - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_set", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dSet([In] int meshKernelId, [In] ref Mesh2DNative mesh2DNative); - - /// - /// Get the double value used in the back-end library as separator and missing value - /// - /// The double missing value - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_separator", CallingConvention = CallingConvention.Cdecl)] - internal static extern double GetSeparator(); - - /// - /// Gets the double value used to separate the inner part of a polygon from its outer part - /// - /// The double missing value used in meshkernel - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_inner_outer_separator", CallingConvention = CallingConvention.Cdecl)] - internal static extern double GetInnerOuterSeparator(); - - /// - /// Triangle interpolation - /// - /// The id of the mesh state - /// The samples coordinates and values - /// The location type - /// The interpolation results with x and y coordinates - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_triangulation_interpolation", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Mesh2dTriangulationInterpolation([In] int meshKernelId, [In] ref GeometryListNative samples, [In] int locationType, [In][Out] ref GeometryListNative results); - - /// - /// Compute the network chainages from fixed point locations - /// - /// The id of the mesh state - /// - /// The fixed chainages for each polyline. Chunks are separated by the separator, each chunk - /// corresponds to a polyline - /// - /// The size of fixed chainages vector - /// The minimum face size. The distance between two chainages must be no less than this length - /// The offset to use for fixed chainages - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_compute_fixed_chainages", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Network1dComputeFixedChainages([In] int meshKernelId, - [In] IntPtr fixedChainages, - [In] int sizeFixedChainages, - [In] double minFaceSize, - [In] double fixedChainagesOffset); - - /// - /// Network1d compute offsetted chainages - /// - /// The id of the mesh state - /// The meshKernelId of the block to orthogonalize - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_compute_offsetted_chainages", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Network1dComputeOffsettedChainages([In] int meshKernelId, [In] double offset); - - /// - /// Sets the Network1D state - /// - /// The id of the mesh state - /// The polylines describing the network - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_set", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Network1dSet([In] int meshKernelId, [In] ref GeometryListNative polylines); - - /// - /// Convert network chainages to mesh1d nodes and edges - /// - /// - /// The meshKernelId The id of the mesh state - /// - /// The minFaceSize The minimum face size below which two nodes will be merged - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_to_mesh1d", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Network1dToMesh1d(int meshKernelId, double minFaceSize); - - /// - /// Get the number of vertices of the offsetted polygon - /// - /// Id of the mesh state - /// The coordinate of the offset point - /// Compute inner/outer polygon - /// The offset distance - /// The number of vertices of the generated polygon - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_count_offset", CallingConvention = CallingConvention.Cdecl)] - internal static extern int PolygonCountOffset([In] int meshKernelId, - [In] ref GeometryListNative geometryListIn, - [In] int innerPolygon, - [In] double distance, - [In][Out] ref int numberOfPolygonVertices); - - /// - /// Count the number of vertices after polygon refinment - /// - /// Id of the mesh state - /// The input polygon - /// The index of the first vertex - /// The index of the second vertex - /// The refinement distance - /// The number of vertices after refinement - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_count_refine", CallingConvention = CallingConvention.Cdecl)] - internal static extern int PolygonCountRefine([In] int meshKernelId, [In] ref GeometryListNative geometryListIn, [In] int firstIndex, [In] int secondIndex, [In] double distance, [In][Out] ref int numberOfPolygonVertices); - - /// - /// Selects points in polygons - /// - /// Id of the mesh state - /// The polygon(s) used for selection - /// The points to select - /// The selected points in the zCoordinates field (0.0 not selected, 1.0 selected) - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_get_included_points", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetPointsInPolygon([In] int meshKernelId, [In] ref GeometryListNative inputPolygon, [In] ref GeometryListNative inputPoints, [In][Out] ref GeometryListNative selectedPoints); - - /// - /// Get the offsetted polygon - /// - /// Id of the mesh state - /// The coordinate of the offset point - /// Compute inner/outer polygon - /// The offset distance - /// The offsetted polygon - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_get_offset", CallingConvention = CallingConvention.Cdecl)] - internal static extern int PolygonGetOffset([In] int meshKernelId, [In] ref GeometryListNative geometryListIn, [In] int innerPolygon, [In] double distance, [In][Out] ref GeometryListNative geometryListOut); - - /// - /// Gets the refined polygon - /// - /// Id of the mesh state - /// The input polygons - /// The index of the first vertex - /// The index of the second vertex - /// The refinement distance - /// - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_refine", CallingConvention = CallingConvention.Cdecl)] - internal static extern int PolygonRefine([In] int meshKernelId, [In] ref GeometryListNative geometryListIn, [In] int firstIndex, [In] int secondIndex, [In] double distance, [In][Out] ref GeometryListNative geometryListOut); - - /// - /// Redo editing action - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_redo_state", CallingConvention = CallingConvention.Cdecl)] - internal static extern int RedoState(int meshKernelId, [In][Out] ref bool redone); - - /// - /// Redo editing action - /// - /// Id of the mesh state - /// Error code - [DllImport(MeshKernelDllName, EntryPoint = "mkernel_undo_state", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UndoState(int meshKernelId, [In][Out] ref bool undone); - } + + /// + /// Compute the global mesh with a given number of points along the longitude and latitude directions. + /// + /// Id of the mesh state + /// The number of points along the longitude + /// The number of points along the latitude (half hemisphere) + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_global", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMakeGlobal(int meshKernelId, int numLongitudeNodes, int numLatitudeNodes); + + /// + /// Make a triangular grid in a polygon + /// + /// Id of the mesh state + /// The polygon where to triangulate + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_triangular_mesh_from_polygon", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMakeTriangularMeshFromPolygon([In] int meshKernelId, [In] ref GeometryListNative geometryListNative); + + /// + /// Make a triangular mesh from samples + /// + /// Id of the mesh state + /// The samples where to triangulate + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_triangular_mesh_from_samples", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMakeTriangularMeshFromSamples([In] int meshKernelId, [In] ref GeometryListNative geometryListNative); + + /// + /// Makes a rectangular mesh + /// + /// The id of the mesh state + /// The structure containing the make grid parameters + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_rectangular_mesh", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMakeRectangularMesh([In] int meshKernelId, + [In] ref MakeGridParametersNative makeGridParameters); + + /// + /// Makes a rectangular mesh from a polygon + /// + /// The id of the mesh state + /// The structure containing the make grid parameters + /// The polygons to account for + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_rectangular_mesh_from_polygon", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMakeRectangularMeshFromPolygon([In] int meshKernelId, + [In] ref MakeGridParametersNative makeGridParameters, + [In] ref GeometryListNative geometryList); + + /// + /// Makes a rectangular mesh on a defined extension + /// + /// The id of the mesh state + /// The structure containing the make grid parameters + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_make_rectangular_mesh_on_extension", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMakeRectangularMeshOnExtension([In] int meshKernelId, + [In] ref MakeGridParametersNative makeGridParameters); + + /// + /// Merges vertices, effectively removing small edges. The merging distance is computed internally based on the minimum + /// edge size. + /// + /// Id of the mesh state + /// + /// The polygon where to perform the operation. If empty the operation is performed over + /// the entire mesh + /// + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_merge_nodes", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMergeNodes([In] int meshKernelId, [In] ref GeometryListNative geometryListNative); + + /// + /// Merges vertices within a defined distance in a polygon, effectively removing small edges + /// + /// Id of the mesh state + /// + /// The polygon where to perform the operation. If empty the operation is performed over + /// the entire mesh + /// + /// The distance below which two nodes will be merged + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_merge_nodes_with_merging_distance", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMergeNodesWithMergingDistance([In] int meshKernelId, [In] ref GeometryListNative geometryListNative, [In] double mergingDistance); + + /// + /// Merges vertex + /// + /// to + /// + /// + /// Id of the mesh state + /// The index of the first vertex to merge + /// The index of the second vertex to merge + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_merge_two_nodes", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMergeTwoNodes([In] int meshKernelId, [In] int startVertexIndex, [In] int endVertexIndex); + + /// + /// Function to move a selected node to a new position + /// + /// Id of the mesh state + /// The new x coordinate + /// The new y coordinate + /// The index of the mesh2d node to be moved + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_move_node", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dMoveNode([In] int meshKernelId, + [In] double xCoordinate, + [In] double yCoordinate, + [In] int nodeIndex); + + /// + /// Prepare outer orthogonalization iteration (interactive mode) + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_prepare_outer_iteration_orthogonalization", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dPrepareOuterIterationOrthogonalization([In] int meshKernelId); + + /// + /// Refine based on gridded samples + /// + /// The id of the mesh state + /// The gridded samples + /// The mesh refinement parameters + /// Use nodal refinement + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_refine_based_on_gridded_samples", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dRefineBasedOnGriddedSamples([In] int meshKernelId, + [In] ref GriddedSamplesNative griddedSamplesNative, + [In] ref MeshRefinementParametersNative meshRefinementParameters, + [In] bool useNodalRefinement); + + /// + /// Refine a grid based on polygon + /// + /// Id of the mesh state + /// The closed polygon where to perform the refinement + /// The settings for the mesh refinement algorithm + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_refine_based_on_polygon", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dRefineBasedOnPolygon([In] int meshKernelId, + [In] ref GeometryListNative geometryListNative, + [In] ref MeshRefinementParametersNative meshRefinementParametersNative); + + /// + /// Refine a grid based on the samples contained in the geometry list + /// + /// Id of the mesh state + /// The sample set + /// + /// The relative search radius relative to the face size, used for some interpolation + /// algorithms + /// + /// The minimum number of samples used for some averaging algorithms + /// The mesh refinement parameters + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_refine_based_on_samples", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dRefineBasedOnSamples([In] int meshKernelId, + [In] ref GeometryListNative geometryListNative, + [In] double relativeSearchRadius, + [In] int minimumNumSamples, + [In] ref MeshRefinementParametersNative meshRefinementParameters); + + /// + /// Rotates a mesh2d about a given point by a given angle + /// + /// Id of the mesh state + /// >X-coordinate of the centre of rotation + /// Y-coordinate of the centre of rotation> + /// Angle of rotation in degrees + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_rotate", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dRotate([In] int meshKernelId, + [In] double centreX, + [In] double centreY, + [In] double angle); + + /// + /// Translates a mesh2d + /// + /// Id of the mesh state + /// X-component of the translation vector + /// Y-component of the translation vector + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_translate", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dTranslate([In] int meshKernelId, + [In] double translationX, + [In] double translationY); + + /// + /// Synchronize provided mesh ( + /// + /// and + /// + /// ) with the mesh state with + /// + /// + /// Id of the mesh state + /// Mesh dimensions + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_set", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dSet([In] int meshKernelId, [In] ref Mesh2DNative mesh2DNative); + + /// + /// Get the double value used in the back-end library as separator and missing value + /// + /// The double missing value + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_separator", CallingConvention = CallingConvention.Cdecl)] + internal static extern double GetSeparator(); + + /// + /// Gets the double value used to separate the inner part of a polygon from its outer part + /// + /// The double missing value used in meshkernel + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_get_inner_outer_separator", CallingConvention = CallingConvention.Cdecl)] + internal static extern double GetInnerOuterSeparator(); + + /// + /// Triangle interpolation + /// + /// The id of the mesh state + /// The samples coordinates and values + /// The location type + /// The interpolation results with x and y coordinates + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_triangulation_interpolation", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Mesh2dTriangulationInterpolation([In] int meshKernelId, [In] ref GeometryListNative samples, [In] int locationType, [In][Out] ref GeometryListNative results); + + /// + /// Compute the network chainages from fixed point locations + /// + /// The id of the mesh state + /// + /// The fixed chainages for each polyline. Chunks are separated by the separator, each chunk + /// corresponds to a polyline + /// + /// The size of fixed chainages vector + /// The minimum face size. The distance between two chainages must be no less than this length + /// The offset to use for fixed chainages + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_compute_fixed_chainages", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Network1dComputeFixedChainages([In] int meshKernelId, + [In] IntPtr fixedChainages, + [In] int sizeFixedChainages, + [In] double minFaceSize, + [In] double fixedChainagesOffset); + + /// + /// Network1d compute offsetted chainages + /// + /// The id of the mesh state + /// The meshKernelId of the block to orthogonalize + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_compute_offsetted_chainages", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Network1dComputeOffsettedChainages([In] int meshKernelId, [In] double offset); + + /// + /// Sets the Network1D state + /// + /// The id of the mesh state + /// The polylines describing the network + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_set", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Network1dSet([In] int meshKernelId, [In] ref GeometryListNative polylines); + + /// + /// Convert network chainages to mesh1d nodes and edges + /// + /// + /// The meshKernelId The id of the mesh state + /// + /// The minFaceSize The minimum face size below which two nodes will be merged + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_network1d_to_mesh1d", CallingConvention = CallingConvention.Cdecl)] + internal static extern int Network1dToMesh1d(int meshKernelId, double minFaceSize); + + /// + /// Get the number of vertices of the offsetted polygon + /// + /// Id of the mesh state + /// The coordinate of the offset point + /// Compute inner/outer polygon + /// The offset distance + /// The number of vertices of the generated polygon + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_count_offset", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PolygonCountOffset([In] int meshKernelId, + [In] ref GeometryListNative geometryListIn, + [In] int innerPolygon, + [In] double distance, + [In][Out] ref int numberOfPolygonVertices); + + /// + /// Count the number of vertices after polygon refinment + /// + /// Id of the mesh state + /// The input polygon + /// The index of the first vertex + /// The index of the second vertex + /// The refinement distance + /// The number of vertices after refinement + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_count_refine", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PolygonCountRefine([In] int meshKernelId, [In] ref GeometryListNative geometryListIn, [In] int firstIndex, [In] int secondIndex, [In] double distance, [In][Out] ref int numberOfPolygonVertices); + + /// + /// Selects points in polygons + /// + /// Id of the mesh state + /// The polygon(s) used for selection + /// The points to select + /// The selected points in the zCoordinates field (0.0 not selected, 1.0 selected) + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_get_included_points", CallingConvention = CallingConvention.Cdecl)] + internal static extern int GetPointsInPolygon([In] int meshKernelId, [In] ref GeometryListNative inputPolygon, [In] ref GeometryListNative inputPoints, [In][Out] ref GeometryListNative selectedPoints); + + /// + /// Get the offsetted polygon + /// + /// Id of the mesh state + /// The coordinate of the offset point + /// Compute inner/outer polygon + /// The offset distance + /// The offsetted polygon + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_get_offset", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PolygonGetOffset([In] int meshKernelId, [In] ref GeometryListNative geometryListIn, [In] int innerPolygon, [In] double distance, [In][Out] ref GeometryListNative geometryListOut); + + /// + /// Gets the refined polygon + /// + /// Id of the mesh state + /// The input polygons + /// The index of the first vertex + /// The index of the second vertex + /// The refinement distance + /// + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_polygon_refine", CallingConvention = CallingConvention.Cdecl)] + internal static extern int PolygonRefine([In] int meshKernelId, [In] ref GeometryListNative geometryListIn, [In] int firstIndex, [In] int secondIndex, [In] double distance, [In][Out] ref GeometryListNative geometryListOut); + + /// + /// Redo editing action + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_redo_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int RedoState(int meshKernelId, [In][Out] ref bool redone); + + /// + /// Redo editing action + /// + /// Id of the mesh state + /// Error code + [DllImport(MeshKernelDllName, EntryPoint = "mkernel_undo_state", CallingConvention = CallingConvention.Cdecl)] + internal static extern int UndoState(int meshKernelId, [In][Out] ref bool undone); + } } \ No newline at end of file diff --git a/test/MeshKernelNETTest/Api/MeshKernelTest.cs b/test/MeshKernelNETTest/Api/MeshKernelTest.cs index 41f59ce..32823cf 100644 --- a/test/MeshKernelNETTest/Api/MeshKernelTest.cs +++ b/test/MeshKernelNETTest/Api/MeshKernelTest.cs @@ -156,6 +156,64 @@ public void Mesh2dInsertEdgeThroughApi() } } + [Test] + public void Mesh2dInsertEdgeFromCoordinatesThroughApi() + { + // Before After + // 0 ------- 1 ------- 2 ------- 3 0 ------- 1 ------- 2 ------- 3 + // | | | | | . | | | + // | | | | | . | | | + // | | | | | . | | | + // | | | | |. | | | + // 4 ------- 5 ------- 6 ------- 7 4 ------- 5 ------- 6 ------- 7 + // | | | | | | | | + // | | | | | | | | + // | | | | | | | | + // | | | | | | | | + // 8 ------- 9 ------ 10 ------ 11 8 ------- 9 ------ 10 ------ 11 + // | | | | | | | | + // | | | | | | | | + // | | | | | | | | + // | | | | | | | | + //12 ------ 13 ------ 14 ------ 15 2 ------ 13 ------ 14 ------ 15 + + // Setup + using (DisposableMesh2D mesh = CreateMesh2D(4, 4, 100, 200)) + using (var api = new MeshKernelApi()) + { + var id = 0; + var mesh2D = new DisposableMesh2D(); + try + { + int numberOfEdgesBefore = mesh.NumEdges; + id = api.AllocateState(0); + + Assert.AreEqual(0, api.Mesh2dSet(id, mesh)); + + var firstNewNodeIndex = 0; + var secondNewNodeIndex = 0; + var newEdgeIndex = 0; + Assert.AreEqual(0, api.Mesh2dInsertEdgeFromCoordinates(id, + 0.0, + 400.0, + 100.0, + 600.0, + ref firstNewNodeIndex, + ref secondNewNodeIndex, + ref newEdgeIndex)); + + Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2D)); + Assert.AreNotEqual(2, mesh2D.NumEdges); + Assert.AreEqual(numberOfEdgesBefore + 1, mesh2D.NumEdges); + } + finally + { + api.DeallocateState(id); + mesh2D.Dispose(); + } + } + } + [Test] public void Mesh2dMergeTwoNodesThroughApi() { From 87cd6e5eb4312006bf232c30926f65e2d1d92c39 Mon Sep 17 00:00:00 2001 From: Luca Carniato Date: Wed, 27 Mar 2024 17:56:58 +0100 Subject: [PATCH 3/5] Complete test --- test/MeshKernelNETTest/Api/MeshKernelTest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/MeshKernelNETTest/Api/MeshKernelTest.cs b/test/MeshKernelNETTest/Api/MeshKernelTest.cs index 32823cf..44c130f 100644 --- a/test/MeshKernelNETTest/Api/MeshKernelTest.cs +++ b/test/MeshKernelNETTest/Api/MeshKernelTest.cs @@ -205,6 +205,9 @@ public void Mesh2dInsertEdgeFromCoordinatesThroughApi() Assert.AreEqual(0, api.Mesh2dGetData(id, out mesh2D)); Assert.AreNotEqual(2, mesh2D.NumEdges); Assert.AreEqual(numberOfEdgesBefore + 1, mesh2D.NumEdges); + Assert.AreEqual(2, firstNewNodeIndex); + Assert.AreEqual(7, secondNewNodeIndex); + Assert.AreEqual(24, newEdgeIndex); } finally { From 88a3db90fa9874fe651c5aeaa234b09d5f034a7e Mon Sep 17 00:00:00 2001 From: Luca Carniato Date: Thu, 28 Mar 2024 11:23:21 +0100 Subject: [PATCH 4/5] Update meshkernel nuget --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 0a07bb5..5cc0841 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,7 +3,7 @@ true - + From 8da29c3ccee19fa0059b035075d8562480a41df1 Mon Sep 17 00:00:00 2001 From: Luca Carniato Date: Thu, 28 Mar 2024 12:03:20 +0100 Subject: [PATCH 5/5] Account for comments --- src/MeshKernelNET/Api/IMeshKernelApi.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MeshKernelNET/Api/IMeshKernelApi.cs b/src/MeshKernelNET/Api/IMeshKernelApi.cs index ab606ca..69a74ec 100644 --- a/src/MeshKernelNET/Api/IMeshKernelApi.cs +++ b/src/MeshKernelNET/Api/IMeshKernelApi.cs @@ -1040,7 +1040,8 @@ int Mesh2dInitializeOrthogonalization(int meshKernelId, /// Error code int Mesh2dInsertEdge(int meshKernelId, int startVertexIndex, int endVertexIndex, ref int edgeIndex); - /// @brief Insert a new mesh2d edge from 2 coordinates + /// @brief Insert a new mesh2d edge from 2 coordinates. If the coordinates do not match an existing node within a computed search radius, new ones will be created. + /// The search radius is computed internally based on the minimum mesh size and the distance between the two nodes. /// The id of the mesh state /// The index of the first node to connect /// The index of the second node to connect