22QgsQuadtreeChunkLoaderFactory::QgsQuadtreeChunkLoaderFactory() =
default;
24QgsQuadtreeChunkLoaderFactory::~QgsQuadtreeChunkLoaderFactory() =
default;
26void QgsQuadtreeChunkLoaderFactory::setupQuadtree(
const QgsAABB &rootBbox,
float rootError,
int maxLevel,
const QgsAABB &clippingBbox )
29 mRootError = rootError;
31 mClippingBbox = clippingBbox;
34QgsChunkNode *QgsQuadtreeChunkLoaderFactory::createRootNode()
const
36 return new QgsChunkNode( QgsChunkNodeId( 0, 0, 0 ), mRootBbox, mRootError );
39QVector<QgsChunkNode *> QgsQuadtreeChunkLoaderFactory::createChildren( QgsChunkNode *node )
const
41 QVector<QgsChunkNode *> children;
43 if ( node->level() >= mMaxLevel )
46 const QgsChunkNodeId nodeId = node->tileId();
47 const float childError = node->error() / 2;
48 const QgsAABB bbox = node->bbox();
51 for (
int i = 0; i < 4; ++i )
53 int dx = i & 1, dy = !!( i & 2 );
54 const QgsChunkNodeId childId( nodeId.d + 1, nodeId.x * 2 + dx, nodeId.y * 2 + ( dy ? 0 : 1 ) );
58 const float chXMin = dx ? xc : bbox.
xMin;
59 const float chXMax = dx ? bbox.
xMax : xc;
60 const float chZMin = dy ? zc : bbox.
zMin;
61 const float chZMax = dy ? bbox.
zMax : zc;
62 const float chYMin = bbox.
yMin;
63 const float chYMax = bbox.
yMax;
64 const QgsAABB childBbox =
QgsAABB( chXMin, chYMin, chZMin, chXMax, chYMax, chZMax );
65 if ( mClippingBbox.isEmpty() || childBbox.
intersects( mClippingBbox ) )
66 children <<
new QgsChunkNode( childId, childBbox, childError, node );
float xCenter() const
Returns center in X axis.
bool intersects(const QgsAABB &other) const
Determines whether the box intersects some other axis aligned box.
float zCenter() const
Returns center in Z axis.