All Products
Search
Document Center

PolarDB:ST_SnapToPolygon

Last Updated:Mar 28, 2026

Smoothly fits the vertices of an sfmesh object to a 3D polygon along the Z direction.

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 specified 3D polygon.

Parameters

ParameterTypeDescription
sfmeshsfmeshThe sfmesh model object.
geomgeometryThe 3D polygon to fit vertices to.
zlowdf8The lower distance limit in the Z direction. Only vertices within the range defined by zlowd and zupd are fit.
zupdf8The upper distance limit in the Z direction. Only vertices within the range defined by zlowd and zupd are fit.
bufferf8The buffer distance that defines the smooth transition range around the polygon boundary.
timesi4The number of smooth fitting iterations. Higher values produce better results. Set this value between 5 and 20.

Example

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));

Output:

BOX3D(-1 -1 0,1 1 0.782785594463348)