Skip to content
Permalink
Browse files

Refactoe QgsPointCloudLayerRenderer::traverseTree

  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 4, 2021
1 parent 61ee203 commit 9ee8ec8864e71b3f3ad87290e6aae583656d8974
@@ -153,7 +153,7 @@ bool QgsPointCloudLayerRenderer::render()
return false;
}
float rootErrorPixels = rootErrorInMapCoordinates / mapUnitsPerPixel; // in pixels
const QList<IndexedPointCloudNode> nodes = traverseTree( pc, context.renderContext(), pc->root(), maximumError, rootErrorPixels );
const QVector<IndexedPointCloudNode> nodes = traverseTree( pc, context.renderContext(), pc->root(), maximumError, rootErrorPixels );

QgsPointCloudRequest request;
request.setAttributes( mAttributes );
@@ -291,13 +291,14 @@ QVector<QMap<QString, QString>> QgsPointCloudLayerRenderer::identify( const QgsG
return acceptedPoints;
}

QList<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const QgsPointCloudIndex *pc,
QVector<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const QgsPointCloudIndex *pc,
const QgsRenderContext &context,
IndexedPointCloudNode n,
float maxErrorPixels,
float nodeErrorPixels )
float nodeErrorPixels,
const QgsGeometry &geometry )
{
QList<IndexedPointCloudNode> nodes;
QVector<IndexedPointCloudNode> nodes;

if ( context.renderingStopped() )
{
@@ -313,6 +314,9 @@ QList<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const Qgs
if ( !context.zRange().isInfinite() && !context.zRange().overlaps( adjustedNodeZRange ) )
return nodes;

if ( !geometry.isNull() && !geometry.intersects( pc->nodeMapExtent( n ) ) )
return nodes;

nodes.append( n );

float childrenErrorPixels = nodeErrorPixels / 2.0f;
@@ -322,42 +326,43 @@ QList<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const Qgs
const QList<IndexedPointCloudNode> children = pc->nodeChildren( n );
for ( const IndexedPointCloudNode &nn : children )
{
nodes += traverseTree( pc, context, nn, maxErrorPixels, childrenErrorPixels );
if ( geometry.isNull() || geometry.intersects( pc->nodeMapExtent( nn ) ) )
nodes += traverseTree( pc, context, nn, maxErrorPixels, childrenErrorPixels );
}

return nodes;
}

QVector<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const QgsPointCloudIndex *pc,
const QgsRenderContext &context,
IndexedPointCloudNode n,
float maxErrorPixels,
float nodeErrorPixels,
const QgsGeometry &geom )
{
QVector<IndexedPointCloudNode> nodes;
//QVector<IndexedPointCloudNode> QgsPointCloudLayerRenderer::traverseTree( const QgsPointCloudIndex *pc,
// const QgsRenderContext &context,
// IndexedPointCloudNode n,
// float maxErrorPixels,
// float nodeErrorPixels,
// const QgsGeometry &geom )
//{
// QVector<IndexedPointCloudNode> nodes;

if ( !geom.intersects( pc->nodeMapExtent( n ) ) )
return nodes;
// if ( !geom.intersects( pc->nodeMapExtent( n ) ) )
// return nodes;

if ( !context.zRange().isInfinite() && !context.zRange().overlaps( pc->nodeZRange( n ) ) )
return nodes;
// if ( !context.zRange().isInfinite() && !context.zRange().overlaps( pc->nodeZRange( n ) ) )
// return nodes;

nodes.append( n );
// nodes.append( n );

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

const QList<IndexedPointCloudNode> children = pc->nodeChildren( n );
for ( const IndexedPointCloudNode &nn : children )
{
if ( geom.intersects( pc->nodeMapExtent( nn ) ) )
nodes += traverseTree( pc, context, nn, maxErrorPixels, childrenErrorPixels, geom );
}
// const QList<IndexedPointCloudNode> children = pc->nodeChildren( n );
// for ( const IndexedPointCloudNode &nn : children )
// {
// if ( geom.intersects( pc->nodeMapExtent( nn ) ) )
// nodes += traverseTree( pc, context, nn, maxErrorPixels, childrenErrorPixels, geom );
// }

return nodes;
}
// return nodes;
//}

QgsPointCloudLayerRenderer::~QgsPointCloudLayerRenderer() = default;

@@ -118,10 +118,8 @@ class CORE_EXPORT QgsPointCloudLayerRenderer: public QgsMapLayerRenderer

private:

//! Traverses tree and returns all nodes in specified depth
QList<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, const QgsRenderContext &context, IndexedPointCloudNode n, float maxErrorPixels, float nodeErrorPixels );
//! Traverses tree and returns all nodes that intersects with a \a geometry in specified depth
QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, const QgsRenderContext &context, IndexedPointCloudNode n, float maxErrorPixels, float nodeErrorPixels, const QgsGeometry &geometry );
//! Traverses tree and returns all nodes that intersects with a \a geometry in specified depth (if the geometry is null all nodes are considered)
QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, const QgsRenderContext &context, IndexedPointCloudNode n, float maxErrorPixels, float nodeErrorPixels, const QgsGeometry &geometry = QgsGeometry() );

QgsPointCloudLayer *mLayer = nullptr;

0 comments on commit 9ee8ec8

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