Skip to content

Commit

Permalink
GRIDEDIT-1196/GRIDEDIT-1197: Bind Casulli refinement and de-refinemen…
Browse files Browse the repository at this point in the history
…t API functions (#70)
  • Loading branch information
ahmad-el-sayed authored Jul 16, 2024
1 parent 45895c7 commit 8b6e77f
Show file tree
Hide file tree
Showing 4 changed files with 1,431 additions and 1,060 deletions.
52 changes: 52 additions & 0 deletions src/MeshKernelNET/Api/IMeshKernelApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,58 @@ int Mesh2dAveragingInterpolation(int meshKernelId,
double relativeSearchSize,
int minNumSamples,
ref DisposableGeometryList results);
/// <summary>
/// De-refine a whole mesh using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <returns>Error code</returns
int Mesh2dCasulliDerefinement(int meshKernelId);

/// <summary>
/// De-refine a mesh on polygon using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <param name="geometryListPolygon">The input polygons</param>
/// <returns></returns>
int Mesh2dCasulliDerefinementOnPolygon(int meshKernelId,
[In] DisposableGeometryList geometryListPolygon);


/// <summary>
/// Get the list of elements that will be removed after applying the Casulli de-refinement algorithm to a whole mesh
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <param name="geometryListElements">The elements to be removed </param>
/// <returns>Error code</returns>
int Mesh2dCasulliDerefinementElements([In] int meshKernelId,
[In][Out] ref DisposableGeometryList geometryListElements);

/// <summary>
/// Get the list of elements that will be removed after applying the Casulli de-refinement algorithm to a mesh on polygon
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <param name="geometryListPolygon">The input polygon</param>
/// <param name="geometryListElements">The elements to be removed </param>
/// <returns>Error code</returns>
int Mesh2dCasulliDerefinementElementsOnPolygon([In] int meshKernelId,
[In] DisposableGeometryList geometryListPolygon,
[In][Out] ref DisposableGeometryList geometryListElements);

/// <summary>
/// Refine a whole mesh using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <returns>Error code</returns
int Mesh2dCasulliRefinement(int meshKernelId);

/// <summary>
/// Refine a mesh on polygon using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <param name="geometryListPolygon">The input polygons</param>
/// <returns></returns>
int Mesh2dCasulliRefinementOnPolygon(int meshKernelId,
[In] DisposableGeometryList geometryListPolygon);

/// <summary>
/// Perform inner orthogonalization iteration
Expand Down
44 changes: 44 additions & 0 deletions src/MeshKernelNET/Api/MeshKernelApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,50 @@ public int Mesh2dAveragingInterpolation(int meshKernelId,
ref resultsNative);
}

public int Mesh2dCasulliDerefinement(int meshKernelId)
{
return MeshKernelDll.Mesh2dCasulliDerefinement(meshKernelId);
}

public int Mesh2dCasulliDerefinementOnPolygon(int meshKernelId,
[In] DisposableGeometryList geometryListPolygon)
{
GeometryListNative geometryListNativePolygon = geometryListPolygon?.CreateNativeObject() ?? new GeometryListNative { numberOfCoordinates = 0 };
return MeshKernelDll.Mesh2dCasulliDerefinementOnPolygon(meshKernelId,
ref geometryListNativePolygon);
}

public int Mesh2dCasulliDerefinementElements(int meshKernelId,
[In][Out] ref DisposableGeometryList geometryListElements)
{
GeometryListNative geometryListNativeElements = geometryListElements.CreateNativeObject();
return MeshKernelDll.Mesh2dCasulliDerefinementElements(meshKernelId,
ref geometryListNativeElements);
}

public int Mesh2dCasulliDerefinementElementsOnPolygon(int meshKernelId,
[In] DisposableGeometryList geometryListPolygon,
[In][Out] ref DisposableGeometryList geometryListElements)
{
GeometryListNative geometryListNativePolygon = geometryListPolygon?.CreateNativeObject() ?? new GeometryListNative { numberOfCoordinates = 0 };
GeometryListNative geometryListNativeElements = geometryListElements.CreateNativeObject();
return MeshKernelDll.Mesh2dCasulliDerefinementElementsOnPolygon(meshKernelId,
ref geometryListNativePolygon,
ref geometryListNativeElements);
}

