From f655ad2318e9c11682f83d242a4b2b75fa359e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ko=C5=88a=C5=99=C3=ADk?= Date: Mon, 25 Nov 2024 12:38:18 +0100 Subject: [PATCH] Clean up after refactor --- src/3d/qgspointcloudlayerchunkloader_p.cpp | 12 ++++++------ src/3d/symbols/qgspointcloud3dsymbol_p.cpp | 19 ++++++++----------- src/core/pointcloud/qgspointcloudindex.cpp | 2 +- src/core/pointcloud/qgspointcloudindex.h | 6 ++++++ tests/src/3d/testqgspointcloud3drendering.cpp | 4 ++-- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/3d/qgspointcloudlayerchunkloader_p.cpp b/src/3d/qgspointcloudlayerchunkloader_p.cpp index e94aa6909e7c8..f7e8a4519c26c 100644 --- a/src/3d/qgspointcloudlayerchunkloader_p.cpp +++ b/src/3d/qgspointcloudlayerchunkloader_p.cpp @@ -182,12 +182,12 @@ int QgsPointCloudLayerChunkLoaderFactory::primitivesCount( QgsChunkNode *node ) static QgsBox3D nodeBoundsToBox3D( QgsBox3D nodeBounds, const QgsCoordinateTransform &coordinateTransform, double zValueOffset, double zValueScale ) { - QgsVector3D extentMin3D( static_cast( nodeBounds.xMinimum() ), - static_cast( nodeBounds.yMinimum() ), - static_cast( nodeBounds.zMinimum() ) * zValueScale + zValueOffset ); - QgsVector3D extentMax3D( static_cast( nodeBounds.xMaximum() ), - static_cast( nodeBounds.yMaximum() ), - static_cast( nodeBounds.zMaximum() ) * zValueScale + zValueOffset ); + QgsVector3D extentMin3D( nodeBounds.xMinimum(), + nodeBounds.yMinimum(), + nodeBounds.zMinimum() * zValueScale + zValueOffset ); + QgsVector3D extentMax3D( nodeBounds.xMaximum(), + nodeBounds.yMaximum(), + nodeBounds.zMaximum() * zValueScale + zValueOffset ); QgsCoordinateTransform extentTransform = coordinateTransform; extentTransform.setBallparkTransformsAreAppropriate( true ); try diff --git a/src/3d/symbols/qgspointcloud3dsymbol_p.cpp b/src/3d/symbols/qgspointcloud3dsymbol_p.cpp index 6a920c8510164..b2248f958d967 100644 --- a/src/3d/symbols/qgspointcloud3dsymbol_p.cpp +++ b/src/3d/symbols/qgspointcloud3dsymbol_p.cpp @@ -56,15 +56,12 @@ typedef Qt3DCore::QGeometry Qt3DQGeometry; #include // pick a point that we'll use as origin for coordinates for this node's points -static QgsVector3D originFromNodeBounds( QgsPointCloudIndex *pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context, const QgsPointCloudBlock *block ) +static QgsVector3D originFromNodeBounds( QgsPointCloudIndex *pc, const QgsPointCloudNodeId &n, const QgsPointCloud3DRenderContext &context) { - const QgsVector3D blockScale = block->scale(); - const QgsVector3D blockOffset = block->offset(); - QgsBox3D bounds = pc->getNode( n ).bounds(); - double nodeOriginX = bounds.xMinimum() * blockScale.x() + blockOffset.x(); - double nodeOriginY = bounds.yMinimum() * blockScale.y() + blockOffset.y(); - double nodeOriginZ = ( bounds.zMinimum() * blockScale.z() + blockOffset.z() ) * context.zValueScale() + context.zValueFixedOffset(); + double nodeOriginX = bounds.xMinimum(); + double nodeOriginY = bounds.yMinimum(); + double nodeOriginZ = bounds.zMinimum() * context.zValueScale() + context.zValueFixedOffset(); try { context.coordinateTransform().transformInPlace( nodeOriginX, nodeOriginY, nodeOriginZ ); @@ -618,7 +615,7 @@ void QgsSingleColorPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *p if ( !output ) output = &outNormal; - output->positionsOrigin = originFromNodeBounds( pc, n, context, block.get() ); + output->positionsOrigin = originFromNodeBounds( pc, n, context ); for ( int i = 0; i < count; ++i ) { @@ -743,7 +740,7 @@ void QgsColorRampPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc, if ( !output ) output = &outNormal; - output->positionsOrigin = originFromNodeBounds( pc, n, context, block.get() ); + output->positionsOrigin = originFromNodeBounds( pc, n, context ); for ( int i = 0; i < count; ++i ) { @@ -865,7 +862,7 @@ void QgsRGBPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc, const if ( !output ) output = &outNormal; - output->positionsOrigin = originFromNodeBounds( pc, n, context, block.get() ); + output->positionsOrigin = originFromNodeBounds( pc, n, context ); int ir = 0; int ig = 0; @@ -1035,7 +1032,7 @@ void QgsClassificationPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex if ( !output ) output = &outNormal; - output->positionsOrigin = originFromNodeBounds( pc, n, context, block.get() ); + output->positionsOrigin = originFromNodeBounds( pc, n, context ); const QSet filteredOutValues = context.getFilteredOutValues(); for ( int i = 0; i < count; ++i ) diff --git a/src/core/pointcloud/qgspointcloudindex.cpp b/src/core/pointcloud/qgspointcloudindex.cpp index 58e2916bbfc2f..724d1053e1edc 100644 --- a/src/core/pointcloud/qgspointcloudindex.cpp +++ b/src/core/pointcloud/qgspointcloudindex.cpp @@ -124,7 +124,7 @@ QgsBox3D QgsPointCloudNode::bounds() const { const QgsBox3D rootBounds = mIndex.rootNodeBounds(); const double d = rootBounds.xMaximum() - rootBounds.xMinimum(); - const double dLevel = ( double )d / pow( 2, mId.d() ); + const double dLevel = d / pow( 2, mId.d() ); const double xMin = rootBounds.xMinimum() + dLevel * mId.x(); const double xMax = rootBounds.xMinimum() + dLevel * ( mId.x() + 1 ); diff --git a/src/core/pointcloud/qgspointcloudindex.h b/src/core/pointcloud/qgspointcloudindex.h index 858728d6fb308..215d9f0ab8fe3 100644 --- a/src/core/pointcloud/qgspointcloudindex.h +++ b/src/core/pointcloud/qgspointcloudindex.h @@ -158,16 +158,21 @@ uint qHash( const QgsPointCloudCacheKey &key ); class CORE_EXPORT QgsPointCloudNode { public: + //! Constructs new node object. Should only be called by QgsPointCloudIndex::getNode() QgsPointCloudNode( const QgsPointCloudIndex &index, QgsPointCloudNodeId id, qint64 pointCount, QList childIds ) : mIndex( index ), mId( id ), mPointCount( pointCount ), mChildIds( childIds ) { } + //! Returns node's ID (unique in index) QgsPointCloudNodeId id() const { return mId; } + //! Returns number of points contained in node data qint64 pointCount() const { return mPointCount; } + //! Returns IDs of child nodes QList children() const { return mChildIds; } //! Returns node's error in map units (used to determine in whether the node has enough detail for the current view) float error() const; + //! Returns node's bounding cube in CRS coords QgsBox3D bounds() const; private: @@ -247,6 +252,7 @@ class CORE_EXPORT QgsPointCloudIndex //! Returns whether the octree contain given node virtual bool hasNode( const QgsPointCloudNodeId &n ) const; + //! Returns object for a given node virtual QgsPointCloudNode getNode( const QgsPointCloudNodeId &id ) const; //! Returns all attributes that are stored in the file diff --git a/tests/src/3d/testqgspointcloud3drendering.cpp b/tests/src/3d/testqgspointcloud3drendering.cpp index fb6a15df22312..f0b471fa551a2 100644 --- a/tests/src/3d/testqgspointcloud3drendering.cpp +++ b/tests/src/3d/testqgspointcloud3drendering.cpp @@ -479,9 +479,9 @@ void TestQgsPointCloud3DRendering::testPointCloudFilteredClassification() // find a better fix in the future. QImage img = Qgs3DUtils::captureSceneImage( engine, scene ); - QGSVERIFYIMAGECHECK( "pointcloud_3d_filtered_classification", "pointcloud_3d_filtered_classification", img, QString(), 80, QSize( 0, 0 ), 15 ); - mLayer->setSubsetString( "" ); + + QGSVERIFYIMAGECHECK( "pointcloud_3d_filtered_classification", "pointcloud_3d_filtered_classification", img, QString(), 80, QSize( 0, 0 ), 15 ); } void TestQgsPointCloud3DRendering::testPointCloudFilteredSceneExtent()