QGIS API Documentation 4.5.0-Master (3b5d115045b)
Loading...
Searching...
No Matches
QgsTessellator Class Reference

Tessellates polygons into triangles. More...

#include <qgstessellator.h>

Public Member Functions

 QgsTessellator ()
Q_DECL_DEPRECATED QgsTessellator (const QgsRectangle &bounds, bool addNormals, bool invertNormals=false, bool addBackFaces=false, bool noZ=false, bool addTextureCoords=false, int facade=3, float textureRotation=0.0f)
 Creates tessellator with a specified bounds of input geometry coordinates.
Q_DECL_DEPRECATED QgsTessellator (double originX, double originY, bool addNormals, bool invertNormals=false, bool addBackFaces=false, bool noZ=false, bool addTextureCoords=false, int facade=3, float textureRotation=0.0f)
 Creates tessellator with a specified origin point of the world (in map coordinates).
void addGeometry (const QgsAbstractGeometry &geometry, float extrusionHeight=0)
 Tessellates a surface geometry and adds its vertex entries to the output data array.
void addPolygon (const QgsPolygon &polygon, float extrusionHeight)
 Tessellates a triangle and adds its vertex entries to the output data array.
std::unique_ptr< QgsMultiPolygon > asMultiPolygon () const
 Returns the triangulation as a multipolygon geometry.
Q_DECL_DEPRECATED QVector< float > data () const
 Returns array of triangle vertex data.
int dataVerticesCount () const
 Returns the number of vertices stored in the output data array.
QString error () const
 Returns a descriptive error string if the tessellation failed.
Qgis::ExtrusionFaces extrusionFaces () const
 Returns which faces are generated during extrusion.
bool hasBackFacesEnabled () const
 Returns true if back faces are being added to the output data.
bool hasInvertedNormals () const
 Returns true if normals are inverted.
bool hasNormals () const
 Returns true if normals are being added to the output data.
bool hasTangents () const
 Returns true if tangents are being added to the output data.
bool hasTextureUVs () const
 Returns true if texture UV coordinates are being added to the output data.
QByteArray indexBuffer () const
 Returns index buffer for the generated points.
int indexStride () const
 Returns size of one index entry in bytes.
Q_DECL_DEPRECATED bool isOutputZUp () const
 Returns whether the "up" direction should be the Z axis on output (true), otherwise the "up" direction will be the Y axis (false).
bool isZValueIgnored () const
 Returns whether Z values from the input geometries are ignored (true) or not (false).
QgsVector3D origin () const
 Returns the origin point of the map.
void setAddNormals (bool addNormals)
 Sets whether normals should be added to the output data.
void setAddTangents (bool addTangents)
 Sets whether tangents should be added to the output data.
void setAddTextureUVs (bool addTextureUVs)
 Sets whether texture UV coordinates should be added to the output data.
void setBackFacesEnabled (bool addBackFaces)
 Sets whether back faces should be added to the output data.
void setBounds (const QgsRectangle &bounds)
 Sets scaling and the bounds of the input geometry coordinates.
void setExtrusionFaces (Qgis::ExtrusionFaces faces)
 Sets which faces should be generated during extrusion.
void setInputZValueIgnored (bool ignore)
 Sets whether Z values from the input geometries are ignored (true) or not (false).
void setInvertNormals (bool invertNormals)
 Sets whether normals should be inverted.
void setOrigin (const QgsVector3D &origin)
 Sets the origin point of the map.
Q_DECL_DEPRECATED void setOutputZUp (bool zUp)
 Sets whether the "up" direction should be the Z axis on output (true), otherwise the "up" direction will be the Y axis (false).
Q_DECL_DEPRECATED void setTextureRotation (float rotation)
 Sets the rotation of texture UV coordinates (in degrees).
void setTriangulationAlgorithm (Qgis::TriangulationAlgorithm algorithm)
 Sets the triangulation algorithm.
int stride () const
 Returns size of one vertex entry in bytes.
