HeightMap: add threshold operations that return new HeightMaps (closes #197)

Add three methods that create NEW HeightMap objects:
- threshold(range): preserve original values where in range, 0.0 elsewhere
- threshold_binary(range, value=1.0): set uniform value where in range
- inverse(): return (1.0 - value) for each cell

These operations are immutable - they preserve the original HeightMap.
Useful for masking operations with Grid.apply_threshold/apply_ranges.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-01-11 21:49:28 -05:00
commit d92d5f0274
3 changed files with 463 additions and 0 deletions

View file

@ -40,6 +40,11 @@ public:
static PyObject* min_max(PyHeightMapObject* self, PyObject* Py_UNUSED(args));
static PyObject* count_in_range(PyHeightMapObject* self, PyObject* args);
// Threshold operations (#197) - return NEW HeightMaps
static PyObject* threshold(PyHeightMapObject* self, PyObject* args);
static PyObject* threshold_binary(PyHeightMapObject* self, PyObject* args, PyObject* kwds);
static PyObject* inverse(PyHeightMapObject* self, PyObject* Py_UNUSED(args));
// Subscript support for hmap[x, y] syntax
static PyObject* subscript(PyHeightMapObject* self, PyObject* key);