Skip to content
Permalink
Browse files

remove the use of QgsCustomPointCloudBlock

  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed May 4, 2021
1 parent 7a03571 commit d07a0b9a2974f09368d02f41670b3bb74e2a8f5b
@@ -28,7 +28,7 @@ Base class for storing raw data from point cloud nodes
public:
QgsPointCloudBlock( int count,
const QgsPointCloudAttributeCollection &attributes,
const QByteArray &data );
const QByteArray &data, const QgsVector3D &scale, const QgsVector3D &offset );
%Docstring
Ctor
%End
@@ -47,34 +47,6 @@ Returns number of points that are stored in the block
QgsPointCloudAttributeCollection attributes() const;
%Docstring
Returns the attributes that are stored in the data block, along with their size
%End

};


class QgsCustomPointCloudBlock : QgsPointCloudBlock
{
%Docstring(signature="appended")
Base class for storing raw data from point cloud nodes that have a custom scale and offset values

.. note::

The API is considered EXPERIMENTAL and can be changed without a notice

.. versionadded:: 3.20
%End

%TypeHeaderCode
#include "qgspointcloudblock.h"
%End
public:
QgsCustomPointCloudBlock( int count,
const QgsPointCloudAttributeCollection &attributes,
const QByteArray &data,
const QgsVector3D &scale,
const QgsVector3D &offset );
%Docstring
Ctor
%End

QgsVector3D scale() const;
@@ -88,6 +60,7 @@ Returns the custom offset of the block.
%End
};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -253,13 +253,8 @@ void QgsSingleColorPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *p
const char *ptr = block->data();
int count = block->pointCount();
const std::size_t recordSize = attributes.pointRecordSize();
QgsVector3D blockScale = pc->scale();
QgsVector3D blockOffset = pc->offset();
if ( QgsCustomPointCloudBlock *customBlock = dynamic_cast<QgsCustomPointCloudBlock *>( block.get() ) )
{
blockScale = customBlock->scale();
blockOffset = customBlock->offset();
}
const QgsVector3D blockScale = block->scale();
const QgsVector3D blockOffset = block->offset();
const double zValueScale = context.zValueScale();
const double zValueOffset = context.zValueFixedOffset();
QgsCoordinateTransform coordinateTransform = context.coordinateTransform();
@@ -382,13 +377,8 @@ void QgsColorRampPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc,
int count = block->pointCount();
const std::size_t recordSize = attributes.pointRecordSize();

QgsVector3D blockScale = pc->scale();
QgsVector3D blockOffset = pc->offset();
if ( QgsCustomPointCloudBlock *customBlock = dynamic_cast<QgsCustomPointCloudBlock *>( block.get() ) )
{
blockScale = customBlock->scale();
blockOffset = customBlock->offset();
}
const QgsVector3D blockScale = block->scale();
const QgsVector3D blockOffset = block->offset();

for ( int i = 0; i < count; ++i )
{
@@ -492,13 +482,8 @@ void QgsRGBPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc, const
int count = block->pointCount();
const std::size_t recordSize = attributes.pointRecordSize();

QgsVector3D blockScale = pc->scale();
QgsVector3D blockOffset = pc->offset();
if ( QgsCustomPointCloudBlock *customBlock = dynamic_cast<QgsCustomPointCloudBlock *>( block.get() ) )
{
blockScale = customBlock->scale();
blockOffset = customBlock->offset();
}
const QgsVector3D blockScale = block->scale();
const QgsVector3D blockOffset = block->offset();
const double zValueScale = context.zValueScale();
const double zValueOffset = context.zValueFixedOffset();
QgsCoordinateTransform coordinateTransform = context.coordinateTransform();
@@ -660,13 +645,8 @@ void QgsClassificationPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex
int count = block->pointCount();
const std::size_t recordSize = attributes.pointRecordSize();

QgsVector3D blockScale = pc->scale();
QgsVector3D blockOffset = pc->offset();
if ( QgsCustomPointCloudBlock *customBlock = dynamic_cast<QgsCustomPointCloudBlock *>( block.get() ) )
{
blockScale = customBlock->scale();
blockOffset = customBlock->offset();
}
const QgsVector3D blockScale = block->scale();
const QgsVector3D blockOffset = block->offset();
const double zValueScale = context.zValueScale();
const double zValueOffset = context.zValueFixedOffset();
QgsCoordinateTransform coordinateTransform = context.coordinateTransform();
@@ -157,13 +157,8 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event )
if ( !block )
continue;

QgsVector3D blockScale = index->scale();
QgsVector3D blockOffset = index->offset();
if ( QgsCustomPointCloudBlock *customBlock = dynamic_cast<QgsCustomPointCloudBlock *>( block.get() ) )
{
blockScale = customBlock->scale();
blockOffset = customBlock->offset();
}
const QgsVector3D blockScale = block->scale();
const QgsVector3D blockOffset = block->offset();

