diff --git a/NEWS b/NEWS index 40f8a101..6115b8eb 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +1.5.2 (2024-03-XX): + * Expose as_vtk to C Api (Loïc Bartoletti) 1.5.1 (2023-12-21): * Rewrite and fix visibility algorithm (Loïc Bartoletti) * Apply clang-tidy fixes (Loïc Bartoletti) diff --git a/src/capi/sfcgal_c.cpp b/src/capi/sfcgal_c.cpp index 8a1dc6d4..238dcc7c 100644 --- a/src/capi/sfcgal_c.cpp +++ b/src/capi/sfcgal_c.cpp @@ -21,6 +21,7 @@ #include "SFCGAL/detail/io/Serialization.h" #include "SFCGAL/io/ewkt.h" +#include "SFCGAL/io/vtk.h" #include "SFCGAL/io/wkb.h" #include "SFCGAL/io/wkt.h" @@ -280,6 +281,13 @@ sfcgal_geometry_as_wkb(const sfcgal_geometry_t *pgeom, char **buffer, strncpy(*buffer, wkb.c_str(), *len);) } +extern "C" void +sfcgal_geometry_as_vtk(const sfcgal_geometry_t *pgeom, const char *filename) +{ + SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR_NO_RET( + io::vtk(*reinterpret_cast(pgeom), filename);) +} + /** * Point */ diff --git a/src/capi/sfcgal_c.h b/src/capi/sfcgal_c.h index 7e5a5fa7..fea3dbea 100644 --- a/src/capi/sfcgal_c.h +++ b/src/capi/sfcgal_c.h @@ -170,6 +170,13 @@ sfcgal_geometry_as_text_decim(const sfcgal_geometry_t *, int numDecimals, SFCGAL_API void sfcgal_geometry_as_wkb(const sfcgal_geometry_t *, char **buffer, size_t *len); +/** + * Creates a VTK file of the given geometry + * @ingroup capi + */ +SFCGAL_API void +sfcgal_geometry_as_vtk(const sfcgal_geometry_t *, const char *filename); + /** * Creates an empty point * @ingroup capi