From 17f9566f5c654ce0b4ec2d263b7f2fa68755d6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 2 Oct 2023 15:30:52 +0200 Subject: [PATCH] add capi --- src/capi/sfcgal_c.cpp | 20 ++++++++++++++++++++ src/capi/sfcgal_c.h | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/capi/sfcgal_c.cpp b/src/capi/sfcgal_c.cpp index 350bbf4c..55c3c813 100644 --- a/src/capi/sfcgal_c.cpp +++ b/src/capi/sfcgal_c.cpp @@ -1170,6 +1170,26 @@ sfcgal_geometry_has_validity_flag(const sfcgal_geometry_t *geom) -> int return g1->hasValidityFlag() ? 1 : 0; } +extern "C" auto +sfcgal_geometry_extrude_straight_skeleton(const sfcgal_geometry_t *geom, double height) + -> sfcgal_geometry_t * +{ + const auto *g1 = reinterpret_cast(geom); + std::unique_ptr polys; + + try { + polys = SFCGAL::algorithm::extrudeStraightSkeleton(*g1, height); + } catch (std::exception &e) { + SFCGAL_WARNING("During straight_extrude_skeleton_distance(A):"); + SFCGAL_WARNING(" with A: %s", + ((const SFCGAL::Geometry *)(geom))->asText().c_str()); + SFCGAL_ERROR("%s", e.what()); + return nullptr; + } + + return polys.release(); +} + extern "C" auto sfcgal_geometry_straight_skeleton_distance_in_m(const sfcgal_geometry_t *geom) -> sfcgal_geometry_t * diff --git a/src/capi/sfcgal_c.h b/src/capi/sfcgal_c.h index 5d386425..3334055b 100644 --- a/src/capi/sfcgal_c.h +++ b/src/capi/sfcgal_c.h @@ -980,6 +980,17 @@ sfcgal_geometry_straight_skeleton(const sfcgal_geometry_t *geom); SFCGAL_API sfcgal_geometry_t * sfcgal_geometry_straight_skeleton_distance_in_m(const sfcgal_geometry_t *geom); +/** + * Returns the extrude straight skeleton of the given Polygon + * @pre geom must be a Polygon + * @pre isValid(geom) == true + * @pre isValid(geom) == true + * @post isValid(return) == true + * @ingroup capi + */ +SFCGAL_API sfcgal_geometry_t * +sfcgal_geometry_extrude_straight_skeleton(const sfcgal_geometry_t *geom, double height); + /** * Returns the approximate medial axis for the given Polygon * Approximate medial axis is based on straight skeleton