This topic describes the uses and basic components of surface mesh models and provides a quick start guide.
Uses
Introduction
A surface mesh model is a common method in 3D solid modeling that uses a series of connected faces to describe the shape of a 3D solid. You can also set visualization elements for face information, such as materials and textures, to provide better visual effects in 3D visualization.
In Ganos, you can use standard SQL to query and process surface model data. Ganos supports data expression and exchange in text and binary formats.
Ganos Sfmesh is a spatiotemporal engine extension for PolarDB for PostgreSQL. It provides a set of data types, functions, and stored procedures to help you efficiently manage, query, and analyze 3D surface data.
Feature overview
Surface mesh models include multiple data types and support various methods, such as construction, access, editing, processing, aggregation, import, and export. They also support 3D spatial relationship determination, 3D analysis and calculation operations, and 3D indexes.
The Ganos Utility extension lets you import multiple 3D data formats for surface mesh models, such as Industry Foundation Classes (IFC), glTF, and Obj. It also supports converting surface mesh models into 3D tile formats, such as 3D Tiles.
For more information, see SfMesh SQL reference.
Main business scenarios
In practical applications, surface mesh types can be used for the visualization and analysis of spatial data:
3D map creation and visualization
Map visualization intuitively shows the distribution, trends, and relationships of data in a geographic space. This helps you better understand the meaning of spatial data and the patterns behind it. 3D spatial data can represent objects in 3D space, such as buildings and pipelines. When combined with visualization elements such as materials and textures, you can restore realistic 3D scenes for display and decision-making.
3D spatial relationship queries
Spatial relationship queries can be used in various scenarios, such as spatial data mining and urban planning. Using spatial relationship queries, you can quickly find spatial entities that meet specific conditions. This provides strong support for decision-making.
Surface mesh types support 3D spatial relationship queries, such as intersection and containment. These queries can be used to determine the relationship between two objects, for example, to determine whether two objects intersect.
3D spatial analysis and calculation
3D spatial analysis and calculation are used for various measurement scenarios, such as calculating the area or volume of a building.
Surface mesh types support various spatial analyses and calculations, such as calculating area, length, and distance. These calculations also include the intersection and union of two objects.
The following section uses a Building Information Modeling (BIM) scenario as an example to describe how to use surface mesh models.
BIM data
Building Information Modeling (BIM) is the process and result of digitally representing the physical and functional characteristics of a construction project or facility throughout its lifecycle. This representation is then used for design, construction, and operation.
BIM data contains a large amount of 3D spatial data and attribute data, which makes it suitable for unified storage, management, and querying in a database.
The Ganos Utility extension supports importing IFC data and converting it into the surface mesh data model.
Visualization
Unlike 2D drawings, the realism and intuitive expression of 3D models make the display of model information more aligned with human intuition. This provides a clearer understanding of a building's spatial relationships.
Using 3D visualization technology, you can generate scene models from BIM data stored as surface meshes for visual operations. This solves the problem of poor intuitiveness in BIM data, especially for large files.

Property queries
BIM data is often stored in files that use specialized formats. This is not conducive to unified management and joint querying with other 2D and 3D data. The data needs to be structurally decomposed to provide business and spatial query capabilities.
You can use the storage and query capabilities of a database to perform integrated property and spatial queries, which solves data management problems.
For example, you can use a standard SQL query to find parts of the 'System Panel' type:
SELECT project_uuid, project_name, parent_uuid, uuid, "family", "name", attrs, props_set
FROM ifc_demo_ifc_elem
WHERE
(((props_set->'Other')::json)->'Type')::text like '%System Panel: %'Spatial analysis
The dimensions in a BIM model are consistent with the actual building. You can use this information to calculate various metrics, such as floor area ratio and building coverage ratio. You can also perform various checks, such as for net floor height and area. In addition, you can check for collision relationships by linking with other spatial data, such as comparing the model with 2D and 3D planning red lines.

Basic components
Surface mesh model overview
In solid modeling and computer-aided design (CAD), a solid object is usually represented as a set of connected surface elements. These elements define the boundary between interior and exterior points.

These faces are usually composed of triangles (triangle meshes), quadrilaterals (quads), or other simple convex polygons (n-gons). They can accurately describe the contour boundary of a solid object.
A model that uses multiple faces to describe a solid object is called a surface mesh model.
Spatial reference systems
A Spatial Reference System (SRS) defines how to associate an Sfmesh object with a specific location on the Earth's surface.
Ganos uses a Spatial Reference Identifier (SRID) to reference an SRS definition. An Sfmesh object is associated with an SRS through its own SRID value.
For more information, see Spatial reference.
Surface mesh data models
The Ganos surface mesh model adds the following data models to the Open Geospatial Consortium (OGC) Simple Feature standard model:
INDEXSURFACE
IndexSurface describes polyhedron information using an indexed approach. For example, the following polyhedron can be described by a vertex coordinate string (p1, p2, p3, p4, p5) and faces defined by vertices (1,2,3), (2,4,3), and (4,5,3).

TRIANGLESTRIP
TriangleStrip describes a polyhedron using a continuous sequence of points. For example, the following polyhedron can be described by a vertex coordinate string (p1, p2, p3, p4, p5) to represent three triangular faces: (p1,p2,p3), (p2,p3,p4), and (p3,p4,p5).