Q_DECL_DEPRECATED float textureRotation () const
 Returns the rotation of texture UV coordinates (in degrees).
Qgis::TriangulationAlgorithm triangulationAlgorithm () const
 Returns the algorithm used for triangulation.
int uniqueVertexCount () const
 Returns unique vertex count.
QByteArray vertexBuffer () const
 Returns vertex buffer for the generated points.
float zMaximum () const
 Returns maximal Z value of the data (in world coordinates).
float zMinimum () const
 Returns minimal Z value of the data (in world coordinates).

Friends

size_t qHash (const VertexPoint &key, size_t seed)

Detailed Description

Tessellates polygons into triangles.

It is expected that client code will create the tessellator object, then repeatedly call addPolygon() method that will generate triangles, and finally call data() to get final vertex data.

Optionally provides extrusion by adding triangles that serve as walls when extrusion height is non-zero.

Definition at line 41 of file qgstessellator.h.

Constructor & Destructor Documentation

◆ QgsTessellator() [1/3]

QgsTessellator::QgsTessellator ( )
default

◆ QgsTessellator() [2/3]

QgsTessellator::QgsTessellator ( double originX,
double originY,
bool addNormals,
bool invertNormals = false,
bool addBackFaces = false,
bool noZ = false,
bool addTextureCoords = false,
int facade = 3,
float textureRotation = 0.0f )

Creates tessellator with a specified origin point of the world (in map coordinates).

Deprecated
QGIS 4.0. Use the default QgsTessellator() constructor and individual setters instead.

Definition at line 124 of file qgstessellator.cpp.

◆ QgsTessellator() [3/3]

QgsTessellator::QgsTessellator ( const QgsRectangle & bounds,
bool addNormals,
bool invertNormals = false,
bool addBackFaces = false,
bool noZ = false,
bool addTextureCoords = false,
int facade = 3,
float textureRotation = 0.0f )

Creates tessellator with a specified bounds of input geometry coordinates.

This constructor allows the tessellator to map input coordinates to a desirable range for numerical stability during calculations.

If noZ is true, then a 2-dimensional tessellation only will be performed and all z coordinates will be ignored.

Since
QGIS 3.10
Deprecated
QGIS 4.0. Use the default QgsTessellator() constructor and individual setters instead.

Definition at line 135 of file qgstessellator.cpp.

Member Function Documentation

◆ addGeometry()

void QgsTessellator::addGeometry ( const QgsAbstractGeometry & geometry,
float extrusionHeight = 0 )

Tessellates a surface geometry and adds its vertex entries to the output data array.

Supported geometries are polygons, polyhedral surfaces and collections of these geometries.

Note
Curved geometries are supported but they are segmentized with the default segmentation tolerance.
See also
addPolygon()
Since
QGIS 4.6

Definition at line 970 of file qgstessellator.cpp.

◆ addPolygon()

void QgsTessellator::addPolygon ( const QgsPolygon & polygon,
float extrusionHeight )

Tessellates a triangle and adds its vertex entries to the output data array.

Definition at line 760 of file qgstessellator.cpp.

◆ asMultiPolygon()

std::unique_ptr< QgsMultiPolygon > QgsTessellator::asMultiPolygon ( ) const

Returns the triangulation as a multipolygon geometry.

Definition at line 1009 of file qgstessellator.cpp.

◆ data()

QVector< float > QgsTessellator::data ( ) const

Returns array of triangle vertex data.

Vertice coordinates are stored as (x, z, -y)

Deprecated
QGIS 4.0. Use vertexBuffer() in combination with indexBuffer().

Definition at line 1034 of file qgstessellator.cpp.

◆ dataVerticesCount()

int QgsTessellator::dataVerticesCount ( ) const

Returns the number of vertices stored in the output data array.

Definition at line 1004 of file qgstessellator.cpp.

◆ error()

QString QgsTessellator::error ( ) const
inline

Returns a descriptive error string if the tessellation failed.

Since
QGIS 3.34

