All Products
Search
Document Center

PolarDB:ST_3DDifference

Last Updated:Mar 28, 2026

Returns the part of an sfmesh object that is not part of a box3d or meshgeom object.

Syntax

sfmesh ST_3DDifference(sfmesh sfmeshObject, box3d box);
sfmesh ST_3DDifference(sfmesh sfmeshObject, meshgeom geom);

Parameters

ParameterDescription
sfmeshObjectThe sfmesh object.
boxThe box3d object.
geomThe closed meshgeom object.

Description

The UV and Normal values of the returned sfmesh object are synchronously updated to reflect the difference result.

The function behaves differently depending on the second argument:

  • sfmesh vs. box3d: Aligns the axes before computing and returns the difference.

  • sfmesh vs. meshgeom: Computes and returns the difference directly.

Example

SELECT ST_NumPatches(ST_3DDifference(ST_3DMakeSphere(1.0, 5), 'BOX3D(0 0 0, 0.2 0.2 0.2)'::box3d));
-----------------
         20480

This example subtracts a small box from a sphere created by ST_3DMakeSphere and counts the resulting patches with ST_NumPatches.

See also

  • ST_3DMakeSphere: Creates a sphere as an sfmesh object

  • ST_NumPatches: Returns the number of faces in a polyhedral surface