const char *ptr = block->data();
QgsPointCloudAttributeCollection blockAttributes = block->attributes();
@@ -131,7 +131,7 @@ bool _serialize( char *data, size_t outputPosition, QgsPointCloudAttribute::Data

// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

QgsPointCloudBlock *_decompressBinary( const QByteArray &dataUncompressed, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
QgsPointCloudBlock *_decompressBinary( const QByteArray &dataUncompressed, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset )
{
const std::size_t pointRecordSize = attributes.pointRecordSize( );
const std::size_t requestedPointRecordSize = requestedAttributes.pointRecordSize();
@@ -192,12 +192,11 @@ QgsPointCloudBlock *_decompressBinary( const QByteArray &dataUncompressed, const
return new QgsPointCloudBlock(
count,
requestedAttributes,
data
data, scale, offset
);
}


QgsPointCloudBlock *QgsEptDecoder::decompressBinary( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
QgsPointCloudBlock *QgsEptDecoder::decompressBinary( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset )
{
if ( ! QFile::exists( filename ) )
return nullptr;
@@ -208,12 +207,12 @@ QgsPointCloudBlock *QgsEptDecoder::decompressBinary( const QString &filename, co
return nullptr;

QByteArray dataUncompressed = f.read( f.size() );
return _decompressBinary( dataUncompressed, attributes, requestedAttributes );
return _decompressBinary( dataUncompressed, attributes, requestedAttributes, scale, offset );
}

QgsPointCloudBlock *QgsEptDecoder::decompressBinary( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
QgsPointCloudBlock *QgsEptDecoder::decompressBinary( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset )
{
return _decompressBinary( data, attributes, requestedAttributes );
return _decompressBinary( data, attributes, requestedAttributes, scale, offset );
}

/* *************************************************************************************** */
@@ -246,7 +245,7 @@ QByteArray decompressZtdStream( const QByteArray &dataCompressed )
return dataUncompressed;
}

QgsPointCloudBlock *QgsEptDecoder::decompressZStandard( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
QgsPointCloudBlock *QgsEptDecoder::decompressZStandard( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset )
{
if ( ! QFile::exists( filename ) )
return nullptr;
@@ -258,21 +257,23 @@ QgsPointCloudBlock *QgsEptDecoder::decompressZStandard( const QString &filename,

QByteArray dataCompressed = f.readAll();
QByteArray dataUncompressed = decompressZtdStream( dataCompressed );
return _decompressBinary( dataUncompressed, attributes, requestedAttributes );
return _decompressBinary( dataUncompressed, attributes, requestedAttributes, scale, offset );
}

QgsPointCloudBlock *QgsEptDecoder::decompressZStandard( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
QgsPointCloudBlock *QgsEptDecoder::decompressZStandard( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset )
{
QByteArray dataUncompressed = decompressZtdStream( data );
return _decompressBinary( dataUncompressed, attributes, requestedAttributes );
return _decompressBinary( dataUncompressed, attributes, requestedAttributes, scale, offset );
}

/* *************************************************************************************** */

template<typename FileType>
QgsPointCloudBlock *__decompressLaz( FileType &file, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
QgsPointCloudBlock *__decompressLaz( FileType &file, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &_scale, const QgsVector3D &_offset )
{
Q_UNUSED( attributes );
Q_UNUSED( _scale );
Q_UNUSED( _offset );

if ( ! file.good() )
return nullptr;
@@ -470,7 +471,7 @@ QgsPointCloudBlock *__decompressLaz( FileType &file, const QgsPointCloudAttribut
float t = common::since( start );
QgsDebugMsgLevel( QStringLiteral( "LAZ-PERF Read through the points in %1 seconds." ).arg( t ), 2 );
#endif
QgsCustomPointCloudBlock *block = new QgsCustomPointCloudBlock(
QgsPointCloudBlock *block = new QgsPointCloudBlock(
count,
requestedAttributes,
data, scale, offset
@@ -480,20 +481,22 @@ QgsPointCloudBlock *__decompressLaz( FileType &file, const QgsPointCloudAttribut

QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename,
const QgsPointCloudAttributeCollection &attributes,
const QgsPointCloudAttributeCollection &requestedAttributes )
const QgsPointCloudAttributeCollection &requestedAttributes,
const QgsVector3D &scale, const QgsVector3D &offset )
{
const QByteArray arr = filename.toUtf8();
std::ifstream file( arr.constData(), std::ios::binary );

return __decompressLaz<std::ifstream>( file, attributes, requestedAttributes );
return __decompressLaz<std::ifstream>( file, attributes, requestedAttributes, scale, offset );
}

QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QByteArray &byteArrayData,
const QgsPointCloudAttributeCollection &attributes,
const QgsPointCloudAttributeCollection &requestedAttributes )
const QgsPointCloudAttributeCollection &requestedAttributes,
const QgsVector3D &scale, const QgsVector3D &offset )
{
std::istringstream file( byteArrayData.toStdString() );
return __decompressLaz<std::istringstream>( file, attributes, requestedAttributes );
return __decompressLaz<std::istringstream>( file, attributes, requestedAttributes, scale, offset );
}

///@endcond
@@ -31,12 +31,12 @@

namespace QgsEptDecoder
{
QgsPointCloudBlock *decompressBinary( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressBinary( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressZStandard( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressZStandard( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressLaz( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressLaz( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes );
QgsPointCloudBlock *decompressBinary( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset );
QgsPointCloudBlock *decompressBinary( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset );
QgsPointCloudBlock *decompressZStandard( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset );
QgsPointCloudBlock *decompressZStandard( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset );
QgsPointCloudBlock *decompressLaz( const QString &filename, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset );
QgsPointCloudBlock *decompressLaz( const QByteArray &data, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes, const QgsVector3D &scale, const QgsVector3D &offset );
};

///@endcond
@@ -282,17 +282,17 @@ QgsPointCloudBlock *QgsEptPointCloudIndex::nodeData( const IndexedPointCloudNode
if ( mDataType == QLatin1String( "binary" ) )
{
QString filename = QStringLiteral( "%1/ept-data/%2.bin" ).arg( mDirectory, n.toString() );
return QgsEptDecoder::decompressBinary( filename, attributes(), request.attributes() );
return QgsEptDecoder::decompressBinary( filename, attributes(), request.attributes(), scale(), offset() );
}
else if ( mDataType == QLatin1String( "zstandard" ) )
{
QString filename = QStringLiteral( "%1/ept-data/%2.zst" ).arg( mDirectory, n.toString() );
return QgsEptDecoder::decompressZStandard( filename, attributes(), request.attributes() );
return QgsEptDecoder::decompressZStandard( filename, attributes(), request.attributes(), scale(), offset() );
}
else if ( mDataType == QLatin1String( "laszip" ) )
{
QString filename = QStringLiteral( "%1/ept-data/%2.laz" ).arg( mDirectory, n.toString() );
return QgsEptDecoder::decompressLaz( filename, attributes(), request.attributes() );
return QgsEptDecoder::decompressLaz( filename, attributes(), request.attributes(), scale(), offset() );
}
else
{
@@ -23,11 +23,13 @@
QgsPointCloudBlock::QgsPointCloudBlock(
int count,
const QgsPointCloudAttributeCollection &attributes,
const QByteArray &data
const QByteArray &data, const QgsVector3D &scale, const QgsVector3D &offset
)
: mPointCount( count )
, mAttributes( attributes )
, mStorage( data )
, mScale( scale )
, mOffset( offset )
{
}

@@ -46,12 +48,12 @@ QgsPointCloudAttributeCollection QgsPointCloudBlock::attributes() const
return mAttributes;
}

// QgsCustomPointCloudBlock
QgsVector3D QgsPointCloudBlock::scale() const
{
return mScale;
}

QgsCustomPointCloudBlock::QgsCustomPointCloudBlock( int count,
const QgsPointCloudAttributeCollection &attributes,
const QByteArray &data,
const QgsVector3D &scale,
const QgsVector3D &offset ) : QgsPointCloudBlock( count, attributes, data ), mScale( scale ), mOffset( offset )
QgsVector3D QgsPointCloudBlock::offset() const
{
return mOffset;
}
@@ -41,7 +41,7 @@ class CORE_EXPORT QgsPointCloudBlock
//! Ctor
QgsPointCloudBlock( int count,
const QgsPointCloudAttributeCollection &attributes,
const QByteArray &data );
const QByteArray &data, const QgsVector3D &scale, const QgsVector3D &offset );
//! Dtor
virtual ~QgsPointCloudBlock() = default;

@@ -54,39 +54,17 @@ class CORE_EXPORT QgsPointCloudBlock
//! Returns the attributes that are stored in the data block, along with their size
QgsPointCloudAttributeCollection attributes() const;

private:
int mPointCount;
QgsPointCloudAttributeCollection mAttributes;
QByteArray mStorage;
};


/**
* \ingroup core
* \brief Base class for storing raw data from point cloud nodes that have a custom scale and offset values
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
*
* \since QGIS 3.20
*/
class CORE_EXPORT QgsCustomPointCloudBlock : public QgsPointCloudBlock
{
public:
//! Ctor
QgsCustomPointCloudBlock( int count,
const QgsPointCloudAttributeCollection &attributes,
const QByteArray &data,
const QgsVector3D &scale,
const QgsVector3D &offset );

//! Returns the custom scale of the block.
QgsVector3D scale() const { return mScale; }
QgsVector3D scale() const;

//! Returns the custom offset of the block.
QgsVector3D offset() const { return mOffset; }
QgsVector3D offset() const;
private:
int mPointCount;
QgsPointCloudAttributeCollection mAttributes;
QByteArray mStorage;
QgsVector3D mScale, mOffset;

};


#endif // QGSPOINTCLOUDBLOCK_H

0 comments on commit d07a0b9

Please sign in to comment.