Definition at line 303 of file qgstessellator.h.

◆ extrusionFaces()

Qgis::ExtrusionFaces QgsTessellator::extrusionFaces ( ) const
inline

Returns which faces are generated during extrusion.

Since
QGIS 4.0

Definition at line 109 of file qgstessellator.h.

◆ hasBackFacesEnabled()

bool QgsTessellator::hasBackFacesEnabled ( ) const
inline

Returns true if back faces are being added to the output data.

See also
setBackFacesEnabled()
Since
QGIS 4.0

Definition at line 185 of file qgstessellator.h.

◆ hasInvertedNormals()

bool QgsTessellator::hasInvertedNormals ( ) const
inline

Returns true if normals are inverted.

See also
setInvertNormals()
Since
QGIS 4.0

Definition at line 201 of file qgstessellator.h.

◆ hasNormals()

bool QgsTessellator::hasNormals ( ) const
inline

Returns true if normals are being added to the output data.

See also
setAddNormals()
Since
QGIS 4.0

Definition at line 153 of file qgstessellator.h.

◆ hasTangents()

bool QgsTessellator::hasTangents ( ) const
inline

Returns true if tangents are being added to the output data.

See also
setAddTangents()
Since
QGIS 4.2

Definition at line 169 of file qgstessellator.h.

◆ hasTextureUVs()

bool QgsTessellator::hasTextureUVs ( ) const
inline

Returns true if texture UV coordinates are being added to the output data.

See also
setAddTextureUVs()
Since
QGIS 4.0

Definition at line 137 of file qgstessellator.h.

◆ indexBuffer()

QByteArray QgsTessellator::indexBuffer ( ) const

Returns index buffer for the generated points.

Since
QGIS 4.0

Definition at line 512 of file qgstessellator.cpp.

◆ indexStride()

int QgsTessellator::indexStride ( ) const
inline

Returns size of one index entry in bytes.

Since
QGIS 4.0

Definition at line 279 of file qgstessellator.h.

◆ isOutputZUp()

Q_DECL_DEPRECATED bool QgsTessellator::isOutputZUp ( ) const
inline

Returns whether the "up" direction should be the Z axis on output (true), otherwise the "up" direction will be the Y axis (false).

The default value is false (to keep compatibility for existing tessellator use cases).

Deprecated
QGIS 4.2. Has no effect no, outputs are always z-up.

Definition at line 229 of file qgstessellator.h.

◆ isZValueIgnored()

bool QgsTessellator::isZValueIgnored ( ) const
inline

Returns whether Z values from the input geometries are ignored (true) or not (false).

Since
QGIS 4.0

Definition at line 97 of file qgstessellator.h.

◆ origin()

QgsVector3D QgsTessellator::origin ( ) const
inline

Returns the origin point of the map.

Since
QGIS 4.0

Definition at line 78 of file qgstessellator.h.

◆ setAddNormals()

void QgsTessellator::setAddNormals ( bool addNormals)

Sets whether normals should be added to the output data.

See also
hasNormals()
Since
QGIS 4.0

Definition at line 204 of file qgstessellator.cpp.

◆ setAddTangents()

void QgsTessellator::setAddTangents ( bool addTangents)

Sets whether tangents should be added to the output data.

See also
hasTangents()
Since
QGIS 4.2

Definition at line 210 of file qgstessellator.cpp.

◆ setAddTextureUVs()

void QgsTessellator::setAddTextureUVs ( bool addTextureUVs)

Sets whether texture UV coordinates should be added to the output data.

See also
hasTextureUVs()
Since
QGIS 4.0

Definition at line 216 of file qgstessellator.cpp.

◆ setBackFacesEnabled()

void QgsTessellator::setBackFacesEnabled ( bool addBackFaces)

Sets whether back faces should be added to the output data.

See also
hasBackFacesEnabled()
Since
QGIS 4.0

Definition at line 194 of file qgstessellator.cpp.

◆ setBounds()

void QgsTessellator::setBounds ( const QgsRectangle & bounds)

