Smoothly fits terrain mesh (sfmesh) vertices to a 3D polygon along the Z axis.
Syntax
sfmesh ST_SnapToPolygon(sfmesh sfmesh, geometry geom, f8 zlowd, f8 zupd, f8 buffer, i4 times);Return value
Returns the sfmesh object with its vertices smoothly fit to the target polygon.
Parameters
| Parameter | Type | Description |
|---|---|---|
sfmesh | sfmesh | The sfmesh model object whose vertices are fit to the polygon. |
geom | geometry | The target 3D polygon. |
zlowd | f8 | The lower Z distance limit. Only vertices within the Z range defined by zlowd and zupd are fit. |
zupd | f8 | The upper Z distance limit. Only vertices within the Z range defined by zlowd and zupd are fit. |
buffer | f8 | The buffer used for smooth fitting. |
times | i4 | The number of fitting iterations. More iterations produce a smoother result. Set a value between 5 and 20. |
Usage notes
zlowdandzupdspecify the vertices to be smoothly fit.buffersets the smooth transition range.timesdefines the number of smooth fitting actions. A higher number of smooth fitting actions brings a better fitting result.
Example
The following example intersects a sphere with a bounding box to produce an sfmesh, then snaps its vertices to a thin polygon strip along the Y axis with times set to 10.
SELECT BOX3D(ST_SnapToPolygon(
ST_3DIntersection(ST_3DMakeSphere(1.0, 4), 'BOX3D(-1 -1 0, 1 1 1)'::box3d),
'POLYGON((-5 -0.1 0.5, 5 -0.1 0.5, 5 0.1 0.5, -5 0.1 0.5, -5 -0.1 0.5))', 0.5, 0.5, 0.5, 10));Result:
BOX3D(-1 -1 0,1 1 0.782785594463348)