public int Mesh2dCasulliRefinement(int meshKernelId)
{
return MeshKernelDll.Mesh2dCasulliRefinement(meshKernelId);
}

public int Mesh2dCasulliRefinementOnPolygon(int meshKernelId,
[In] DisposableGeometryList geometryListPolygon)
{
GeometryListNative geometryListPolygonNative = geometryListPolygon?.CreateNativeObject() ?? new GeometryListNative { numberOfCoordinates = 0 };
return MeshKernelDll.Mesh2dCasulliRefinementOnPolygon(meshKernelId, ref geometryListPolygonNative);
}

public int Mesh2dComputeInnerOrtogonalizationIteration(int meshKernelId)
{
return MeshKernelDll.Mesh2dComputeInnerOrtogonalizationIteration(meshKernelId);
Expand Down
58 changes: 58 additions & 0 deletions src/MeshKernelNET/Native/MeshKernelDll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,64 @@ internal static extern int Mesh2dAveragingInterpolation([In] int meshKernelId,
[In] double relativeSearchSize,
[In] int minNumSamples,
[In][Out] ref GeometryListNative results);
/// <summary>
/// De-refine a whole mesh using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <returns>Error code</returns>
[DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_casulli_derefinement", CallingConvention = CallingConvention.Cdecl)]
internal static extern int Mesh2dCasulliDerefinement([In] int meshKernelId);

/// <summary>
/// De-refine a mesh on polygon using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <param name="geometryListNativePolygon">The polygon where to perform the de-refinement </param>
/// <returns>Error code</returns>
[DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_casulli_derefinement_on_polygon", CallingConvention = CallingConvention.Cdecl)]
internal static extern int Mesh2dCasulliDerefinementOnPolygon([In] int meshKernelId,
[In] ref GeometryListNative geometryListNativePolygon);

/// <summary>
/// Get the list of elements that will be removed after applying the Casulli de-refinement algorithm to a whole mesh
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <param name="geometryListNativeElements">The elements to be removed </param>
/// <returns>Error code</returns>
[DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_casulli_derefinement_elements", CallingConvention = CallingConvention.Cdecl)]
internal static extern int Mesh2dCasulliDerefinementElements([In] int meshKernelId,
[In][Out] ref GeometryListNative geometryListNativeElements);

/// <summary>
/// Get the list of elements that will be removed after applying the Casulli de-refinement algorithm to a mesh on polygon
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <param name="geometryListNativePolygon">The input polygon</param>
/// <param name="geometryListNativeElements">The elements to be removed </param>
/// <returns>Error code</returns>
[DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_casulli_derefinement_elements_on_polygon", CallingConvention = CallingConvention.Cdecl)]
internal static extern int Mesh2dCasulliDerefinementElementsOnPolygon([In] int meshKernelId,
[In] ref GeometryListNative geometryListNativePolygon,
[In][Out] ref GeometryListNative geometryListNativeElements);


/// <summary>
/// Refine a whole mesh using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param>
/// <returns>Error code</returns>
[DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_casulli_refinement", CallingConvention = CallingConvention.Cdecl)]
internal static extern int Mesh2dCasulliRefinement([In] int meshKernelId);

/// <summary>
/// Refine a mesh on polygon using the Casulli algorithm
/// </summary>
/// <param name="meshKernelId">Id of the mesh state</param
/// <param name="geometryListNativePolygon">The polygon where to perform the refinement </param>
/// <returns>Error code</returns>
[DllImport(MeshKernelDllName, EntryPoint = "mkernel_mesh2d_casulli_refinement_on_polygon", CallingConvention = CallingConvention.Cdecl)]
internal static extern int Mesh2dCasulliRefinementOnPolygon([In] int meshKernelId,
[In] ref GeometryListNative geometryListNativePolygon);

/// <summary>
/// Performs inner orthogonalization iteration, by slowly moving the mesh nodes to new optimal positions (interactive mode)
Expand Down
Loading

0 comments on commit 8b6e77f

Please sign in to comment.