Skip to content

File sfcgal_c.cpp

FileList > capi > sfcgal_c.cpp

Go to the source code of this file

  • #include "SFCGAL/Geometry.h"
  • #include "SFCGAL/GeometryCollection.h"
  • #include "SFCGAL/LineString.h"
  • #include "SFCGAL/MultiLineString.h"
  • #include "SFCGAL/MultiPoint.h"
  • #include "SFCGAL/MultiPolygon.h"
  • #include "SFCGAL/MultiSolid.h"
  • #include "SFCGAL/Point.h"
  • #include "SFCGAL/Polygon.h"
  • #include "SFCGAL/PolyhedralSurface.h"
  • #include "SFCGAL/PreparedGeometry.h"
  • #include "SFCGAL/Solid.h"
  • #include "SFCGAL/Triangle.h"
  • #include "SFCGAL/TriangulatedSurface.h"
  • #include "SFCGAL/version.h"
  • #include "SFCGAL/capi/sfcgal_c.h"
  • #include "SFCGAL/detail/io/Serialization.h"
  • #include "SFCGAL/io/OBJ.h"
  • #include "SFCGAL/io/ewkt.h"
  • #include "SFCGAL/io/vtk.h"
  • #include "SFCGAL/io/wkb.h"
  • #include "SFCGAL/io/wkt.h"
  • #include "SFCGAL/algorithm/alphaShapes.h"
  • #include "SFCGAL/algorithm/area.h"
  • #include "SFCGAL/algorithm/buffer3D.h"
  • #include "SFCGAL/algorithm/convexHull.h"
  • #include "SFCGAL/algorithm/covers.h"
  • #include "SFCGAL/algorithm/difference.h"
  • #include "SFCGAL/algorithm/distance.h"
  • #include "SFCGAL/algorithm/distance3d.h"
  • #include "SFCGAL/algorithm/extrude.h"
  • #include "SFCGAL/algorithm/intersection.h"
  • #include "SFCGAL/algorithm/intersects.h"
  • #include "SFCGAL/algorithm/isValid.h"
  • #include "SFCGAL/algorithm/lineSubstring.h"
  • #include "SFCGAL/algorithm/minkowskiSum.h"
  • #include "SFCGAL/algorithm/offset.h"
  • #include "SFCGAL/algorithm/partition_2.h"
  • #include "SFCGAL/algorithm/plane.h"
  • #include "SFCGAL/algorithm/rotate.h"
  • #include "SFCGAL/algorithm/scale.h"
  • #include "SFCGAL/algorithm/straightSkeleton.h"
  • #include "SFCGAL/algorithm/tesselate.h"
  • #include "SFCGAL/algorithm/translate.h"
  • #include "SFCGAL/algorithm/union.h"
  • #include "SFCGAL/algorithm/visibility.h"
  • #include "SFCGAL/algorithm/volume.h"
  • #include "SFCGAL/triangulate/triangulate2DZ.h"
  • #include "SFCGAL/detail/transform/ForceOrderPoints.h"
  • #include "SFCGAL/detail/transform/ForceZOrderPoints.h"
  • #include "SFCGAL/detail/transform/RoundTransform.h"
  • #include <cmath>

Public Static Attributes

Type Name
sfcgal_error_handler_t __sfcgal_error_handler = = printf
sfcgal_error_handler_t __sfcgal_warning_handler = = printf
sfcgal_alloc_handler_t sfcgal_alloc_handler = = malloc
sfcgal_free_handler_t sfcgal_free_handler = = free

Public Functions

