大数据点云可视化
当前使用entwin和potreeConverter转换的ept格式文件,后续增加copc格式及ArcGIS i3s格式,这几个格式都可是直接使用pdal进行读取,有时间的话写详细教程。
核心类接口 :
/// @class PointCloudEptGeometry
/// @brief 点云数据模型
/// @note
class DATA_EXPORT PointCloudEptGeometry :public lxCore::IReadable, public IPointCloudGeometry
{
META_INHERIT_CLASS(PointCloudEptGeometry, lxCore::IReadable)
public:
using Vec3 = lxCore::vec3;
using Ptr = lxCore::ref_ptr<PointCloudEptGeometry>;
enum AccessType
{
Local,
Remote,
};
/// @brief -
/// @param[in] -
/// @param[out] -
/// @return
PointCloudEptGeometry();
/// @brief -
/// @param[in] -
/// @param[out] -
/// @return
~PointCloudEptGeometry();
/// @brief -
/// @param[in] -
/// @param[out] -
/// @return
virtual void load();
/// @brief -
/// @param[in] -
/// @param[out] -
/// @return
bool isLoaded();
virtual PointBlock* loadNode(const VoxelKey& key);
VoxelKey root() { return VoxelKey(0, 0, 0, 0); }
std::list<VoxelKey> children(const VoxelKey& voxel)const;
bool hasNode(const VoxelKey& key) const;
Bounds computeBounds(VoxelKey& key)const;
const std::map<VoxelKey, int>& hierarchy()const;
public:
int maxLeavel()const;
int startLeavel()const;
float spacing()const;
void setScale(const Vec3& scale);
Vec3 scale()const;
void setOffset(const Vec3& offset);
Vec3 offset()const;
int span()const;
void setSpan(int span);
void setBounds(const Bounds& bounds);
Bounds bounds()const;
Bounds tightBounds()const;
void setPointCount(int count);
int64_t pointCount()const;
void print();
private:
bool loadSchema(const QByteArray& dataJson);
bool loadManifest(const QByteArray& manifestJson);
bool loadHierarchy();
void setAttributes(const PointAttributes& attributes);
private:
bool _loaded;
std::string _directory;
mutable std::mutex _hierarchyMutex;
mutable std::map<VoxelKey, int> _hierarchy;
std::string _dataType; ///<
std::string _wkt;
int _maxLeveal;
Bounds _bounds;
Bounds _boundsConforming;
Vec3 _scale;
Vec3 _offset;
int _span;
int64_t _pointCount;
PointAttributes _attributes;
struct AttributeStatistics
{
int count = -1;
double minimum;
double maximum;
double mean = std::numeric_limits< double >::quiet_NaN();
double stDev = std::numeric_limits< double >::quiet_NaN();
double variance = std::numeric_limits< double >::quiet_NaN();
};
std::unordered_map<std::string, AttributeStatistics> _metadataStats;
std::unordered_map<std::string, std::unordered_map< int, int > > _attributeClasses;
QVariantMap _originalMetadata;
};
/// @class PointCloudLodNode
/// @brief 绘制节点
/// @note
class GRAPHICS_EXPORT PointCloudLodNode :public osg::Geode
{
public:
using Vec3 = lxData::PointCloudEptGeometry::Vec3;
PointCloudLodNode();
PointCloudLodNode(lxCore::ref_ptr<lxData::PointCloudEptGeometry> cloud);
~PointCloudLodNode();
virtual lxCore::ref_ptr<lxData::PointCloudEptGeometry> pcoGeometry();
virtual void setPCOGeometry(lxCore::ref_ptr<lxData::PointCloudEptGeometry> pco);
virtual bool addVoxel(osg::ref_ptr<VoxelGeometry> voxel);
virtual osg::ref_ptr<VoxelGeometry> addVoxel(const VoxelGeometry::VoxelKey& key);
virtual bool removeVoxel(osg::ref_ptr<VoxelGeometry> voxel);
virtual bool removeVoxel(const VoxelGeometry::VoxelKey& key);
virtual void clearVoxels();
public:
void setElevationRange(float minz, float maxz);
protected:
void inilize();
protected:
lxCore::ref_ptr<lxData::PointCloudEptGeometry> _pcoGeometry;
bool _showBoundingBox;
typedef std::vector<osg::ref_ptr<VoxelGeometry>> VoxelGeometrys;
VoxelGeometrys _voxels;
osg::ref_ptr<lxGraphic::BoxGeometry> _boxGeometry;
osg::ref_ptr<osg::StateSet> _stateset;
osg::ref_ptr<osg::Program> _shaderProgram;
osg::ref_ptr<osg::Texture2D> _gradientTex;
std::string _currentColorDef;
};