ST_Extrude

更新时间:
复制 MD 格式

Extrudes a 2D polygon into a 3D mesh geometry along the positive z-axis direction.

Syntax

meshgeom ST_Extrude(geometry geom2d, float8 height);

Parameters

ParameterTypeDescription
geom2dgeometryThe input geometry. Accepts Polygon and MultiPolygon types.
heightfloat8The extrusion height along the positive z-axis.

Description

ST_Extrude takes a flat 2D polygon and generates a 3D mesh geometry (meshgeom) by extruding it upward along the positive z-axis by the specified height.

The input geometry must be a Polygon or MultiPolygon. The output is a meshgeom object composed of top and bottom polygon faces and lateral triangle strips connecting them.

Effect diagram

A 2D polygon is extruded along the z-axis. Effect diagram

Examples

Extrude a triangle polygon by a height of 1:

SELECT ST_AsText(ST_Extrude('POLYGON((0 0, 1 0, 1 1, 0 0))', 1));

Output:

MESHGEOM(PATCH(POLYGON Z ((0 0 1,1 0 1,1 1 1,0 0 1)),TRIANGLESTRIP Z (0 0 1,0 0 0,1 0 1,1 0 0,1 1 1,1 1 0,0 0 1,0 0 0),POLYGON Z ((0 0 0,1 1 0,1 0 0,0 0 0))))

The output meshgeom contains:

  • A top face (POLYGON Z) at z = height

  • A bottom face (POLYGON Z) at z = 0

  • Lateral faces represented as a TRIANGLESTRIP Z connecting the top and bottom edges