Preparing source geometry#
Surveyed or digitised outlines often carry far more vertices than a mesh needs.
meshkit.prepare_sources() removes vertices within per-feature tolerances,
audits the result independently, and returns buffers that
meshkit.prepared_request() turns into a job request without building
Python rows per vertex.
prepared = meshkit.prepare_sources([
{"id": "domain", "role": "outer", "xy": outline,
"policy": {"mode": "simplify", "maximum_deviation": 0.5}},
{"id": "levee", "role": "line", "xy": levee_xy, "z": levee_z,
"policy": {"mode": "simplify", "maximum_deviation": 0.2,
"maximum_z_deviation": 0.05}},
])
if not prepared["ok"]:
raise RuntimeError(prepared["error"])
request = meshkit.prepared_request(prepared, options={"maximum_size": 10.})
result = meshkit.run(request)
Coordinates never move: simplification only removes vertices, and every shortcut is checked against the whole stretch it replaces, in XY and Z. A stretch shared by several features is simplified once, under the strictest of their policies. Crossing features are not split; node them before meshing.
Features#
Key |
Default |
Meaning |
|---|---|---|
|
— |
Required. Vertices as rows |
|
|
Source identifier, returned as |
|
none |
Heights, one per vertex. Features that share a point must give it the
same height (otherwise |
|
none |
One flag per vertex; flagged vertices are never removed. |
|
|
|
|
|
Close a line into a ring (implied for |
|
|
Integer carried to the path. |
|
preserve |
Simplification policy, below. |
Policy#
The default mode, "preserve", keeps every vertex; the limits apply with
"mode": "simplify".
Key |
Default |
Meaning |
|---|---|---|
|
|
|
|
|
Largest XY distance between a shortcut and the vertices it removes. |
|
|
Largest height difference, in Z units; 0 keeps heights exact. |
|
|
Largest direction change at a removed vertex. |
|
|
Largest change of a ring’s area, relative to it; -1 disables. |
|
|
Largest absolute area change, in squared XY units; -1 disables. |
|
|
Smallest distance a shortcut keeps from other geometry. |
The second argument takes protected_points (points no shortcut may pass
over), max_work (0 allows 256 operations per input vertex plus 100,000)
and max_workspace_bytes (default 1 GiB). Running out of work keeps the
original features.
Result#
prepared["ok"] is false with an error text when simplification or its
audit fails. Otherwise:
points(float64(N, 2)) andpoint_elevations(float64(N,), NaN where nozwas given) hold every distinct retained vertex once;featureshas one row per input feature:id(one-based path ID),source_id,kind,closed,marker,vertices(indexes intopoints),source_vertices(for each retained vertex, its index in the input feature; empty when the feature is unchanged) andremoved(vertices removed);shared_chainscounts stretches shared by several features.