Skip to content

Commit

Permalink
add capi
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti committed Oct 2, 2023
1 parent d401ba4 commit 17f9566
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/capi/sfcgal_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const SFCGAL::Geometry *>(geom);
std::unique_ptr<SFCGAL::PolyhedralSurface> 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 *
Expand Down
11 changes: 11 additions & 0 deletions src/capi/sfcgal_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17f9566

Please sign in to comment.