Sets scaling and the bounds of the input geometry coordinates.

Since
QGIS 4.0

Definition at line 151 of file qgstessellator.cpp.

◆ setExtrusionFaces()

void QgsTessellator::setExtrusionFaces ( Qgis::ExtrusionFaces faces)

Sets which faces should be generated during extrusion.

Since
QGIS 4.0

Definition at line 162 of file qgstessellator.cpp.

◆ setInputZValueIgnored()

void QgsTessellator::setInputZValueIgnored ( bool ignore)

Sets whether Z values from the input geometries are ignored (true) or not (false).

By default, this is false.

Since
QGIS 4.0

Definition at line 157 of file qgstessellator.cpp.

◆ setInvertNormals()

void QgsTessellator::setInvertNormals ( bool invertNormals)

Sets whether normals should be inverted.

See also
hasInvertedNormals()
Since
QGIS 4.0

Definition at line 199 of file qgstessellator.cpp.

◆ setOrigin()

void QgsTessellator::setOrigin ( const QgsVector3D & origin)

Sets the origin point of the map.

Since
QGIS 4.0

Definition at line 146 of file qgstessellator.cpp.

◆ setOutputZUp()

void QgsTessellator::setOutputZUp ( bool zUp)

Sets whether the "up" direction should be the Z axis on output (true), otherwise the "up" direction will be the Y axis (false).

The default value is false (to keep compatibility for existing tessellator use cases).

Deprecated
QGIS 4.2. Has no effect no, outputs are always z-up.

Definition at line 227 of file qgstessellator.cpp.

◆ setTextureRotation()

void QgsTessellator::setTextureRotation ( float rotation)

Sets the rotation of texture UV coordinates (in degrees).

Deprecated
QGIS 4.2. Handled in shaders now. No longer has any effect on the texture coordinates.

Definition at line 191 of file qgstessellator.cpp.

◆ setTriangulationAlgorithm()

void QgsTessellator::setTriangulationAlgorithm ( Qgis::TriangulationAlgorithm algorithm)

Sets the triangulation algorithm.

Since
QGIS 4.0

Definition at line 222 of file qgstessellator.cpp.

◆ stride()

int QgsTessellator::stride ( ) const
inline

Returns size of one vertex entry in bytes.

Definition at line 273 of file qgstessellator.h.

◆ textureRotation()

Q_DECL_DEPRECATED float QgsTessellator::textureRotation ( ) const
inline

Returns the rotation of texture UV coordinates (in degrees).

Deprecated
QGIS 4.2. Handled in shaders now. No longer has any effect on the texture coordinates.

Definition at line 121 of file qgstessellator.h.

◆ triangulationAlgorithm()

Qgis::TriangulationAlgorithm QgsTessellator::triangulationAlgorithm ( ) const
inline

Returns the algorithm used for triangulation.

Since
QGIS 4.0

Definition at line 213 of file qgstessellator.h.

◆ uniqueVertexCount()

int QgsTessellator::uniqueVertexCount ( ) const

Returns unique vertex count.

Since
QGIS 4.0

Definition at line 1055 of file qgstessellator.cpp.

◆ vertexBuffer()

QByteArray QgsTessellator::vertexBuffer ( ) const

Returns vertex buffer for the generated points.

Since
QGIS 4.0

Definition at line 507 of file qgstessellator.cpp.

◆ zMaximum()

float QgsTessellator::zMaximum ( ) const
inline

Returns maximal Z value of the data (in world coordinates).

Since
QGIS 3.12

Definition at line 296 of file qgstessellator.h.

◆ zMinimum()

float QgsTessellator::zMinimum ( ) const
inline

Returns minimal Z value of the data (in world coordinates).

Since
QGIS 3.12

Definition at line 290 of file qgstessellator.h.

◆ qHash

size_t qHash ( const VertexPoint & key,
size_t seed )
friend

Definition at line 321 of file qgstessellator.h.


The documentation for this class was generated from the following files: