Skip to content

Commit

Permalink
Clean up after refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdkon committed Nov 25, 2024
1 parent 4bac513 commit f655ad2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/3d/qgspointcloudlayerchunkloader_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>( nodeBounds.xMinimum() ),
static_cast<double>( nodeBounds.yMinimum() ),
static_cast<double>( nodeBounds.zMinimum() ) * zValueScale + zValueOffset );
QgsVector3D extentMax3D( static_cast<double>( nodeBounds.xMaximum() ),
static_cast<double>( nodeBounds.yMaximum() ),
static_cast<double>( 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
Expand Down
19 changes: 8 additions & 11 deletions src/3d/symbols/qgspointcloud3dsymbol_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@ typedef Qt3DCore::QGeometry Qt3DQGeometry;
#include <delaunator.hpp>

// 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 );
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<int> filteredOutValues = context.getFilteredOutValues();
for ( int i = 0; i < count; ++i )
Expand Down
2 changes: 1 addition & 1 deletion src/core/pointcloud/qgspointcloudindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 6 additions & 0 deletions src/core/pointcloud/qgspointcloudindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QgsPointCloudNodeId> 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<QgsPointCloudNodeId> 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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/src/3d/testqgspointcloud3drendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f655ad2

Please sign in to comment.