osg+pdal大数据点云的LOD可视化

                

大数据点云可视化

       当前使用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;
    };

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值