Type Name
SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (intersection, SFCGAL::algorithm::intersection)
SFCGAL::algorithm::intersection3D SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (difference, SFCGAL::algorithm::difference)
SFCGAL::algorithm::intersection3D SFCGAL::algorithm::difference3D SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (union_3d, SFCGAL::algorithm::union3D)
SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE (covers_3d, SFCGAL::algorithm::covers3D)
SFCGAL::algorithm::intersects SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE (intersects_3d, SFCGAL::algorithm::intersects3D)
SFCGAL::algorithm::intersection3D SFCGAL::algorithm::difference3D SFCGAL::algorithm::convexHull SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION (convexhull_3d, SFCGAL::algorithm::convexHull3D)
SFCGAL::algorithm::intersection3D SFCGAL::algorithm::difference3D SFCGAL::algorithm::convexHull SFCGAL::algorithm::straightSkeleton SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION (approximate_medial_axis, SFCGAL::algorithm::approximateMedialAxis)
auto down_cast (sfcgal_geometry_t * p)
auto down_const_cast (const sfcgal_geometry_t * p)
auto sfcgal_approx_convex_partition_2 (const sfcgal_geometry_t * geom)
auto sfcgal_full_version ()
auto sfcgal_geometry_alpha_shapes (const sfcgal_geometry_t * geom, double alpha, bool allow_holes)
void sfcgal_geometry_as_hexwkb (const sfcgal_geometry_t * pgeom, char ** buffer, size_t * len)
void sfcgal_geometry_as_obj (const sfcgal_geometry_t * pgeom, char ** buffer, size_t * len)
void sfcgal_geometry_as_obj_file (const sfcgal_geometry_t * pgeom, const char * filename)
void sfcgal_geometry_as_text (const sfcgal_geometry_t * pgeom, char ** buffer, size_t * len)
void sfcgal_geometry_as_text_decim (const sfcgal_geometry_t * pgeom, int numDecimals, char ** buffer, size_t * len)
auto sfcgal_geometry_as_vtk (const sfcgal_geometry_t * pgeom, char ** buffer, size_t * len)
auto sfcgal_geometry_as_vtk_file (const sfcgal_geometry_t * pgeom, const char * filename)
void sfcgal_geometry_as_wkb (const sfcgal_geometry_t * pgeom, char ** buffer, size_t * len)
auto sfcgal_geometry_buffer3d (const sfcgal_geometry_t * geom, double radius, int segments, sfcgal_buffer3d_type_t buffer_type)
auto sfcgal_geometry_clone (const sfcgal_geometry_t * geom)
void sfcgal_geometry_collection_add_geometry (sfcgal_geometry_t * collection, sfcgal_geometry_t * geometry)
auto sfcgal_geometry_collection_create ()
auto sfcgal_geometry_collection_geometry_n (const sfcgal_geometry_t * collection, size_t i)
auto sfcgal_geometry_collection_num_geometries (const sfcgal_geometry_t * collection)
void sfcgal_geometry_delete (sfcgal_geometry_t * geom)
auto sfcgal_geometry_extrude (const sfcgal_geometry_t * geom, double ex, double ey, double ez)
auto sfcgal_geometry_extrude_polygon_straight_skeleton (const sfcgal_geometry_t * geom, double building_height, double roof_height)
auto sfcgal_geometry_extrude_straight_skeleton (const sfcgal_geometry_t * geom, double height)
auto sfcgal_geometry_force_lhr (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_force_rhr (const sfcgal_geometry_t * geom)
void sfcgal_geometry_force_valid (sfcgal_geometry_t * geom, int valid)
auto sfcgal_geometry_has_validity_flag (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_is_3d (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_is_empty (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_is_measured (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_is_planar (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_is_valid (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_is_valid_detail (const sfcgal_geometry_t * geom, char ** invalidity_reason, sfcgal_geometry_t ** invalidity_location)
auto sfcgal_geometry_line_sub_string (const sfcgal_geometry_t * geom, double start, double end)
auto sfcgal_geometry_make_solid (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_minkowski_sum (const sfcgal_geometry_t * geom1, const sfcgal_geometry_t * geom2)
auto sfcgal_geometry_offset_polygon (const sfcgal_geometry_t * geom, double radius)
auto sfcgal_geometry_optimal_alpha_shapes (const sfcgal_geometry_t * geom, bool allow_holes, size_t nb_components)
auto sfcgal_geometry_orientation (const sfcgal_geometry_t * ga)
auto sfcgal_geometry_rotate (const sfcgal_geometry_t * geom, double angle)
auto sfcgal_geometry_rotate_2d (const sfcgal_geometry_t * geom, double angle, double cx, double cy)
auto sfcgal_geometry_rotate_3d (const sfcgal_geometry_t * geom, double angle, double ax, double ay, double az)
auto sfcgal_geometry_rotate_3d_around_center (const sfcgal_geometry_t * geom, double angle, double ax, double ay, double az, double cx, double cy, double cz)
auto sfcgal_geometry_rotate_x (const sfcgal_geometry_t * geom, double angle)
auto sfcgal_geometry_rotate_y (const sfcgal_geometry_t * geom, double angle)
auto sfcgal_geometry_rotate_z (const sfcgal_geometry_t * geom, double angle)
auto sfcgal_geometry_round (const sfcgal_geometry_t * geom, int r)
auto sfcgal_geometry_scale (const sfcgal_geometry_t * geom, double s)
auto sfcgal_geometry_scale_3d (const sfcgal_geometry_t * geom, double sx, double sy, double sz)
auto sfcgal_geometry_scale_3d_around_center (const sfcgal_geometry_t * geom, double sx, double sy, double sz, double cx, double cy, double cz)
auto sfcgal_geometry_straight_skeleton_distance_in_m (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_straight_skeleton_partition (const sfcgal_geometry_t * geom, bool autoOrientation)
auto sfcgal_geometry_translate_2d (sfcgal_geometry_t * geom, double dx, double dy)
auto sfcgal_geometry_translate_3d (sfcgal_geometry_t * geom, double dx, double dy, double dz)
auto sfcgal_geometry_triangulate_2dz (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_type_id (const sfcgal_geometry_t * geom)
auto sfcgal_geometry_visibility_point (const sfcgal_geometry_t * polygon, const sfcgal_geometry_t * point)
auto sfcgal_geometry_visibility_segment (const sfcgal_geometry_t * polygon, const sfcgal_geometry_t * pointA, const sfcgal_geometry_t * pointB)
build the visibility polygon of the segment [pointA ; pointB] on a Polygon
auto sfcgal_geometry_volume (const sfcgal_geometry_t * geom)
auto sfcgal_greene_approx_convex_partition_2 (const sfcgal_geometry_t * geom)
void sfcgal_init ()
auto sfcgal_io_read_binary_prepared (const char * str, size_t len)
auto sfcgal_io_read_ewkt (const char * str, size_t len)
auto sfcgal_io_read_wkb (const char * str, size_t len)
auto sfcgal_io_read_wkt (const char * str, size_t len)
void sfcgal_io_write_binary_prepared (const sfcgal_prepared_geometry_t * geom, char ** buffer, size_t * len)
void sfcgal_linestring_add_point (sfcgal_geometry_t * linestring, sfcgal_geometry_t * point)
auto sfcgal_linestring_create ()
auto sfcgal_linestring_num_points (const sfcgal_geometry_t * linestring)
auto sfcgal_linestring_point_n (const sfcgal_geometry_t * linestring, size_t i)
auto sfcgal_multi_linestring_create ()
auto sfcgal_multi_point_create ()
auto sfcgal_multi_polygon_create ()
auto sfcgal_multi_solid_create ()
auto sfcgal_optimal_convex_partition_2 (const sfcgal_geometry_t * geom)
auto sfcgal_point_create ()
auto sfcgal_point_create_from_xy (double x, double y)
auto sfcgal_point_create_from_xym (double x, double y, double m)
auto sfcgal_point_create_from_xyz (double x, double y, double z)
auto sfcgal_point_create_from_xyzm (double x, double y, double z, double m)
auto sfcgal_point_m (const sfcgal_geometry_t * geom)
auto sfcgal_point_x (const sfcgal_geometry_t * geom)
auto sfcgal_point_y (const sfcgal_geometry_t * geom)
auto sfcgal_point_z (const sfcgal_geometry_t * geom)
void sfcgal_polygon_add_interior_ring (sfcgal_geometry_t * polygon, sfcgal_geometry_t * ring)
auto sfcgal_polygon_create ()
auto sfcgal_polygon_create_from_exterior_ring (sfcgal_geometry_t * ring)
auto sfcgal_polygon_exterior_ring (const sfcgal_geometry_t * polygon)
auto sfcgal_polygon_interior_ring_n (const sfcgal_geometry_t * polygon, size_t i)
auto sfcgal_polygon_num_interior_rings (const sfcgal_geometry_t * polygon)
void sfcgal_polyhedral_surface_add_polygon (sfcgal_geometry_t * polyhedral, sfcgal_geometry_t * polygon)
auto sfcgal_polyhedral_surface_create ()
auto sfcgal_polyhedral_surface_num_polygons (const sfcgal_geometry_t * polyhedral)
auto sfcgal_polyhedral_surface_polygon_n (const sfcgal_geometry_t * polyhedral, size_t i)
void sfcgal_prepared_geometry_as_ewkt (const sfcgal_prepared_geometry_t * prepared, int num_decimals, char ** buffer, size_t * len)
auto sfcgal_prepared_geometry_create ()
auto sfcgal_prepared_geometry_create_from_geometry (sfcgal_geometry_t * geometry, srid_t srid)
void sfcgal_prepared_geometry_delete (sfcgal_prepared_geometry_t * prepared)
auto sfcgal_prepared_geometry_geometry (const sfcgal_prepared_geometry_t * prepared)
void sfcgal_prepared_geometry_set_geometry (sfcgal_prepared_geometry_t * prepared, sfcgal_geometry_t * geometry)
void sfcgal_prepared_geometry_set_srid (sfcgal_prepared_geometry_t * prepared, srid_t srid)
auto sfcgal_prepared_geometry_srid (const sfcgal_prepared_geometry_t * prepared)
void sfcgal_set_alloc_handlers (sfcgal_alloc_handler_t malloc_handler, sfcgal_free_handler_t free_handler)
void sfcgal_set_error_handlers (sfcgal_error_handler_t warning_handler, sfcgal_error_handler_t error_handler)
void sfcgal_set_geometry_validation (int enabled)
void sfcgal_solid_add_interior_shell (sfcgal_geometry_t * solid, sfcgal_geometry_t * shell)
auto sfcgal_solid_create ()
auto sfcgal_solid_create_from_exterior_shell (sfcgal_geometry_t * shell)
auto sfcgal_solid_num_shells (const sfcgal_geometry_t * solid)
auto sfcgal_solid_shell_n (const sfcgal_geometry_t * solid, size_t i)
auto sfcgal_triangle_create ()
auto sfcgal_triangle_create_from_points (const sfcgal_geometry_t * pta, const sfcgal_geometry_t * ptb, const sfcgal_geometry_t * ptc)
void sfcgal_triangle_set_vertex (sfcgal_geometry_t * triangle, int i, const sfcgal_geometry_t * vertex)
void sfcgal_triangle_set_vertex_from_xy (sfcgal_geometry_t * triangle, int i, double x, double y)
void sfcgal_triangle_set_vertex_from_xyz (sfcgal_geometry_t * triangle, int i, double x, double y, double z)
auto sfcgal_triangle_vertex (const sfcgal_geometry_t * triangle, int i)
void sfcgal_triangulated_surface_add_triangle (sfcgal_geometry_t * tin, sfcgal_geometry_t * triangle)
auto sfcgal_triangulated_surface_create ()
auto sfcgal_triangulated_surface_num_triangles (const sfcgal_geometry_t * tin)
auto sfcgal_triangulated_surface_triangle_n (const sfcgal_geometry_t * tin, size_t i)
auto sfcgal_version ()
auto sfcgal_y_monotone_partition_2 (const sfcgal_geometry_t * geom)

Macros

Type Name
define SFCGAL_ERROR __sfcgal_error_handler
define SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR (call)
define SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR_NO_RET (call)
define SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (name, sfcgal_function)
define SFCGAL_GEOMETRY_FUNCTION_BINARY_MEASURE (name, sfcgal_function)
define SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE (name, sfcgal_function) SFCGAL_GEOMETRY_FUNCTION_BINARY_SCALAR(name, sfcgal_function, int, bool, -1)
define SFCGAL_GEOMETRY_FUNCTION_BINARY_SCALAR (name, sfcgal_function, ret_type, cpp_type, fail_value)
define SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION (name, sfcgal_function)
define SFCGAL_GEOMETRY_FUNCTION_UNARY_MEASURE (name, sfcgal_function)
define SFCGAL_WARNING __sfcgal_warning_handler

Public Static Attributes Documentation

variable __sfcgal_error_handler

sfcgal_error_handler_t __sfcgal_error_handler;

variable __sfcgal_warning_handler

sfcgal_error_handler_t __sfcgal_warning_handler;

variable sfcgal_alloc_handler

sfcgal_alloc_handler_t sfcgal_alloc_handler;

variable sfcgal_free_handler

sfcgal_free_handler_t sfcgal_free_handler;

Public Functions Documentation

function SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION

SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (
    intersection,
    SFCGAL::algorithm::intersection
) 

function SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION

SFCGAL::algorithm::intersection3D SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (
    difference,
    SFCGAL::algorithm::difference
) 

function SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION

SFCGAL::algorithm::intersection3D SFCGAL::algorithm::difference3D SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (
    union_3d,
    SFCGAL::algorithm::union3D
) 

function SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE

SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE (
    covers_3d,
    SFCGAL::algorithm::covers3D
) 

function SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE

SFCGAL::algorithm::intersects SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE (
    intersects_3d,
    SFCGAL::algorithm::intersects3D
) 

function SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION

SFCGAL::algorithm::intersection3D SFCGAL::algorithm::difference3D SFCGAL::algorithm::convexHull SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION (
    convexhull_3d,
    SFCGAL::algorithm::convexHull3D
) 

function SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION

SFCGAL::algorithm::intersection3D SFCGAL::algorithm::difference3D SFCGAL::algorithm::convexHull SFCGAL::algorithm::straightSkeleton SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION (
    approximate_medial_axis,
    SFCGAL::algorithm::approximateMedialAxis
) 

function down_cast

template<class T>
inline auto down_cast (
    sfcgal_geometry_t * p
) 

function down_const_cast

template<class T>
inline auto down_const_cast (
    const sfcgal_geometry_t * p
) 

function sfcgal_approx_convex_partition_2

auto sfcgal_approx_convex_partition_2 (
    const sfcgal_geometry_t * geom
) 

Returns the approximal convex partition of a geometry (polygon without hole)

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_full_version

auto sfcgal_full_version () 

Get full version (including CGAL and Boost versions)


function sfcgal_geometry_alpha_shapes

auto sfcgal_geometry_alpha_shapes (
    const sfcgal_geometry_t * geom,
    double alpha,
    bool allow_holes
) 

Returns the alpha shapes of geom

Precondition:

isValid(geom) == true

Precondition:

alpha >= 0

Postcondition:

isValid(return) == true


function sfcgal_geometry_as_hexwkb

void sfcgal_geometry_as_hexwkb (
    const sfcgal_geometry_t * pgeom,
    char ** buffer,
    size_t * len
) 

Returns a WKB representation as hexadecimal of the given geometry

Postcondition:

buffer is returned allocated and must be freed by the caller


function sfcgal_geometry_as_obj

void sfcgal_geometry_as_obj (
    const sfcgal_geometry_t * pgeom,
    char ** buffer,
    size_t * len
) 

Creates a OBJ string of the given geometry


function sfcgal_geometry_as_obj_file

void sfcgal_geometry_as_obj_file (
    const sfcgal_geometry_t * pgeom,
    const char * filename
) 

Creates a OBJ file of the given geometry


function sfcgal_geometry_as_text

void sfcgal_geometry_as_text (
    const sfcgal_geometry_t * pgeom,
    char ** buffer,
    size_t * len
) 

Returns a WKT representation of the given geometry using CGAL exact integer fractions as coordinate values

Postcondition:

buffer is returned allocated and must be freed by the caller


function sfcgal_geometry_as_text_decim

void sfcgal_geometry_as_text_decim (
    const sfcgal_geometry_t * pgeom,
    int numDecimals,
    char ** buffer,
    size_t * len
) 

Returns a WKT representation of the given geometry using floating point coordinate values. Floating point precision can be set via the numDecimals parameter. Setting numDecimals to -1 yields the same result as sfcgal_geometry_as_text.

Postcondition:

buffer is returned allocated and must be freed by the caller


function sfcgal_geometry_as_vtk

auto sfcgal_geometry_as_vtk (
    const sfcgal_geometry_t * pgeom,
    char ** buffer,
    size_t * len
) 

Creates a VTK string of the given geometry


function sfcgal_geometry_as_vtk_file

auto sfcgal_geometry_as_vtk_file (
    const sfcgal_geometry_t * pgeom,
    const char * filename
) 

Creates a VTK file of the given geometry


function sfcgal_geometry_as_wkb

void sfcgal_geometry_as_wkb (
    const sfcgal_geometry_t * pgeom,
    char ** buffer,
    size_t * len
) 

Returns a WKB representation of the given geometry

Postcondition:

buffer is returned allocated and must be freed by the caller


function sfcgal_geometry_buffer3d

auto sfcgal_geometry_buffer3d (
    const sfcgal_geometry_t * geom,
    double radius,
    int segments,
    sfcgal_buffer3d_type_t buffer_type
) 

Computes a 3D buffer around a geometry

Parameters:

  • geom The input geometry (must be a Point or LineString)
  • radius The buffer radius
  • segments The number of segments to use for approximating curved surfaces
  • buffer_type The type of buffer to compute (ROUND, CYLSPHERE, or FLAT)

Returns:

A new geometry representing the 3D buffer

Precondition:

isValid(geom) == true

Precondition:

radius > 0

Precondition:

segments > 2

Postcondition:

isValid(return) == true


function sfcgal_geometry_clone

auto sfcgal_geometry_clone (
    const sfcgal_geometry_t * geom
) 

Returns a deep clone of the given geometry

Postcondition:

returns a pointer to an allocated geometry that must be deallocated by sfcgal_geometry_delete


function sfcgal_geometry_collection_add_geometry

void sfcgal_geometry_collection_add_geometry (
    sfcgal_geometry_t * collection,
    sfcgal_geometry_t * geometry
) 

Adds a Geometry to a given GeometryCollection

Precondition:

collection must be a GeometryCollection

Postcondition:

the ownership of the given geometry is taken. The caller is not responsible anymore of its deallocation


function sfcgal_geometry_collection_create

auto sfcgal_geometry_collection_create () 

Geometry collection


function sfcgal_geometry_collection_geometry_n

auto sfcgal_geometry_collection_geometry_n (
    const sfcgal_geometry_t * collection,
    size_t i
) 

Returns the ith geometry of a GeometryCollection

Precondition:

collection is a GeometryCollection

Precondition:

i >= 0 and i < sfcgal_geometry_collection_num_geometries

Postcondition:

the returned Geometry is not writable and must not be deallocated by the caller


function sfcgal_geometry_collection_num_geometries

auto sfcgal_geometry_collection_num_geometries (
    const sfcgal_geometry_t * collection
) 

Returns the number of geometries of a given GeometryCollection

Precondition:

collection is a GeometryCollection


function sfcgal_geometry_delete

void sfcgal_geometry_delete (
    sfcgal_geometry_t * geom
) 

Deletes a given geometry

Precondition:

the given pointer must have been previously allocated by a creation function


function sfcgal_geometry_extrude

auto sfcgal_geometry_extrude (
    const sfcgal_geometry_t * geom,
    double ex,
    double ey,
    double ez
) 

Returns an extrusion of the given Geometry

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_extrude_polygon_straight_skeleton

auto sfcgal_geometry_extrude_polygon_straight_skeleton (
    const sfcgal_geometry_t * geom,
    double building_height,
    double roof_height
) 

Returns the union of the polygon z-extrusion (with respect to building_height) and the extrude straight skeleton (with respect to roof_height) of the given Polygon

Precondition:

geom must be a Polygon

Precondition:

isValid(geom) == true

Precondition:

roof_height != 0


function sfcgal_geometry_extrude_straight_skeleton

auto sfcgal_geometry_extrude_straight_skeleton (
    const sfcgal_geometry_t * geom,
    double height
) 

Returns the extrude straight skeleton of the given Polygon

Precondition:

geom must be a Polygon

Precondition:

isValid(geom) == true

Precondition:

height != 0


function sfcgal_geometry_force_lhr

auto sfcgal_geometry_force_lhr (
    const sfcgal_geometry_t * geom
) 

Force a Left Handed Rule on the given Geometry

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_force_rhr

auto sfcgal_geometry_force_rhr (
    const sfcgal_geometry_t * geom
) 

Force a Right Handed Rule on the given Geometry

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_force_valid

void sfcgal_geometry_force_valid (
    sfcgal_geometry_t * geom,
    int valid
) 

Sets the validity flag of the geometry. FIXME We better have geometry constructors to directly build valid geometries


function sfcgal_geometry_has_validity_flag

auto sfcgal_geometry_has_validity_flag (
    const sfcgal_geometry_t * geom
) 

Gets the validity flag of the geometry.


function sfcgal_geometry_is_3d

auto sfcgal_geometry_is_3d (
    const sfcgal_geometry_t * geom
) 

Tests if the given geometry is 3D or not


function sfcgal_geometry_is_empty

auto sfcgal_geometry_is_empty (
    const sfcgal_geometry_t * geom
) 

Tests if the given geometry is empty or not


function sfcgal_geometry_is_measured

auto sfcgal_geometry_is_measured (
    const sfcgal_geometry_t * geom
) 

Tests if the given geometry is measured (has an m) or not


function sfcgal_geometry_is_planar

auto sfcgal_geometry_is_planar (
    const sfcgal_geometry_t * geom
) 

Tests if the given Geometry is planar

Precondition:

isValid(geom) == true


function sfcgal_geometry_is_valid

auto sfcgal_geometry_is_valid (
    const sfcgal_geometry_t * geom
) 

Tests if the given geometry is valid or not


function sfcgal_geometry_is_valid_detail

auto sfcgal_geometry_is_valid_detail (
    const sfcgal_geometry_t * geom,
    char ** invalidity_reason,
    sfcgal_geometry_t ** invalidity_location
) 

Tests if the given geometry is valid or not And return details in case of invalidity

Parameters:

  • geom the input geometry
  • invalidity_reason input/output parameter. If non null, a null-terminated string could be allocated and contain reason of the invalidity
  • invalidity_location input/output parameter. If non null, a geometry could be allocated and contain the location of the invalidity

function sfcgal_geometry_line_sub_string

auto sfcgal_geometry_line_sub_string (
    const sfcgal_geometry_t * geom,
    double start,
    double end
) 

Returns the substring of the given LineString between fractional distances

Precondition:

isValid(geom) == true

Precondition:

geom is a Linestring

Precondition:

-1 <= start <= 1

Precondition:

-1 <= end <= 1

Postcondition:

isValid(return) == true


function sfcgal_geometry_make_solid

auto sfcgal_geometry_make_solid (
    const sfcgal_geometry_t * geom
) 

Convert a PolyhedralSurface to a Solid

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_minkowski_sum

auto sfcgal_geometry_minkowski_sum (
    const sfcgal_geometry_t * geom1,
    const sfcgal_geometry_t * geom2
) 

Returns the minkowski sum geom1 + geom2

Precondition:

isValid(geom1) == true

Precondition:

isValid(geom2) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_offset_polygon

auto sfcgal_geometry_offset_polygon (
    const sfcgal_geometry_t * geom,
    double radius
) 

Returns the offset polygon of the given Geometry.

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_optimal_alpha_shapes

auto sfcgal_geometry_optimal_alpha_shapes (
    const sfcgal_geometry_t * geom,
    bool allow_holes,
    size_t nb_components
) 

Returns the optimal alpha shapes of geom

Precondition:

isValid(geom) == true

Precondition:

alpha >= 0

Precondition:

nb_components >= 0

Postcondition:

isValid(return) == true


function sfcgal_geometry_orientation

auto sfcgal_geometry_orientation (
    const sfcgal_geometry_t * ga
) 

Get geometry orientation. Returns: -1 for a counter clock wise orientation, 1 for a clock wise orientation, 0 for invalid or undetermined orientation


function sfcgal_geometry_rotate

auto sfcgal_geometry_rotate (
    const sfcgal_geometry_t * geom,
    double angle
) 

Rotates a geometry around the origin (0,0,0) by a given angle

Parameters:

  • geom The geometry to rotate
  • angle Rotation angle in radians

Returns:

The rotated geometry


function sfcgal_geometry_rotate_2d

auto sfcgal_geometry_rotate_2d (
    const sfcgal_geometry_t * geom,
    double angle,
    double cx,
    double cy
) 

Rotates a geometry around a specified point by a given angle

Parameters:

  • geom The geometry to rotate
  • angle Rotation angle in radians
  • cx X-coordinate of the center point
  • cy Y-coordinate of the center point

Returns:

The rotated geometry


function sfcgal_geometry_rotate_3d

auto sfcgal_geometry_rotate_3d (
    const sfcgal_geometry_t * geom,
    double angle,
    double ax,
    double ay,
    double az
) 

Rotates a 3D geometry around a specified axis by a given angle

Parameters:

  • geom The geometry to rotate
  • angle Rotation angle in radians
  • ax X-coordinate of the axis vector
  • ay Y-coordinate of the axis vector
  • az Z-coordinate of the axis vector

Returns:

The rotated geometry


function sfcgal_geometry_rotate_3d_around_center

auto sfcgal_geometry_rotate_3d_around_center (
    const sfcgal_geometry_t * geom,
    double angle,
    double ax,
    double ay,
    double az,
    double cx,
    double cy,
    double cz
) 

Rotates a 3D geometry around a specified axis and center point by a given angle

Parameters:

  • geom The geometry to rotate
  • angle Rotation angle in radians
  • ax X-coordinate of the axis vector
  • ay Y-coordinate of the axis vector
  • az Z-coordinate of the axis vector
  • cx X-coordinate of the center point
  • cy Y-coordinate of the center point
  • cz Z-coordinate of the center point

Returns:

The rotated geometry


function sfcgal_geometry_rotate_x

auto sfcgal_geometry_rotate_x (
    const sfcgal_geometry_t * geom,
    double angle
) 

Rotates a geometry around the X axis by a given angle

Parameters:

  • geom The geometry to rotate
  • angle Rotation angle in radians

Returns:

The rotated geometry


function sfcgal_geometry_rotate_y

auto sfcgal_geometry_rotate_y (
    const sfcgal_geometry_t * geom,
    double angle
) 

Rotates a geometry around the Y axis by a given angle

Parameters:

  • geom The geometry to rotate
  • angle Rotation angle in radians

Returns:

The rotated geometry


function sfcgal_geometry_rotate_z

auto sfcgal_geometry_rotate_z (
    const sfcgal_geometry_t * geom,
    double angle
) 

Rotates a geometry around the Z axis by a given angle

Parameters:

  • geom The geometry to rotate
  • angle Rotation angle in radians

Returns:

The rotated geometry


function sfcgal_geometry_round

auto sfcgal_geometry_round (
    const sfcgal_geometry_t * geom,
    int r
) 

Round coordinates of the given Geometry

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_scale

auto sfcgal_geometry_scale (
    const sfcgal_geometry_t * geom,
    double s
) 

Scale a geometry by a given factor

Parameters:

  • geom The geometry to scale
  • s Scale factor

Returns:

The scaled geometry


function sfcgal_geometry_scale_3d

auto sfcgal_geometry_scale_3d (
    const sfcgal_geometry_t * geom,
    double sx,
    double sy,
    double sz
) 

Scale a geometry by different factors for each dimension

Parameters:

  • geom The geometry to scale
  • sx Scale factor for x dimension
  • sy Scale factor for y dimension
  • sz Scale factor for z dimension

Returns:

The scaled geometry


function sfcgal_geometry_scale_3d_around_center

auto sfcgal_geometry_scale_3d_around_center (
    const sfcgal_geometry_t * geom,
    double sx,
    double sy,
    double sz,
    double cx,
    double cy,
    double cz
) 

Scale a geometry by different factors for each dimension around a center point

Parameters:

  • geom The geometry to scale
  • sx Scale factor for x dimension
  • sy Scale factor for y dimension
  • sz Scale factor for z dimension
  • cx X-coordinate of the center point
  • cy Y-coordinate of the center point
  • cz Z-coordinate of the center point

Returns:

The scaled geometry


function sfcgal_geometry_straight_skeleton_distance_in_m

auto sfcgal_geometry_straight_skeleton_distance_in_m (
    const sfcgal_geometry_t * geom
) 

Returns the straight skeleton of the given Geometry with the distance to the border as M coordinate

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_straight_skeleton_partition

auto sfcgal_geometry_straight_skeleton_partition (
    const sfcgal_geometry_t * geom,
    bool autoOrientation
) 

Returns the straight skeleton partition for the given Polygon

Precondition:

isValid(geom) == true

Precondition:

geom must be a Polygon, Triangle or MultiPolygon

Postcondition:

isValid(return) == true


function sfcgal_geometry_translate_2d

auto sfcgal_geometry_translate_2d (
    sfcgal_geometry_t * geom,
    double dx,
    double dy
) 

Translate a geometry by a 2D vector

Parameters:

  • geom the geometry to translate
  • dx x component of the translation vector
  • dy y component of the translation vector

function sfcgal_geometry_translate_3d

auto sfcgal_geometry_translate_3d (
    sfcgal_geometry_t * geom,
    double dx,
    double dy,
    double dz
) 

Translate a geometry by a 3D vector

Parameters:

  • geom the geometry to translate
  • dx x component of the translation vector
  • dy y component of the translation vector
  • dz z component of the translation vector

function sfcgal_geometry_triangulate_2dz

auto sfcgal_geometry_triangulate_2dz (
    const sfcgal_geometry_t * geom
) 

Returns a triangulation of the given Geometry

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_geometry_type_id

auto sfcgal_geometry_type_id (
    const sfcgal_geometry_t * geom
) 

Returns the type of a given geometry


function sfcgal_geometry_visibility_point

auto sfcgal_geometry_visibility_point (
    const sfcgal_geometry_t * polygon,
    const sfcgal_geometry_t * point
) 

Returns the visibility polygon of a Point inside a Polygon

Parameters:

  • polygon input geometry
  • point input geometry

Precondition:

polygon is a valid geometry

Precondition:

point must be inside polygon or on the boundary


function sfcgal_geometry_visibility_segment

build the visibility polygon of the segment [pointA ; pointB] on a Polygon

auto sfcgal_geometry_visibility_segment (
    const sfcgal_geometry_t * polygon,
    const sfcgal_geometry_t * pointA,
    const sfcgal_geometry_t * pointB
) 

Parameters:

  • polygon input geometry
  • pointA input geometry
  • pointB input geometry

Precondition:

polygon is a valid geometry

Precondition:

pointA and pointB must be vertices of poly, adjacents and respect the direction


function sfcgal_geometry_volume

auto sfcgal_geometry_volume (
    const sfcgal_geometry_t * geom
) 

Returns the volume of geom (must be a volume)

Precondition:

isValid(geom) == true


function sfcgal_greene_approx_convex_partition_2

auto sfcgal_greene_approx_convex_partition_2 (
    const sfcgal_geometry_t * geom
) 

Returns the greene approximal convex partition of a geometry (polygon without hole)

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_init

void sfcgal_init () 

This function must be called before all the other one.


function sfcgal_io_read_binary_prepared

auto sfcgal_io_read_binary_prepared (
    const char * str,
    size_t len
) 

function sfcgal_io_read_ewkt

auto sfcgal_io_read_ewkt (
    const char * str,
    size_t len
) 

function sfcgal_io_read_wkb

auto sfcgal_io_read_wkb (
    const char * str,
    size_t len
) 

io::readWKB


function sfcgal_io_read_wkt

auto sfcgal_io_read_wkt (
    const char * str,
    size_t len
) 

io::readWKT


function sfcgal_io_write_binary_prepared

void sfcgal_io_write_binary_prepared (
    const sfcgal_prepared_geometry_t * geom,
    char ** buffer,
    size_t * len
) 

Serialization


function sfcgal_linestring_add_point

void sfcgal_linestring_add_point (
    sfcgal_geometry_t * linestring,
    sfcgal_geometry_t * point
) 

Adds a point to a LineString

Parameters:

  • linestring is the LineString where the Point has to be added to
  • point is the Point to add to the given LineString

Precondition:

i >= and i < sfcgal_linestring_num_points

Postcondition:

the ownership of Point is taken by the function


function sfcgal_linestring_create

auto sfcgal_linestring_create () 

LineString


function sfcgal_linestring_num_points

auto sfcgal_linestring_num_points (
    const sfcgal_geometry_t * linestring
) 

Returns the number of points of the given LineString

Precondition:

linestring must be a LineString


function sfcgal_linestring_point_n

auto sfcgal_linestring_point_n (
    const sfcgal_geometry_t * linestring,
    size_t i
) 

Returns the ith point of a given LineString

Parameters:

  • i is the point index in the LineString

Precondition:

linestring must be a LineString

Precondition:

i >= and i < sfcgal_linestring_num_points

Postcondition:

the returned Point is not writable and must not be deallocated by the caller


function sfcgal_multi_linestring_create

auto sfcgal_multi_linestring_create () 

Creates an empty MultiLineString


function sfcgal_multi_point_create

auto sfcgal_multi_point_create () 

Multi-*


function sfcgal_multi_polygon_create

auto sfcgal_multi_polygon_create () 

Creates an empty MultiPolygon


function sfcgal_multi_solid_create

auto sfcgal_multi_solid_create () 

Creates an empty MultiSolid


function sfcgal_optimal_convex_partition_2

auto sfcgal_optimal_convex_partition_2 (
    const sfcgal_geometry_t * geom
) 

Returns the optimal convex partition of a geometry (polygon without hole)

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


function sfcgal_point_create

auto sfcgal_point_create () 

Point


function sfcgal_point_create_from_xy

auto sfcgal_point_create_from_xy (
    double x,
    double y
) 

Creates a point from two X and Y coordinates


function sfcgal_point_create_from_xym

auto sfcgal_point_create_from_xym (
    double x,
    double y,
    double m
) 

Creates a point from three X, Y and M coordinates


function sfcgal_point_create_from_xyz

auto sfcgal_point_create_from_xyz (
    double x,
    double y,
    double z
) 

Creates a point from three X, Y and Z coordinates


function sfcgal_point_create_from_xyzm

auto sfcgal_point_create_from_xyzm (
    double x,
    double y,
    double z,
    double m
) 

Creates a point from four X, Y, Z and M coordinates


function sfcgal_point_m

auto sfcgal_point_m (
    const sfcgal_geometry_t * geom
) 

Returns the M coordinate of the given Point

Precondition:

the given geometry must be a Point

Precondition:

the given point must not be empty

Postcondition:

the M coordinate can value NaN if the given point has no m


function sfcgal_point_x

auto sfcgal_point_x (
    const sfcgal_geometry_t * geom
) 

Returns the X coordinate of the given Point

Precondition:

the given geometry must be a Point

Precondition:

the given point must not be empty


function sfcgal_point_y

auto sfcgal_point_y (
    const sfcgal_geometry_t * geom
) 

Returns the Y coordinate of the given Point

Precondition:

the given geometry must be a Point

Precondition:

the given point must not be empty


function sfcgal_point_z

auto sfcgal_point_z (
    const sfcgal_geometry_t * geom
) 

Returns the Z coordinate of the given Point

Precondition:

the given geometry must be a Point

Precondition:

the given point must not be empty

Postcondition:

the Z coordinate can value NaN if the given point is 2D only


function sfcgal_polygon_add_interior_ring

void sfcgal_polygon_add_interior_ring (
    sfcgal_geometry_t * polygon,
    sfcgal_geometry_t * ring
) 

Adds an interior ring to a given Polygon

Precondition:

polygon must be a Polygon

Precondition:

ring must be a LineString


function sfcgal_polygon_create

auto sfcgal_polygon_create () 

Polygon


function sfcgal_polygon_create_from_exterior_ring

auto sfcgal_polygon_create_from_exterior_ring (
    sfcgal_geometry_t * ring
) 

Creates an empty Polygon from an extrior ring

Precondition:

ring must be a LineString

Postcondition:

the ownership of the given ring is taken. The caller is not responsible anymore of its deallocation


function sfcgal_polygon_exterior_ring

auto sfcgal_polygon_exterior_ring (
    const sfcgal_geometry_t * polygon
) 

Returns the exterior ring of a given Polygon

Precondition:

polygon must be a Polygon

Precondition:

polygon must not be empty

Postcondition:

the returned ring is a LineString, is not writable and must not be deallocated by the caller


function sfcgal_polygon_interior_ring_n

auto sfcgal_polygon_interior_ring_n (
    const sfcgal_geometry_t * polygon,
    size_t i
) 

Returns the ith interior ring of a given Polygon

Precondition:

polygon must be a Polygon

Precondition:

i >= 0 and i < sfcgal_polygon_num_interior_rings

Postcondition:

the returned ring is a LineString, is not writable and must not be deallocated by the caller


function sfcgal_polygon_num_interior_rings

auto sfcgal_polygon_num_interior_rings (
    const sfcgal_geometry_t * polygon
) 

Returns the number of interior rings of a given Polygon

Precondition:

polygon must be a Polygon


function sfcgal_polyhedral_surface_add_polygon

void sfcgal_polyhedral_surface_add_polygon (
    sfcgal_geometry_t * polyhedral,
    sfcgal_geometry_t * polygon
) 

Adds a Polygon to a given PolyhedralSurface

Precondition:

polyhedral must be a PolyhedralSurface

Precondition:

polygon must be a Polygon

Postcondition:

the ownership of the Polygon is taken. The caller is not responsible anymore of its deallocation


function sfcgal_polyhedral_surface_create

auto sfcgal_polyhedral_surface_create () 

Polyhedral surface


function sfcgal_polyhedral_surface_num_polygons

auto sfcgal_polyhedral_surface_num_polygons (
    const sfcgal_geometry_t * polyhedral
) 

Returns the number of polygons of a given PolyhedralSurface

Precondition:

polyhedral must be a PolyhedralSurface


function sfcgal_polyhedral_surface_polygon_n

auto sfcgal_polyhedral_surface_polygon_n (
    const sfcgal_geometry_t * polyhedral,
    size_t i
) 

Returns the ith polygon of a given PolyhedralSurface

Precondition:

polyhedral must be a PolyhedralSurface

Precondition:

i >= 0 and i < sfcgal_polyhedral_surface_num_polygons(polyhedral)

Postcondition:

the returned Polygon is not writable and must not be deallocated by the caller


function sfcgal_prepared_geometry_as_ewkt

void sfcgal_prepared_geometry_as_ewkt (
    const sfcgal_prepared_geometry_t * prepared,
    int num_decimals,
    char ** buffer,
    size_t * len
) 

Returns an EWKT representation of the given PreparedGeometry

Parameters:

  • num_decimals number of decimals. -2 for a variable number of decimals. -1 for an exact representation

Postcondition:

buffer is returned allocated and must be freed by the caller


function sfcgal_prepared_geometry_create

auto sfcgal_prepared_geometry_create () 

Creates an empty PreparedGeometry


function sfcgal_prepared_geometry_create_from_geometry

auto sfcgal_prepared_geometry_create_from_geometry (
    sfcgal_geometry_t * geometry,
    srid_t srid
) 

Creates a PreparedGeometry from a Geometry and an SRID


function sfcgal_prepared_geometry_delete

void sfcgal_prepared_geometry_delete (
    sfcgal_prepared_geometry_t * prepared
) 

Deletes a given PreparedGeometry

Precondition:

prepared must be a PreparedGeometry

Postcondition:

the underlying Geometry linked to the given PreparedGeometry is also deleted


function sfcgal_prepared_geometry_geometry

auto sfcgal_prepared_geometry_geometry (
    const sfcgal_prepared_geometry_t * prepared
) 

Returns the Geometry associated with a given PreparedGeometry

Precondition:

prepared must be a PreparedGeometry

Postcondition:

the returned Geometry is not writable and must not be deallocated by the caller


function sfcgal_prepared_geometry_set_geometry

void sfcgal_prepared_geometry_set_geometry (
    sfcgal_prepared_geometry_t * prepared,
    sfcgal_geometry_t * geometry
) 

Sets the Geometry associated with the given PreparedGeometry

Precondition:

prepared must be a PreparedGeometry

Postcondition:

the ownership of the given geometry is taken. The caller is not responsible anymore of its deallocation


function sfcgal_prepared_geometry_set_srid

void sfcgal_prepared_geometry_set_srid (
    sfcgal_prepared_geometry_t * prepared,
    srid_t srid
) 

Sets SRID associated with a given PreparedGeometry

Precondition:

prepared must be a PreparedGeometry


function sfcgal_prepared_geometry_srid

auto sfcgal_prepared_geometry_srid (
    const sfcgal_prepared_geometry_t * prepared
) 

Returns SRID associated with a given PreparedGeometry

Precondition:

prepared must be a PreparedGeometry


function sfcgal_set_alloc_handlers

void sfcgal_set_alloc_handlers (
    sfcgal_alloc_handler_t malloc_handler,
    sfcgal_free_handler_t free_handler
) 

Sets the error handlers. These callbacks are called on warning or error

Parameters:

  • malloc_handler is the function to call for memory allocation. The default behaviour is to call malloc()
  • free_handler is the function to call for memory deallocation. The default behaviour is to call free()

function sfcgal_set_error_handlers

void sfcgal_set_error_handlers (
    sfcgal_error_handler_t warning_handler,
    sfcgal_error_handler_t error_handler
) 

Sets the error handlers. These callbacks are called on warning or error

Parameters:

  • warning_handler is the printf-styled callback function that will be called when a function raises a warning. The default behaviour is to call printf.
  • error_handler is the printf-style callback function that will be called when a function generates an error. The default behaviour is to call printf.

function sfcgal_set_geometry_validation

void sfcgal_set_geometry_validation (
    int enabled
) 

Set the geometry validation mode

Note:

obsolete


function sfcgal_solid_add_interior_shell

void sfcgal_solid_add_interior_shell (
    sfcgal_geometry_t * solid,
    sfcgal_geometry_t * shell
) 

Adds a shell to a given Solid

Precondition:

solid must be a Solid

Precondition:

shell must be a PolyhedralSurface

Postcondition:

the ownership of the shell is taken. The caller is not responsible anymore of its deallocation


function sfcgal_solid_create

auto sfcgal_solid_create () 

Solid


function sfcgal_solid_create_from_exterior_shell

auto sfcgal_solid_create_from_exterior_shell (
    sfcgal_geometry_t * shell
) 

Creates a Solid from an exterior shell

Precondition:

ring must be a PolyhedralSurface

Postcondition:

the ownership of the given shell is taken. The caller is not responsible anymore of its deallocation


function sfcgal_solid_num_shells

auto sfcgal_solid_num_shells (
    const sfcgal_geometry_t * solid
) 

Returns the number of shells of a given Solid

Precondition:

solid must be a Solid


function sfcgal_solid_shell_n

auto sfcgal_solid_shell_n (
    const sfcgal_geometry_t * solid,
    size_t i
) 

Returns the ith shell of a given Solid

Precondition:

solid must be a Solid

Precondition:

i >= 0 and i < sfcgal_solid_num_shells( tin )

Postcondition:

the returned PolyhedralSurface is not writable and must not be deallocated by the caller


function sfcgal_triangle_create

auto sfcgal_triangle_create () 

Triangle


function sfcgal_triangle_create_from_points

auto sfcgal_triangle_create_from_points (
    const sfcgal_geometry_t * pta,
    const sfcgal_geometry_t * ptb,
    const sfcgal_geometry_t * ptc
) 

Creates a Triangle from three given Point

Precondition:

pta must be a Triangle

Precondition:

ptb must be a Triangle

Precondition:

ptc must be a Triangle

Postcondition:

the ownership of the three points are not taken. The caller is still responsible of their deallocation


function sfcgal_triangle_set_vertex

void sfcgal_triangle_set_vertex (
    sfcgal_geometry_t * triangle,
    int i,
    const sfcgal_geometry_t * vertex
) 

Sets one vertex of a Triangle

Precondition:

triangle must be a Triangle

Precondition:

vertex must be a Point

Postcondition:

returns a pointer to one of the vertices as a Point. This pointer is not writable and must not be deallocated by the caller


function sfcgal_triangle_set_vertex_from_xy

void sfcgal_triangle_set_vertex_from_xy (
    sfcgal_geometry_t * triangle,
    int i,
    double x,
    double y
) 

Sets one vertex of a Triangle from two coordinates

Precondition:

triangle must be a Triangle

Precondition:

i >= 0 and i < 3


function sfcgal_triangle_set_vertex_from_xyz

void sfcgal_triangle_set_vertex_from_xyz (
    sfcgal_geometry_t * triangle,
    int i,
    double x,
    double y,
    double z
) 

Sets one vertex of a Triangle from three coordinates

Precondition:

triangle must be a Triangle

Precondition:

i >= 0 and i < 3


function sfcgal_triangle_vertex

auto sfcgal_triangle_vertex (
    const sfcgal_geometry_t * triangle,
    int i
) 

Returns one the Triangle's vertex as a Point

Precondition:

triangle must be a Triangle

Precondition:

i >= 0 and i < 3

Postcondition:

returns a pointer to one of the vertices as a Point. This pointer is not writable and must not be deallocated by the caller


function sfcgal_triangulated_surface_add_triangle

void sfcgal_triangulated_surface_add_triangle (
    sfcgal_geometry_t * tin,
    sfcgal_geometry_t * triangle
) 

Adds a Triangle to a given TriangulatedSurface

Precondition:

tin must be a TriangulatedSurface

Precondition:

triangle must be a Triangle

Postcondition:

the ownership of the Triangle is taken. The caller is not responsible anymore of its deallocation


function sfcgal_triangulated_surface_create

auto sfcgal_triangulated_surface_create () 

Triangulated surface


function sfcgal_triangulated_surface_num_triangles

auto sfcgal_triangulated_surface_num_triangles (
    const sfcgal_geometry_t * tin
) 

Returns the number of triangles of a given TriangulatedSurface

Precondition:

tin must be a TriangulatedSurface


function sfcgal_triangulated_surface_triangle_n

auto sfcgal_triangulated_surface_triangle_n (
    const sfcgal_geometry_t * tin,
    size_t i
) 

Returns the ith Triangle of a given TriangulatedSurface

Precondition:

tin must be a TriangulatedSurface

Precondition:

i >= 0 and i < sfcgal_triangulated_surface_num_triangles( tin )

Postcondition:

the returned Triangle is not writable and must not be deallocated by the caller


function sfcgal_version

auto sfcgal_version () 

Get version


function sfcgal_y_monotone_partition_2

auto sfcgal_y_monotone_partition_2 (
    const sfcgal_geometry_t * geom
) 

Returns the y monotone partition of a geometry (polygon without hole)

Precondition:

isValid(geom) == true

Postcondition:

isValid(return) == true


Macro Definition Documentation

define SFCGAL_ERROR

#define SFCGAL_ERROR __sfcgal_error_handler

define SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR

#define SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR (
    call
) try {                                                                        \
    call                                                                       \
  } catch (std::exception & e) {                                               \
    SFCGAL_ERROR("%s", e.what());                                              \
    return 0;                                                                  \
  }

define SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR_NO_RET

#define SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR_NO_RET (
    call
) try {                                                                        \
    call                                                                       \
  } catch (std::exception & e) {                                               \
    SFCGAL_ERROR("%s", e.what());                                              \
  }

define SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION

#define SFCGAL_GEOMETRY_FUNCTION_BINARY_CONSTRUCTION (
    name,
    sfcgal_function
) extern "C" sfcgal_geometry_t *sfcgal_geometry_##name(                        \
      const sfcgal_geometry_t *ga, const sfcgal_geometry_t *gb)                \
  {                                                                            \
    std::unique_ptr< SFCGAL::Geometry > result;                                  \
    try {                                                                      \
      result = sfcgal_function(*(const SFCGAL::Geometry *)(ga),                \
                               *(const SFCGAL::Geometry *)(gb));               \
    } catch (std::exception & e) {                                             \
      SFCGAL_WARNING("During " #name "(A,B) :");                               \
      SFCGAL_WARNING("  with A: %s",                                           \
                     ((const SFCGAL::Geometry *)(ga))->asText().c_str());      \
      SFCGAL_WARNING("   and B: %s",                                           \
                     ((const SFCGAL::Geometry *)(gb))->asText().c_str());      \
      SFCGAL_ERROR("%s", e.what());                                            \
      return 0;                                                                \
    }                                                                          \
    return result.release();                                                   \
  }

define SFCGAL_GEOMETRY_FUNCTION_BINARY_MEASURE

#define SFCGAL_GEOMETRY_FUNCTION_BINARY_MEASURE (
    name,
    sfcgal_function
) SFCGAL_GEOMETRY_FUNCTION_BINARY_SCALAR(name, sfcgal_function, double,        \
                                         double, -1.0)

define SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE

#define SFCGAL_GEOMETRY_FUNCTION_BINARY_PREDICATE (
    name,
    sfcgal_function
) SFCGAL_GEOMETRY_FUNCTION_BINARY_SCALAR(name, sfcgal_function, int, bool, -1)

define SFCGAL_GEOMETRY_FUNCTION_BINARY_SCALAR

#define SFCGAL_GEOMETRY_FUNCTION_BINARY_SCALAR (
    name,
    sfcgal_function,
    ret_type,
    cpp_type,
    fail_value
) extern "C" ret_type sfcgal_geometry_##name(const sfcgal_geometry_t *ga,      \
                                             const sfcgal_geometry_t *gb)      \
  {                                                                            \
    cpp_type r;                                                                \
    try {                                                                      \
      r = sfcgal_function(*(const SFCGAL::Geometry *)(ga),                     \
                          *(const SFCGAL::Geometry *)(gb));                    \
    } catch (std::exception & e) {                                             \
      SFCGAL_WARNING("During " #name "(A,B) :");                               \
      SFCGAL_WARNING("  with A: %s",                                           \
                     ((const SFCGAL::Geometry *)(ga))->asText().c_str());      \
      SFCGAL_WARNING("   and B: %s",                                           \
                     ((const SFCGAL::Geometry *)(gb))->asText().c_str());      \
      SFCGAL_ERROR("%s", e.what());                                            \
      return fail_value;                                                       \
    }                                                                          \
    return r;                                                                  \
  }

define SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION

#define SFCGAL_GEOMETRY_FUNCTION_UNARY_CONSTRUCTION (
    name,
    sfcgal_function
) extern "C" sfcgal_geometry_t *sfcgal_geometry_##name(                        \
      const sfcgal_geometry_t *ga)                                             \
  {                                                                            \
    std::unique_ptr< SFCGAL::Geometry > result;                                  \
    try {                                                                      \
      result = sfcgal_function(*(const SFCGAL::Geometry *)(ga));               \
    } catch (std::exception & e) {                                             \
      SFCGAL_WARNING("During " #name "(A) :");                                 \
      SFCGAL_WARNING("  with A: %s",                                           \
                     ((const SFCGAL::Geometry *)(ga))->asText().c_str());      \
      SFCGAL_ERROR("%s", e.what());                                            \
      return 0;                                                                \
    }                                                                          \
    return result.release();                                                   \
  }

define SFCGAL_GEOMETRY_FUNCTION_UNARY_MEASURE

#define SFCGAL_GEOMETRY_FUNCTION_UNARY_MEASURE (
    name,
    sfcgal_function
) extern "C" double sfcgal_geometry_##name(const sfcgal_geometry_t *ga)        \
  {                                                                            \
    double r;                                                                  \
    try {                                                                      \
      r = sfcgal_function(*(const SFCGAL::Geometry *)(ga));                    \
    } catch (std::exception & e) {                                             \
      SFCGAL_WARNING("During " #name "(A) :");                                 \
      SFCGAL_WARNING("  with A: %s",                                           \
                     ((const SFCGAL::Geometry *)(ga))->asText().c_str());      \
      SFCGAL_ERROR("%s", e.what());                                            \
      return -1.0;                                                             \
    }                                                                          \
    return r;                                                                  \
  }

define SFCGAL_WARNING

#define SFCGAL_WARNING __sfcgal_warning_handler


The documentation for this class was generated from the following file /builds/sfcgal/SFCGAL/src/capi/sfcgal_c.cpp