Rust low-level FFI bindings to SFCGAL
1.5.x C API.
Don't use this crate directly, prefer it's higher-level wrapper : sfcgal-rs.
Important
Note that the required version of SFCGAL is currently 1.5.x (latest version - 2023-10-30).
If you want to use SFCCAL 1.4.x, you can use the 0.6.x version of this crate / of sfcgal-rs.
This crate contains a few lines of C code (compiled as a static library with cc
crate) wrapping SFCGAL C API in order to replace the error and warning handlers (which use printf
by default).
It expects SFCGAL to be installed as a system library and that you have the header file for it's C API.
Then bindgen is run to generate these low-levels bindings.
In addition to all the sfcgal_
types and functions, this crate expose :
- a Rust
initialize
function: it callssfcgal_init()
function then it calls a customw_sfcgal_init_handlers()
function which replace the error and warning handlers fromprintf
to a char buffer. Thatinitialize
function internally usesstd::sync::Once
to ensure it's only called once. - two C functions
w_sfcgal_get_last_error
andw_sfcgal_get_last_warning
which repectively reads the buffer containing the error message and the buffer containing the warning message.
In the future it could probably be improved by not requiring SFCGAL to be installed as a system library.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.