TRIANGLEFAN
TriangleFan describes a polyhedron using a continuous sequence of points. For example, the following polyhedron can be described by a vertex coordinate string (p3, p1, p2, p4, p5) to represent three triangular faces: (p3,p1,p2), (p3,p2,p4), and (p3,p4,p5).

Surface mesh data types
The Ganos surface model includes the following data types:
sfmesh: A collection of data types that includes information about geometry, materials, textures, and texture coordinates.
meshgeom: A geometric object used to record coordinate point information, face construction methods, and corresponding texture coordinates and normal vectors.
texture: Texture map information, including width, height, compression method, and binary texture data.
material: A collection of visual properties for the surface of an sfmesh object. This includes color, texture, smoothness, transparency, reflectivity, refractivity, and luminosity.
The Ganos surface model supports reference objects. A reference object is a special data structure that stores only the address information of another object instead of its actual data values.
Surface mesh exchange formats
The surface mesh exchange format supports both text and binary formats.
A human-readable text format: Well-Known Text (WKT). For more information, see WKT.
A binary format that preserves data precision and is easy to transmit: Well-Known Binary (WKB). For more information, see WKB.
Data column view
In Ganos, `sfmesh_columns` is a view that reads all surface mesh-related columns from the database system catalog tables. This view follows the OGC Simple Features Specification for SQL standard and includes corresponding extensions.
The view has the following structure:
Column name | Type | Description |
g_table_catalog | varchar(256) | The name of the database. |
g_table_schema | name | The schema that contains the table. |
g_table_name | name | The name of the table. |
g_sfmesh_column | name | The name of a surface mesh column in the table. |
g_sfmesh_type | name | The specific subtype of the surface mesh column. Valid values:
|
You can query all surface model data columns in the current database with the following statement:
SELECT * FROM sfmesh_columns;Alternatively, you can use the following statement to filter for model columns.
SELECT * FROM sfmesh_columns
WHERE g_sfmesh_type = 'sfmesh';Indexes
Spatial indexes allow Ganos to avoid full sequential scans of the database when processing large spatial datasets. Indexes speed up searches by organizing data into a search tree that can be quickly traversed to find specific records.
Ganos provides a 3D spatial index for Sfmesh based on the Generalized Search Tree (GiST).
You can create it in the following ways.
CREATE INDEX <index_name>
ON <table_name>
USING GIST(<column_name>);Quick start
Introduction
This quick start guide helps you quickly understand the basic usage of the Ganos Sfmesh engine. It covers creating the extension, creating tables, inserting data, querying results, creating indexes, and performing spatial queries.
For more advanced usage, see the following SfMesh best practice articles:
Ganos 3D Engine Series (3): Analysis of BIM Data Management and Visualization Features
Ganos 3D Engine Series (4): Road Network and Terrain Conforming
Syntax
Create the extension.
CREATE EXTENSION Ganos_sfmesh CASCADE;NoteInstall the extension in the public schema to avoid permission issues.
CREATE extension Ganos_sfmesh WITH schema public cascade CASCADE;Create a table with an SFMesh field.
CREATE TABLE t_mesh( id integer, mesh sfmesh );Insert data.
-- Insert data into the table INSERT INTO t_mesh(id, mesh) VALUES (1, '{ "version" : 1, "srid" : 4326, "root" : 0 , "meshgeoms" : [ "MESHGEOM(PATCH(TRIANGLESTRIP(0 0 0 ,0 10 10,10 10 10,10 0 0)))" ], "primitives" : [ {"meshgeom": 0}], "nodes" : [ {"primitive" : 0} ] }'::sfmesh), (2, '{ "version" : 1, "srid" : 4326, "root" : 0 , "meshgeoms" : [ "MESHGEOM(PATCH(INDEXSURFACE(VERTEX(0 0 1,0 10 2,10 10 3,10 0 4), INDEX((0,1,2),(1,2,3)))))" ], "primitives" : [ {"meshgeom": 0}], "nodes" : [ {"primitive" : 0} ] }'::sfmesh);Query the data.
SELECT id, ST_AsText(mesh) FROM t_mesh; ------------------------- 1 | {"version" : 1, "srid" : 4326, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(TRIANGLESTRIP(0 0 0,0 10 10,10 10 10,10 0 0)))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]} 2 | {"version" : 1, "srid" : 4326, "root" : 0, "meshgeoms" : ["MESHGEOM(PATCH(INDEXSURFACE Z (VERTEX(0 0 1,0 10 2,10 10 3,10 0 4),INDEX((0,1,2),(1,2,3)))))"], "primitives" : [{"meshgeom" : 0}], "nodes" : [{"primitive" : 0}]}Create an index.
CREATE INDEX idx_t_mesh ON t_mesh USING GIST(mesh);Perform a spatial query.
-- Intersect with a 3D spatial object SELECT id FROM t_mesh WHERE ST_3DIntersects(mesh, ST_SetSRID('BOX3D(0 0 0, 10 10 10)'::box3d::sfmesh, 4326));Delete the extension (optional).
DROP EXTENSION Ganos_SFMesh CASCADE;
SQL reference
For the detailed SQL reference, see SfMesh SQL reference.