Welds vertices of an sfmesh or IndexSurface object whose coordinate distance and texture coordinate difference both fall within the specified threshold, and returns the resulting sfmesh object with duplicate vertices removed.
Syntax
sfmesh ST_3DRemoveDuplicateVertex(sfmesh sfmesh, float8 dist_threshold);Parameters
| Parameter | Type | Description |
|---|---|---|
sfmesh | sfmesh | The sfmesh model object. |
dist_threshold | float8 | The distance threshold. Vertices whose coordinate distance and texture coordinate difference both fall within this threshold are welded together. Distance is calculated using the Cartesian coordinate system. |
Return value
Returns the welded sfmesh object.
How it works
ST_3DRemoveDuplicateVertex scans the vertices of an sfmesh or IndexSurface object and merges any two vertices into one when both of the following conditions are met:
Their coordinate distance (in the Cartesian coordinate system) is within
dist_threshold.Their texture coordinate difference is within
dist_threshold.
A smaller dist_threshold welds fewer vertices and preserves more geometric detail. A larger value welds more aggressively, reducing file size but potentially losing fine details.
Examples
The following example welds vertices in an IndexSurface object using a distance threshold of 0.1. The input contains six vertices; after welding, two duplicate-or-near-duplicate vertices are merged, leaving 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
)
);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}]}Effect of dist_threshold on mesh size
The following diagrams show how different threshold values affect the output size of the same mesh.
Raw data (50.2 MB)

Vertex-welded results (20.2 MB): dist_threshold = 0.01

Vertex-welded results (3.3 MB): dist_threshold = 0.1

Vertex-welded results (0.63MB): dist_threshold = 1 (some details lost)
