From 56b2ab072e099283d256c8346ae67f4dae77e260 Mon Sep 17 00:00:00 2001 From: "bozo.kopic" Date: Tue, 21 Dec 2021 02:50:05 +0100 Subject: WIP c implementation --- src_c/common.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src_c/common.h (limited to 'src_c/common.h') diff --git a/src_c/common.h b/src_c/common.h new file mode 100644 index 0000000..e8eb9d1 --- /dev/null +++ b/src_c/common.h @@ -0,0 +1,77 @@ +#ifndef OPCUT_COMMON_H +#define OPCUT_COMMON_H + + +#import +#import + +#define OPCUT_SUCCESS 0 +#define OPCUT_ERROR -1 +#define OPCUT_UNSOLVABLE 1 + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char *data; + size_t len; +} opcut_str_t; + +typedef struct { + opcut_str_t id; + double width; + double height; +} opcut_panel_t; + +typedef struct { + opcut_str_t id; + double width; + double height; + bool can_rotate; +} opcut_item_t; + +typedef struct { + double cut_width; + bool min_initial_usage; + opcut_panel_t *panels; + size_t panels_len; + opcut_item_t *items; + size_t items_len; +} opcut_params_t; + +typedef struct { + opcut_panel_t *panel; + opcut_item_t *item; + double x; + double y; + bool rotate; +} opcut_used_t; + +typedef struct { + opcut_panel_t *panel; + double width; + double height; + double x; + double y; +} opcut_unused_t; + +typedef struct { + opcut_params_t *params; + opcut_used_t *used; + size_t used_len; + opcut_unused_t *unused; + size_t unused_len; +} opcut_result_t; + + +int opcut_params_init(opcut_params_t *params, opcut_str_t *json); +void opcut_params_destroy(opcut_params_t *params); +int opcut_result_write(opcut_result_t *result, FILE *stream); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3-70-g09d2