20#include <unordered_set>
39void QgsTessellator::addExtrusionWallQuad(
const QVector3D &pt1,
const QVector3D &pt2,
float height,
float u1,
float u2 )
41 const float dx = pt2.x() - pt1.x();
42 const float dy = pt2.y() - pt1.y();
45 QVector3D vn = QVector3D( -dy, dx, 0 );
52 QVector3D tangentDir( dx, dy, 0 );
53 tangentDir.normalize();
59 tangentDir = -tangentDir;
62 vt = QVector4D( tangentDir.x(), tangentDir.y(), tangentDir.z(), 1.0f );
70 const float v0 = -height;
71 const float v1 = -height;
72 const float v2 = 0.0f;
73 const float v3 = 0.0f;
77 mData << pt1.x() << pt1.y() << pt1.z() + height;
79 mData << vn.x() << vn.y() << vn.z();
81 mData << vt.x() << vt.y() << vt.z() << vt.w();
82 if ( mAddTextureCoords )
87 mData << pt2.x() << pt2.y() << pt2.z() + height;
89 mData << vn.x() << vn.y() << vn.z();
91 mData << vt.x() << vt.y() << vt.z() << vt.w();
92 if ( mAddTextureCoords )
97 mData << pt1.x() << pt1.y() << pt1.z();
99 mData << vn.x() << vn.y() << vn.z();
101 mData << vt.x() << vt.y() << vt.z() << vt.w();
102 if ( mAddTextureCoords )
113 mData << pt2.x() << pt2.y() << pt2.z();
115 mData << vn.x() << vn.y() << vn.z();
117 mData << vt.x() << vt.y() << vt.z() << vt.w();
118 if ( mAddTextureCoords )
124QgsTessellator::QgsTessellator(
double originX,
double originY,
bool addNormals,
bool invertNormals,
bool addBackFaces,
bool noZ,
bool addTextureCoords,
int facade,
float )
129 setExtrusionFacesLegacy( facade );
138 setExtrusionFacesLegacy( facade );
154 mScale = bounds.
isNull() ? 1.0 : std::max( 10000.0 / bounds.
width(), 10000.0 / bounds.
height() );
159 mInputZValueIgnored = ignore;
164 mExtrusionFaces = faces;
167void QgsTessellator::setExtrusionFacesLegacy(
int facade )
196 mAddBackFaces = addBackFaces;
201 mInvertNormals = invertNormals;
206 mAddNormals = addNormals;
212 mAddTangents = addTangents;
218 mAddTextureCoords = addTextureUVs;
230void QgsTessellator::updateStride()
232 mStride = 3 *
sizeof( float );
234 mStride += 3 *
sizeof( float );
236 mStride += 4 *
sizeof( float );
237 if ( mAddTextureCoords )
238 mStride += 2 *
sizeof( float );
241void QgsTessellator::makeWalls(
const QgsLineString &ring,
bool ccw,
float extrusionHeight )
253 float accumulatedU = 0.0f;
254 for (
int i = 1; i < ring.
numPoints(); ++i )
258 const QVector3D pt1(
static_cast<float>( ptPrev.
x() - mOrigin.x() ),
static_cast<float>( ptPrev.
y() - mOrigin.y() ),
static_cast<float>( std::isnan( ptPrev.
z() ) ? 0 : ptPrev.
z() - mOrigin.z() ) );
260 const QVector3D pt2(
static_cast<float>( pt.
x() - mOrigin.x() ),
static_cast<float>( pt.
y() - mOrigin.y() ),
static_cast<float>( std::isnan( pt.
z() ) ? 0 : pt.
z() - mOrigin.z() ) );
262 const float segmentLength = pt1.distanceToPoint( pt2 );
265 addExtrusionWallQuad( pt1, pt2, extrusionHeight, -accumulatedU, -( accumulatedU + segmentLength ) );
270 addExtrusionWallQuad( pt2, pt1, extrusionHeight, accumulatedU + segmentLength, accumulatedU );
273 accumulatedU += segmentLength;
278static QVector3D calculateNormal(
const QgsLineString *curve,
double originX,
double originY,
double originZ,
bool invertNormal,
float extrusionHeight )
283 if ( extrusionHeight != 0 )
284 return QVector3D( 0, 0, 1 );
287 float orientation = 1.f;
289 orientation = -orientation;
291 orientation = -orientation;
292 return QVector3D( 0, 0, orientation );
300 for (
int i = 1; i < curve->
numPoints(); i++ )
303 if ( pt1.
z() != pt2.
z() )
309 if ( sameZ && extrusionHeight != 0 )
310 return QVector3D( 0, 0, 1 );
317 double nx = 0, ny = 0, nz = 0;
320 pt1.
setX( pt1.
x() - originX );
321 pt1.
setY( pt1.
y() - originY );
322 pt1.
setZ( std::isnan( pt1.
z() ) ? 0.0 : pt1.
z() - originZ );
323 for (
int i = 1; i < curve->
numPoints(); i++ )
326 pt2.
setX( pt2.
x() - originX );
327 pt2.
setY( pt2.
y() - originY );
328 pt2.
setZ( std::isnan( pt2.
z() ) ? 0.0 : pt2.
z() - originZ );
330 nx += ( pt1.
y() - pt2.
y() ) * ( pt1.
z() + pt2.
z() );
331 ny += ( pt1.
z() - pt2.
z() ) * ( pt1.
x() + pt2.
x() );
332 nz += ( pt1.
x() - pt2.
x() ) * ( pt1.
y() + pt2.
y() );
337 QVector3D normal( nx, ny, nz );
345static void normalVectorToXYVectors(
const QVector3D &pNormal, QVector3D &pXVector, QVector3D &pYVector )
350 if ( pNormal.z() > 0.001 || pNormal.z() < -0.001 )
352 pXVector = QVector3D( 1, 0, -pNormal.x() / pNormal.z() );
354 else if ( pNormal.y() > 0.001 || pNormal.y() < -0.001 )
356 pXVector = QVector3D( 1, -pNormal.x() / pNormal.y(), 0 );
360 pXVector = QVector3D( -pNormal.y() / pNormal.x(), 1, 0 );
362 pXVector.normalize();
363 pYVector = QVector3D::normal( pNormal, pXVector );
368 std::size_t
operator()(
const std::pair<float, float> pair )
const
370 const std::size_t h1 = std::hash<float>()( pair.first );
371 const std::size_t h2 = std::hash<float>()( pair.second );
381 polyline.reserve( pCount );
383 const double *srcXData = ring->
xData();
384 const double *srcYData = ring->
yData();
385 const double *srcZData = ring->
zData();
386 std::unordered_set<std::pair<float, float>,
float_pair_hash> foundPoints;
388 for (
int i = 0; i < pCount - 1; ++i )
390 const float x = *srcXData++;
391 const float y = *srcYData++;
393 const auto res = foundPoints.insert( std::make_pair( x, y ) );
400 p2t::Point *pt2 =
new p2t::Point( x, y );
401 polyline.push_back( pt2 );
404 ( *zHash )[pt2] = *srcZData++;
412 const double exp = 1e10;
413 return round( x * exp ) / exp;
426 double *xData = x.data();
427 double *yData = y.data();
428 double *zData = z.data();
430 const double *srcXData = curve.
xData();
431 const double *srcYData = curve.
yData();
432 const double *srcZData = curve.
is3D() ? curve.
zData() :
nullptr;
434 for (
int i = 0; i < count; ++i )
436 QVector4D v( *srcXData++ - pt0.
x(), *srcYData++ - pt0.
y(), srcZData ? *srcZData++ - pt0.
z() : 0, 0 );
438 v = toNewBase->map( v );
441 v.setX( v.x() * scale );
442 v.setY( v.y() * scale );
476 std::vector< const QgsLineString * > rings;
485 if ( numPoints <= 1 )
488 const double *srcXData = ring->
xData();
489 const double *srcYData = ring->
yData();
490 double x0 = *srcXData++;
491 double y0 = *srcYData++;
492 for (
int i = 1; i < numPoints; ++i )
494 const double x1 = *srcXData++;
495 const double y1 = *srcYData++;
504 return min_d != 1e20 ? std::sqrt( min_d ) : 1e20;
509 return QByteArray(
reinterpret_cast<const char *
>( mData.constData() ),
sizeof(
float ) * mData.size() );
514 return QByteArray(
reinterpret_cast<const char *
>( mIndexBuffer.constData() ),
sizeof( uint32_t ) * mIndexBuffer.size() );
517void QgsTessellator::calculateBaseTransform(
const QVector3D &pNormal, QMatrix4x4 *base )
const
519 if ( !mInputZValueIgnored && pNormal != QVector3D( 0, 0, 1 ) )
523 QVector3D pXVector, pYVector;
524 normalVectorToXYVectors( pNormal, pXVector, pYVector );
529 *base = QMatrix4x4( pXVector.x(), pXVector.y(), pXVector.z(), 0, pYVector.x(), pYVector.y(), pYVector.z(), 0, pNormal.x(), pNormal.y(), pNormal.z(), 0, 0, 0, 0, 0 );
533 base->setToIdentity();
537QVector3D QgsTessellator::applyTransformWithExtrusion(
const QVector3D point,
float extrusionHeight, QMatrix4x4 *transformMatrix,
const QgsPoint *originOffset )
539 const float z = mInputZValueIgnored ? 0.0f : point.z();
540 QVector4D pt( point.x(), point.y(), z, 0 );
542 pt = *transformMatrix * pt;
544 const double fx = pt.
x() - mOrigin.x() + originOffset->
x();
545 const double fy = pt.y() - mOrigin.y() + originOffset->
y();
546 const double baseHeight = mInputZValueIgnored ? 0 : pt.z() - mOrigin.z() + originOffset->
z();
547 const double fz = mInputZValueIgnored ? 0.0 : ( baseHeight + extrusionHeight );
549 if ( baseHeight < mZMin )
550 mZMin =
static_cast<float>( baseHeight );
551 if ( baseHeight > mZMax )
552 mZMax =
static_cast<float>( baseHeight );
554 mZMax =
static_cast<float>( fz );
556 return QVector3D(
static_cast<float>( fx ),
static_cast<float>( fy ),
static_cast<float>( fz ) );
564 polyline.reserve( pCount );
566 const double *srcXData = ring->
xData();
567 const double *srcYData = ring->
yData();
568 const double *srcZData = ring->
zData();
571 for (
int i = 0; i < pCount - 1; ++i )
573 const double x = *srcXData++;
574 const double y = *srcYData++;
576 std::array<double, 2> pt = { x, y };
577 polyline.push_back( pt );
580 if ( zValues && srcZData )
582 zValues->insert( zValues->end(), srcZData, srcZData + pCount - 1 );
586std::vector<QVector3D> QgsTessellator::generateConstrainedDelaunayTriangles(
const QgsPolygon *polygonNew )
588 QList<std::vector<p2t::Point *>> polylinesToDelete;
589 QHash<p2t::Point *, float> z;
592 std::vector<p2t::Point *> polyline;
594 polylinesToDelete << polyline;
596 p2t::CDT cdt = p2t::CDT( polyline );
601 std::vector<p2t::Point *> holePolyline;
604 ringToPoly2tri( hole, holePolyline, mInputZValueIgnored ?
nullptr : &z );
606 cdt.AddHole( holePolyline );
607 polylinesToDelete << holePolyline;
611 std::vector<p2t::Triangle *> triangles = cdt.GetTriangles();
613 std::vector<QVector3D> trianglePoints;
614 trianglePoints.reserve( triangles.size() * 3 );
616 for ( p2t::Triangle *t : triangles )
618 trianglePoints.emplace_back( t->GetPoint( 0 )->x / mScale, t->GetPoint( 0 )->y / mScale, z.value( t->GetPoint( 0 ) ) );
619 trianglePoints.emplace_back( t->GetPoint( 1 )->x / mScale, t->GetPoint( 1 )->y / mScale, z.value( t->GetPoint( 1 ) ) );
620 trianglePoints.emplace_back( t->GetPoint( 2 )->x / mScale, t->GetPoint( 2 )->y / mScale, z.value( t->GetPoint( 2 ) ) );
623 for (
int i = 0; i < polylinesToDelete.count(); ++i )
624 qDeleteAll( polylinesToDelete[i] );
626 return trianglePoints;
629std::vector<QVector3D> QgsTessellator::generateEarcutTriangles(
const QgsPolygon *polygonNew )
631 const bool useZValues = !mInputZValueIgnored && polygonNew->
is3D();
632 const int allVerticesCount = polygonNew->
nCoordinates();
633 std::vector<double> zValues;
636 zValues.reserve( allVerticesCount );
638 std::vector<std::vector<std::array<double, 2>>> rings;
642 std::vector<std::array<double, 2>> polyline;
644 rings.push_back( std::move( polyline ) );
649 std::vector<std::array<double, 2>> holePolyline;
651 rings.push_back( std::move( holePolyline ) );
654 std::vector<std::array<double, 2>> points;
655 points.reserve( allVerticesCount );
657 for (
const auto &ring : rings )
659 points.insert( points.end(), ring.begin(), ring.end() );
662 std::vector<uint32_t> indices = mapbox::earcut<uint32_t>( rings );
663 std::vector<QVector3D> trianglePoints;
664 trianglePoints.reserve( indices.size() );
666 for (
size_t i = 0; i < indices.size(); i++ )
668 uint32_t vertexIndex = indices[i];
670 const float x =
static_cast<float>( points[vertexIndex][0] );
671 const float y =
static_cast<float>( points[vertexIndex][1] );
672 const float z =
static_cast<float>( useZValues ? zValues[vertexIndex] : 0.0 );
674 trianglePoints.emplace_back( x / mScale, y / mScale, z );
677 return trianglePoints;
680void QgsTessellator::addVertex(
681 const QVector3D &point,
682 const QVector3D &normal,
683 const QVector4D &tangent,
684 float extrusionHeight,
685 QMatrix4x4 *transformMatrix,
687 QHash<VertexPoint, unsigned int> *vertexBuffer,
688 const size_t &vertexBufferOffset,
692 const QVector3D pt = applyTransformWithExtrusion( point, extrusionHeight, transformMatrix, originOffset );
693 const VertexPoint vertex( pt, normal, tangent );
697 mIndexBuffer << vertexBufferOffset + index;
703 mIndexBuffer << vertexBufferOffset + index;
705 mData << pt.x() << pt.y() << pt.z();
708 mData << normal.x() << normal.y() << normal.z();
712 mData << tangent.x() << tangent.y() << tangent.z() << tangent.w();
714 if ( mAddTextureCoords )
731void QgsTessellator::addVertex(
const QVector3D &point,
const QVector3D &normal,
const QVector4D &tangent,
float extrusionHeight, QMatrix4x4 *transformMatrix,
const QgsPoint *originOffset,
bool isFloor )
733 const QVector3D pt = applyTransformWithExtrusion( point, extrusionHeight, transformMatrix, originOffset );
735 mData << pt.x() << pt.y() << pt.z();
738 mData << normal.x() << normal.y() << normal.z();
742 mData << tangent.x() << tangent.y() << tangent.z() << tangent.w();
744 if ( mAddTextureCoords )
766 const QVector3D pNormal = !mInputZValueIgnored ? calculateNormal( exterior, mOrigin.x(), mOrigin.y(), mOrigin.z(), mInvertNormals, extrusionHeight ) : QVector3D();
768 const QVector4D frontTangent( 1.0f, 0.0f, 0.0f, 1.0f );
769 const QVector4D floorFrontTangent( -1.0f, 0.0f, 0.0f, 1.0f );
771 const QVector4D backTangent( frontTangent.x(), frontTangent.y(), frontTangent.z(), -1.0f );
772 const QVector4D floorBackTangent( floorFrontTangent.x(), floorFrontTangent.y(), floorFrontTangent.z(), -1.0f );
774 const int pCount = exterior->
numPoints();
781 std::unique_ptr<QgsPolygon> polygonNew;
783 if ( !mInputZValueIgnored && !
qgsDoubleNear( pNormal.length(), 1, 0.001 ) )
786 bool buildWalls =
false;
787 bool buildFloor =
false;
788 bool buildRoof =
false;
803 if ( buildFloor || buildRoof )
805 calculateBaseTransform( pNormal, &base );
808 QVector3D normal = pNormal;
810 base = base.transposed();
814 Q_ASSERT( polygonNew->exteriorRing()->numPoints() >= 3 );
817 const QVector3D p1(
static_cast<float>( triangle->
xAt( 0 ) ),
static_cast<float>( triangle->
yAt( 0 ) ),
static_cast<float>( triangle->
zAt( 0 ) ) );
818 const QVector3D p2(
static_cast<float>( triangle->
xAt( 1 ) ),
static_cast<float>( triangle->
yAt( 1 ) ),
static_cast<float>( triangle->
zAt( 1 ) ) );
819 const QVector3D p3(
static_cast<float>( triangle->
xAt( 2 ) ),
static_cast<float>( triangle->
yAt( 2 ) ),
static_cast<float>( triangle->
zAt( 2 ) ) );
820 std::array<QVector3D, 3> points = { p1, p2, p3 };
824 for (
const QVector3D &point : points )
826 addVertex( point, normal, frontTangent, extrusionHeight, &base, &extrusionOrigin );
831 for (
size_t i = points.size(); i-- > 0; )
833 const QVector3D &point = points[i];
834 addVertex( point, -normal, backTangent, extrusionHeight, &base, &extrusionOrigin );
841 for (
const QVector3D &point : points )
843 addVertex( point, normal, floorFrontTangent, 0.0, &base, &extrusionOrigin,
true );
848 for (
size_t i = points.size(); i-- > 0; )
850 const QVector3D &point = points[i];
851 addVertex( point, -normal, floorBackTangent, 0.0, &base, &extrusionOrigin,
true );
865 if ( polygonSimplified.
isNull() )
867 mError = QObject::tr(
"geometry simplification failed - skipping" );
875 mError = QObject::tr(
"geometry's coordinates are too close to each other and simplification failed - skipping" );
880 polygonNew.reset( polygonSimplifiedData->
clone() );
887 std::vector<QVector3D> trianglePoints;
888 switch ( mTriangulationAlgorithm )
891 trianglePoints = generateConstrainedDelaunayTriangles( polygonNew.get() );
894 trianglePoints = generateEarcutTriangles( polygonNew.get() );
898 if ( trianglePoints.empty() )
900 mError = QObject::tr(
"Failed to triangulate polygon." );
904 Q_ASSERT( trianglePoints.size() % 3 == 0 );
906 mData.reserve( mData.size() + trianglePoints.size() * 3 * (
stride() /
sizeof(
float ) ) );
910 for (
size_t i = 0; i < trianglePoints.size(); i += 3 )
912 const std::array<QVector3D, 3> points = { trianglePoints[i + 0], trianglePoints[i + 1], trianglePoints[i + 2] };
917 for (
const QVector3D &point : points )
919 addVertex( point, normal, frontTangent, extrusionHeight, &base, &extrusionOrigin, &
vertexBuffer, vertexBufferSize );
924 for (
size_t i = points.size(); i-- > 0; )
926 const QVector3D &point = points[i];
927 addVertex( point, -normal, backTangent, extrusionHeight, &base, &extrusionOrigin, &
vertexBuffer, vertexBufferSize );
934 for (
const QVector3D &point : points )
936 addVertex( point, normal, floorFrontTangent, 0.0, &base, &extrusionOrigin, &
vertexBuffer, vertexBufferSize,
true );
941 for (
size_t i = points.size(); i-- > 0; )
943 const QVector3D &point = points[i];
944 addVertex( point, -normal, floorBackTangent, 0.0, &base, &extrusionOrigin, &
vertexBuffer, vertexBufferSize,
true );
950 catch ( std::runtime_error &err )
956 mError = QObject::tr(
"An unknown error occurred" );
964 makeWalls( *exterior,
false, extrusionHeight );
986 for (
int i = 0; i < surface->numPatches(); ++i )
988 addPolygon( *surface->patchN( i ), extrusionHeight );
993 for (
int i = 0; i < collection->numGeometries(); ++i )
995 addGeometry( *collection->geometryN( i ), extrusionHeight );
1006 return mIndexBuffer.size();
1011 auto mp = std::make_unique< QgsMultiPolygon >();
1012 const size_t nVals = mIndexBuffer.size();
1014 Q_ASSERT( nVals % 3 == 0 );
1016 mp->reserve( nVals / 3 );
1017 const size_t noOfElements =
stride() /
sizeof( float );
1019 for (
size_t i = 0; i + 2 < nVals; i += 3 )
1021 const uint32_t index1 = mIndexBuffer[i] * noOfElements;
1022 const uint32_t index2 = mIndexBuffer[i + 1] * noOfElements;
1023 const uint32_t index3 = mIndexBuffer[i + 2] * noOfElements;
1025 const QgsPoint p1( mData[index1], mData[index1 + 1], mData[index1 + 2] );
1026 const QgsPoint p2( mData[index2], mData[index2 + 1], mData[index2 + 2] );
1027 const QgsPoint p3( mData[index3], mData[index3 + 1], mData[index3 + 2] );
1036 const size_t n = mIndexBuffer.size();
1038 return QVector<float>();
1040 QVector<float> tData;
1041 size_t noOfElements =
stride() /
sizeof( float );
1042 tData.reserve( n * noOfElements );
1044 for (
auto &index : mIndexBuffer )
1046 for (
size_t i = 0; i < noOfElements; i++ )
1048 tData << mData[index * noOfElements + i];
1057 if ( mData.size() == 0 )
1060 return mData.size() / (
stride() /
sizeof( float ) );
@ CounterClockwise
Counter-clockwise direction.
@ Clockwise
Clockwise direction.
TriangulationAlgorithm
Triangulation algorithms.
QFlags< ExtrusionFace > ExtrusionFaces
Tessellator extrusion face types.
Abstract base class for all geometries.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
Curve polygon geometry type.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
int nCoordinates() const override
Returns the number of nodes contained in the geometry.
Abstract base class for curved geometry type.
Qgis::AngularDirection orientation() const
Returns the curve's orientation, e.g.
static double sqrDistance2D(double x1, double y1, double x2, double y2)
Returns the squared 2D distance between (x1, y1) and (x2, y2).
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsGeometry simplify(double tolerance, QgsFeedback *feedback=nullptr) const
Returns a simplified version of this geometry using a specified tolerance value.
Line string geometry type, with support for z-dimension and m-values.
Point geometry type, with support for z-dimension and m-values.
void setY(double y)
Sets the point's y-coordinate.
void setX(double x)
Sets the point's x-coordinate.
void setZ(double z)
Sets the point's z-coordinate.
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership).
QgsPolygon * clone() const override
Clones the geometry by performing a deep copy.
Polyhedral surface geometry type.
A rectangle specified with double values.
double yAt(int index) const override
Returns the y-coordinate of the specified node in the line string.
int numPoints() const override
Returns the number of points in the curve.
double xAt(int index) const override
Returns the x-coordinate of the specified node in the line string.
const double * yData() const
Returns a const pointer to the y vertex data.
double zAt(int index) const override
Returns the z-coordinate of the specified node in the simple curve.
QgsPoint startPoint() const override
Returns the starting point of the curve.
QgsPoint pointN(int i) const
Returns the specified point from inside the simple curve.
const double * xData() const
Returns a const pointer to the x vertex data.
const double * zData() const
Returns a const pointer to the z vertex data, or nullptr if the simple curve does not have z values.
std::unique_ptr< QgsMultiPolygon > asMultiPolygon() const
Returns the triangulation as a multipolygon geometry.
Q_DECL_DEPRECATED void setTextureRotation(float rotation)
Sets the rotation of texture UV coordinates (in degrees).
void addGeometry(const QgsAbstractGeometry &geometry, float extrusionHeight=0)
Tessellates a surface geometry and adds its vertex entries to the output data array.
void setOrigin(const QgsVector3D &origin)
Sets the origin point of the map.
void setTriangulationAlgorithm(Qgis::TriangulationAlgorithm algorithm)
Sets the triangulation algorithm.
Q_DECL_DEPRECATED QVector< float > data() const
Returns array of triangle vertex data.
QByteArray vertexBuffer() const
Returns vertex buffer for the generated points.
int stride() const
Returns size of one vertex entry in bytes.
void setBounds(const QgsRectangle &bounds)
Sets scaling and the bounds of the input geometry coordinates.
void addPolygon(const QgsPolygon &polygon, float extrusionHeight)
Tessellates a triangle and adds its vertex entries to the output data array.
QgsVector3D origin() const
Returns the origin point of the map.
int uniqueVertexCount() const
Returns unique vertex count.
QByteArray indexBuffer() const
Returns index buffer for the generated points.
void setInvertNormals(bool invertNormals)
Sets whether normals should be inverted.
void setBackFacesEnabled(bool addBackFaces)
Sets whether back faces should be added to the output data.
Q_DECL_DEPRECATED void setOutputZUp(bool zUp)
Sets whether the "up" direction should be the Z axis on output (true), otherwise the "up" direction w...
void setAddTangents(bool addTangents)
Sets whether tangents should be added to the output data.
int dataVerticesCount() const
Returns the number of vertices stored in the output data array.
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 setAddTextureUVs(bool addTextureUVs)
Sets whether texture UV coordinates should be added to the output data.
void setAddNormals(bool addNormals)
Sets whether normals should be added to the output data.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
static Q_INVOKABLE QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
static Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
T qgsgeometry_cast(QgsAbstractGeometry *geom)
bool isCounterClockwise(std::array< Direction, 4 > dirs)
Checks whether the 4 directions in dirs make up a counter-clockwise rectangle.
double minimumDistanceBetweenCoordinates(const QgsPolygon &polygon)
void ringToEarcutPoints(const QgsLineString *ring, std::vector< std::array< double, 2 > > &polyline, std::vector< double > *zValues)
void ringToPoly2tri(const QgsLineString *ring, std::vector< p2t::Point * > &polyline, QHash< p2t::Point *, float > *zHash)
QgsPolygon * transformPolygonToNewBase(const QgsPolygon &polygon, const QgsPoint &pt0, const QMatrix4x4 *toNewBase, const float scale)
double roundCoord(double x)
std::size_t operator()(const std::pair< float, float > pair) const