All Products
Search
Document Center

PolarDB:ST_3DRemoveDuplicateVertex

Last Updated:Mar 28, 2026

Welds vertices of an sfmesh or IndexSurface object where the spatial distance and texture coordinate difference between vertex pairs are both within the specified threshold, then removes the duplicate vertices.

Syntax

sfmesh ST_3DRemoveDuplicateVertex(sfmesh sfmesh, float8 dist_threshold);

Parameters

ParameterDescription
sfmeshThe sfmesh model object.
dist_thresholdThe distance threshold. Vertices within this distance of each other are welded into a single vertex. Distance is measured in the Cartesian coordinate system. Both the spatial distance and the texture coordinate difference must fall within this threshold for welding to occur.

Return value

Returns the welded sfmesh object.

How it works

The function evaluates each pair of vertices in the sfmesh or IndexSurface object against dist_threshold. A vertex pair is merged when both conditions are met:

  • The Cartesian spatial distance between the two vertices is within dist_threshold.

  • The texture coordinate difference between the two vertices is within dist_threshold.

When both conditions are satisfied, the two vertices are welded into one, reducing the total vertex count and the resulting object size.

Effect of dist_threshold on output size

The following sketch maps show how dist_threshold affects output size and geometric detail. A higher threshold merges more vertices and reduces file size, but may cause loss of geometric detail.

  • Raw data (50.2 MB)

image.png
  • Vertex-welded results (20.2 MB): dist_threshold = 0.01

image.png
  • Vertex-welded results (3.3 MB): dist_threshold = 0.1

image.png
  • Vertex-welded results (0.63 MB): dist_threshold = 1 (some details lost)

image.png

Examples

Example: Remove vertices that are close in both spatial position and texture coordinate

The input contains six vertices, some of which are within 0.1 units of each other. After welding, duplicate vertices are merged and the output contains only four distinct vertices.

SELECT ST_AsText(ST_3DRemoveDuplicateVertex('MESHGEOM(PATCH(INDEXSURFACE(VERTEX(0 0 0, 1 0 0, 0 1 0, 1 0.01 0, 0.01 0 0, 0 -1 0), INDEX((0,1,2),(3,4,5)))))'::meshgeom, 0.1));

Expected output:

{"version" : 1, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 0,1 0 0,0 1 0,0 -1 0),INDEX((0,1,2),(1,0,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]}