Oakfield API Documentation 1.0.0
Numerical core APIs
Loading...
Searching...
No Matches
field_patch.h
Go to the documentation of this file.
1
10#ifndef OAKFIELD_FIELD_PATCH_H
11#define OAKFIELD_FIELD_PATCH_H
12
13#include "sim_buffer.h"
14
15#include <stdbool.h>
16#include <stddef.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22enum {
27};
28
32typedef struct SimFieldPatch {
33 size_t x0;
34 size_t y0;
35 size_t width;
36 size_t height;
37 size_t field_width;
38 size_t field_height;
39 unsigned int flags;
41
57
67typedef SimResult (*SimFieldPatchRowIterFn)(size_t row_index, void *row_data, size_t row_length,
68 void *userdata);
69
77
86SimResult sim_field_patch_full(size_t field_width, size_t field_height, SimFieldPatch *out_patch);
87
100SimResult sim_field_patch_from_xywh(size_t field_width, size_t field_height, size_t x0, size_t y0,
101 size_t width, size_t height, SimFieldPatch *out_patch);
102
112 SimFieldPatch *out_patch);
113
129SimResult sim_field_patch_from_normalized_region(size_t field_width, size_t field_height,
130 double min_x, double min_y, double max_x,
131 double max_y, SimFieldPatch *out_patch);
132
140
156 bool readonly, SimFieldPatchView *out_view);
157
167 void *userdata);
168
182size_t sim_field_patch_split_tiles(const SimFieldPatch *patch, size_t tile_width,
183 size_t tile_height, SimFieldPatch *out_tiles,
184 size_t out_capacity);
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif /* OAKFIELD_FIELD_PATCH_H */
SimResult
Return codes shared by libsimcore modules.
Definition field.h:29
SimResult sim_field_patch_iter_rows(const SimFieldPatchView *view, SimFieldPatchRowIterFn row_fn, void *userdata)
Iterate physical rows in a patch view.
SimResult sim_field_patch_from_xywh(size_t field_width, size_t field_height, size_t x0, size_t y0, size_t width, size_t height, SimFieldPatch *out_patch)
Construct a patch from x/y origin and width/height extents.
@ SIM_FIELD_PATCH_FLAG_TOUCHES_BOUNDARY
Definition field_patch.h:26
@ SIM_FIELD_PATCH_FLAG_NONE
Definition field_patch.h:23
@ SIM_FIELD_PATCH_FLAG_IS_FULL_FIELD
Definition field_patch.h:25
@ SIM_FIELD_PATCH_FLAG_COVERS_FULL_ROWS
Definition field_patch.h:24
bool sim_field_patch_view_is_valid(const SimFieldPatchView *view)
Validate a patch view and its backing buffer-view layout.
SimResult(* SimFieldPatchRowIterFn)(size_t row_index, void *row_data, size_t row_length, void *userdata)
Row callback used by sim_field_patch_iter_rows().
Definition field_patch.h:67
size_t sim_field_patch_split_tiles(const SimFieldPatch *patch, size_t tile_width, size_t tile_height, SimFieldPatch *out_tiles, size_t out_capacity)
Split a patch into row-major tiles.
bool sim_field_patch_is_valid(const SimFieldPatch *patch)
Validate patch bounds, dimensions, and source-field extents.
SimResult sim_field_patch_full(size_t field_width, size_t field_height, SimFieldPatch *out_patch)
Construct a patch covering a complete field.
SimResult sim_field_patch_from_normalized_region(size_t field_width, size_t field_height, double min_x, double min_y, double max_x, double max_y, SimFieldPatch *out_patch)
Construct a patch from normalized [0, 1] coordinate bounds.
bool sim_field_patch_intersect(const SimFieldPatch *lhs, const SimFieldPatch *rhs, SimFieldPatch *out_patch)
Intersect two patches from the same field.
SimResult sim_field_patch_view_from_field(SimField *field, const SimFieldPatch *patch, bool readonly, SimFieldPatchView *out_view)
Create a zero-copy view over a patch of a row-major field.
Shared standalone buffer and buffer-view types.
Non-owning typed view over contiguous, strided, or indexed scalar storage.
Definition sim_buffer.h:41
Zero-copy view over a field patch.
Definition field_patch.h:48
SimFieldPatch patch
Definition field_patch.h:50
size_t shape_storage[2]
Definition field_patch.h:54
bool readonly
Definition field_patch.h:52
size_t stride_storage[2]
Definition field_patch.h:55
size_t row_stride
Definition field_patch.h:51
SimBufferView buffer_view
Definition field_patch.h:49
bool zero_copy
Definition field_patch.h:53
Rectangular non-empty region of a 2D field index space.
Definition field_patch.h:32
unsigned int flags
Definition field_patch.h:39
size_t width
Definition field_patch.h:35
size_t height
Definition field_patch.h:36
size_t field_height
Definition field_patch.h:38
size_t x0
Definition field_patch.h:33
size_t field_width
Definition field_patch.h:37
size_t y0
Definition field_patch.h:34
Owning multidimensional field.
Definition field.h:157