Converts a meshgeom geometry object into a triangulated representation optimized for rendering.
Syntax
meshgeom ST_Triangulate(meshgeom geom);Parameters
| Parameter | Description |
|---|---|
geom | The meshgeom object to triangulate. |
Description
ST_Triangulate decomposes polygon patches in a meshgeom object into indexed triangle surfaces (INDEXSURFACE), where each face is represented as a set of vertex indices (INDEX). The returned triangulated geometry object is used to render models.
The function accepts both polygon-based patches (PATCH(POLYGON(...))) and pre-indexed surface patches (PATCH(INDEXSURFACE(...))), and produces the same INDEXSURFACE Z output in both cases.
Examples
Triangulate a polygon patch
Input is a PATCH containing a POLYGON. ST_Triangulate splits the polygon into two triangles and returns an indexed surface.
SELECT ST_asText(ST_Triangulate('MESHGEOM(PATCH(POLYGON((0 0 0, 1 0 0, 1 1 0, 0 1 0, 0 0 0))))'));Output:
MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 0,1 0 0,1 1 0,0 1 0),INDEX((2,3,0),(0,1,2)))))Triangulate an indexed surface patch
Input is already an INDEXSURFACE with a single quad index. ST_Triangulate re-triangulates it, producing the same output as the polygon input above.
SELECT ST_asText(ST_Triangulate('MESHGEOM(PATCH(INDEXSURFACE( VERTEX(0 0 0,1 0 0,1 1 0,0 1 0),INDEX((0,1,2,3)) )))'));Output:
MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 0,1 0 0,1 1 0,0 1 0),INDEX((2,3,0),(0,1,2)))))What's next
ST_asText— convert ameshgeomobject to its well-known text (WKT) representationOther Ganos geometry functions for building, transforming, and exporting
meshgeomobjects