Skip to content
Permalink
Browse files

Minor optimisations, warning fixes for point clouds

  • Loading branch information
nyalldawson committed Jan 4, 2021
1 parent 610cb46 commit b01ff14ac2c512c491c821346f883358b0eb42bb
@@ -39,11 +39,6 @@ IndexedPointCloudNode::IndexedPointCloudNode( int _d, int _x, int _y, int _z ):
mZ( _z )
{}

bool IndexedPointCloudNode::operator==( const IndexedPointCloudNode &other ) const
{
return mD == other.d() && mX == other.x() && mY == other.y() && mZ == other.z();
}

IndexedPointCloudNode IndexedPointCloudNode::fromString( const QString &str )
{
QStringList lst = str.split( '-' );
@@ -54,7 +49,7 @@ IndexedPointCloudNode IndexedPointCloudNode::fromString( const QString &str )

QString IndexedPointCloudNode::toString() const
{
return QString( "%1-%2-%3-%4" ).arg( mD ).arg( mX ).arg( mY ).arg( mZ );
return QStringLiteral( "%1-%2-%3-%4" ).arg( mD ).arg( mX ).arg( mY ).arg( mZ );
}

int IndexedPointCloudNode::d() const
@@ -77,7 +72,7 @@ int IndexedPointCloudNode::z() const
return mZ;
}

uint qHash( const IndexedPointCloudNode &id )
uint qHash( IndexedPointCloudNode id )
{
return id.d() + id.x() + id.y() + id.z();
}
@@ -58,7 +58,10 @@ class CORE_EXPORT IndexedPointCloudNode
bool isValid() const { return mD >= 0; }

//! Compares nodes
bool operator==( const IndexedPointCloudNode &other ) const;
bool operator==( IndexedPointCloudNode other ) const
{
return mD == other.d() && mX == other.x() && mY == other.y() && mZ == other.z();
}

//! Creates node from string
static IndexedPointCloudNode fromString( const QString &str );
@@ -83,7 +86,7 @@ class CORE_EXPORT IndexedPointCloudNode
};

//! Hash function for indexed nodes
CORE_EXPORT uint qHash( const IndexedPointCloudNode &id );
CORE_EXPORT uint qHash( IndexedPointCloudNode id );

/**
* \ingroup core
@@ -51,7 +51,7 @@ QgsPointCloudLayerRenderer::QgsPointCloudLayerRenderer( QgsPointCloudLayer *laye
mOffset = mLayer->dataProvider()->index()->offset();
}

if ( const QgsPointCloudLayerElevationProperties *elevationProps = dynamic_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() ) )
if ( const QgsPointCloudLayerElevationProperties *elevationProps = qobject_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() ) )
{
mZOffset = elevationProps->zOffset();
mZScale = elevationProps->zScale();
@@ -119,7 +119,7 @@ bool QgsPointCloudLayerRenderer::render()

const IndexedPointCloudNode root = pc->root();

const float maximumError = context.renderContext().convertToPainterUnits( mRenderer->maximumScreenError(), mRenderer->maximumScreenErrorUnit() );// in pixels
const double maximumError = context.renderContext().convertToPainterUnits( mRenderer->maximumScreenError(), mRenderer->maximumScreenErrorUnit() );// in pixels

const QgsRectangle rootNodeExtentLayerCoords = pc->nodeMapExtent( root );
QgsRectangle rootNodeExtentMapCoords;
@@ -133,15 +133,15 @@ bool QgsPointCloudLayerRenderer::render()
rootNodeExtentMapCoords = rootNodeExtentLayerCoords;
}

const float rootErrorInMapCoordinates = rootNodeExtentMapCoords.width() / pc->span(); // in map coords
const double rootErrorInMapCoordinates = rootNodeExtentMapCoords.width() / pc->span(); // in map coords

double mapUnitsPerPixel = context.renderContext().mapToPixel().mapUnitsPerPixel();
if ( ( rootErrorInMapCoordinates < 0.0 ) || ( mapUnitsPerPixel < 0.0 ) || ( maximumError < 0.0 ) )
{
QgsDebugMsg( QStringLiteral( "invalid screen error" ) );
return false;
}
float rootErrorPixels = rootErrorInMapCoordinates / mapUnitsPerPixel; // in pixels
double rootErrorPixels = rootErrorInMapCoordinates / mapUnitsPerPixel; // in pixels
const QVector<IndexedPointCloudNode> nodes = traverseTree( pc, context.renderContext(), pc->root(), maximumError, rootErrorPixels );

QgsPointCloudRequest request;
@@ -186,8 +186,8 @@ bool QgsPointCloudLayerRenderer::forceRasterRender() const
QVector<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const QgsPointCloudIndex *pc,
const QgsRenderContext &context,
IndexedPointCloudNode n,
float maxErrorPixels,
float nodeErrorPixels )
double maxErrorPixels,
double nodeErrorPixels )
{
QVector<IndexedPointCloudNode> nodes;

@@ -207,7 +207,7 @@ QVector<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const Q

nodes.append( n );

float childrenErrorPixels = nodeErrorPixels / 2.0f;
double childrenErrorPixels = nodeErrorPixels / 2.0;
if ( childrenErrorPixels < maxErrorPixels )
return nodes;

@@ -63,7 +63,7 @@ class CORE_EXPORT QgsPointCloudLayerRenderer: public QgsMapLayerRenderer
bool forceRasterRender() const override;

private:
QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, const QgsRenderContext &context, IndexedPointCloudNode n, float maxErrorPixels, float nodeErrorPixels );
QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, const QgsRenderContext &context, IndexedPointCloudNode n, double maxErrorPixels, double nodeErrorPixels );

QgsPointCloudLayer *mLayer = nullptr;

0 comments on commit b01ff14

Please sign in to comment.
You can’t perform that action at this time.