|
|
The mesh generator used by BASEmesh requires its input data to adhere to much stricter rules than other GIS applications. This means that GIS geometries that are valid for most other contexts may still produce undesirable results or fail to mesh entirely when used for mesh generation.
|
|
|
|
|
|
BASEmesh includes a custom builder interface for its input geometry allowing users to process GIS datasets for use in mesh generation.
|
|
|
|
|
|
In the QGIS plugin, this geometry cleanup is enabled by default, but may be disabled through the *'Disable input cleaning'* checkbox. Additionally, the *'Snapping tolerance'* GUI value will be used for any non-exact operations.
|
|
|
|
|
|
In the BASEmesh API, this is handled by the `basemesh.PSLGBuilder` class. Refer to the Python API for documentation on its API and usage.
|
|
|
|
|
|
## Triangle
|
|
|
|
|
|
The mesh generator Triangle will always merge vertices whose X and Y coordinates match exactly, as well as duplicate segments connecting the same input vertices (regardless of order).
|
|
|
|
|
|
This is always enabled but will emit warnings in the Triangle output if encountered.
|
|
|
|
|
|
## Cleanup Operations
|
|
|
|
|
|
This section lists the cleanup steps performed by BASEmesh and provides a brief description for each. Note that these act in addition to the ones built into Triangle.
|
|
|
|
|
|
### `merge_vertices`
|
|
|
|
|
|
*Uses snapping tolerance*
|
|
|
|
|
|
Merges any vertices whose distance is less than the specified tolerance. If enabled, this prevents any Triangle warnings related to duplicate vertices.
|
|
|
|
|
|
### `merge_coincident_segments`
|
|
|
|
|
|
Deletes any duplicate segments describing the same connection of vertices as a previous one. If enabled, prevents any Triangle warnings related to duplicate segments.
|
|
|
|
|
|
### `insert_intersection_vertices`
|
|
|
|
|
|
*Uses snapping tolerance*
|
|
|
|
|
|
Find any segment intersections (not counting endpoints) and insert new vertices at the intersection points. This does not alter the original segments, run `split_segments` afterwards to remove the intersections.
|
|
|
|
|
|
### `split_segments`
|
|
|
|
|
|
*Uses snapping tolerance*
|
|
|
|
|
|
For any segment bisected by a vertex, delete the original segment and insert a new one either side of the bisecting vertex.
|
|
|
|
|
|
This step is important for Triangle as nodes bisecting vertices results in fatal errors while meshing.
|
|
|
|
|
|
### `remove_singular_segments`
|
|
|
|
|
|
Removes any segments whose length is zero. This may occur as a result of two distinct input vertices being merged together, which would leave the segment connected to the same vertex twice.
|
|
|
|
|
|
## QGIS Plugin Cleanup Strategy
|
|
|
|
|
|
As of writing, the BASEmesh plugin uses the following cleanup process:
|
|
|
|
|
|
```py
|
|
|
builder = PSLGBuilder()
|
|
|
builder.add_vertices(...) # Omitted for brevity
|
|
|
builder.add_segments(...) # Omitted for brevity
|
|
|
|
|
|
builder.merge_vertices(snapping_tolerance)
|
|
|
builder.merge_coincident_segments()
|
|
|
builder.insert_intersection_vertices(snapping_tolerance)
|
|
|
builder.split_segments(snapping_tolerance)
|
|
|
builder.merge_vertices(snapping_tolerance)
|
|
|
builder.remove_singular_segments()
|
|
|
```
|
|
|
|
|
|
The second call to `merge_vertices()` is required as `split_segments` may have introduced new vertices that fall within the snapping tolerance of existing ones. |