# class cogs::DynamicScan

## Overview

Scan able to change and remember its current transformation. More…

    #include <DynamicScan.h>

    class DynamicScan: public cogs::Scan {
    public:
        // construction

        DynamicScan();
        DynamicScan(const DynamicScan& source);
        DynamicScan(DynamicScan&&);
        ~DynamicScan();

        // methods

        DynamicScan& operator=(const DynamicScan& source);
        DynamicScan& operator=(DynamicScan&&);
        virtual void Transform(const glm::mat4& transformation, const std::optional<utils::SpaceDefinition>& resulting_space = std::nullopt);
        const glm::mat4& GetCurrentTransform() const;
        void RevertTransformations();
        void ResetTransform();
    };

### Inherited Members

    public:
        // typedefs

        typedef std::function<bool(const glm::vec3&, const glm::vec3&)> PointNormalPredicate;
        typedef glm::uvec2 Coords;

        // structs

        struct Chunk;
        struct CopyCommand;

        // fields

        static const cogs::PointCloudProperty::Key POSITIONS;
        static const cogs::PointCloudProperty::Key NORMALS;
        static const cogs::PointCloudProperty::Key COLORS;
        static const cogs::PointCloudProperty::Key UVS;
        static const cogs::PointCloudProperty::Key INTENSITIES;
        static const glm::vec3 CAMERA_SPACE_FORWARD;
        static const glm::vec3 CAMERA_SPACE_UP;
        static const glm::vec3 CAMERA_SPACE_RIGHT;
        static const uint32_t INVALID_INDEX;

        // methods

        PointCloud& operator=(const PointCloud& source);
        PointCloud& operator=(PointCloud&&);
        virtual bool Import(const std::string& filename);
        virtual bool Export(const std::string& filename) const;
        virtual bool Resize(uint32_t new_size);
        virtual uint32_t GetSize() const;
        virtual void Reserve(uint32_t new_capacity);
        uint32_t GetCapacity() const;
        virtual void ShrinkToFit();
        virtual void Clear();
        virtual bool Erase(std::vector<uint32_t> indices_to_erase, std::vector<int>* replacement_map = nullptr);
        virtual bool Erase(const PointNormalPredicate& Predicate, std::vector<int>* replacement_map = nullptr);
        virtual bool Append(const PointCloud& pc);
        glm::vec3* GetPositions();
        const glm::vec3* GetPositions() const;
        bool HasNormals() const;
        glm::vec3* GetNormals();
        const glm::vec3* GetNormals() const;
        const PointCloudProperty& AddNormals();
        bool HasColors() const;
        struct Color3f* GetColors();
        const struct Color3f* GetColors() const;
        const PointCloudProperty& AddColors();
        bool HasIntensities() const;
        float* GetIntensities();
        const float* GetIntensities() const;
        const PointCloudProperty& AddIntensities();
        const std::vector<PointCloudProperty>& GetProperties() const;
        const PointCloudProperty& AddProperty(const PointCloudProperty::Key& key, DataType type);
        const PointCloudProperty& AddProperty(const PointCloudProperty::Key& key, size_t bytes_per_point);
        void RemoveProperty(const PointCloudProperty::Key& key);
        void ClonePropertiesOf(const PointCloud& pc);
        bool HasProperty(const PointCloudProperty::Key& key) const;
        std::optional<PointCloudProperty> GetProperty(const PointCloudProperty::Key& key);
        std::optional<const PointCloudProperty> GetProperty(const PointCloudProperty::Key& key) const;
        virtual void* GetVoidData(const PointCloudProperty::Key& key);
        const void* GetVoidData(const PointCloudProperty::Key& key) const;

        template <typename T>
        T* GetData(const PointCloudProperty::Key& key);

        template <typename T>
        const T* GetData(const PointCloudProperty::Key& key) const;

        virtual void Transform(const glm::mat4& transformation, const std::optional<utils::SpaceDefinition>& resulting_space = std::nullopt);
        bool HasSpace() const;
        const std::optional<utils::SpaceDefinition>& GetSpace() const;
        std::string GetSpaceId() const;
        void SetSpace(const std::optional<utils::SpaceDefinition>& new_space);
        bool TransformToSpace(const utils::SpaceDefinition& new_space);
        Scan& operator=(const Scan& source);
        Scan& operator=(Scan&&);
        virtual bool Import(const std::string& filename);
        virtual bool Export(const std::string& filename) const;
        virtual void Reserve(uint32_t new_capacity);
        virtual void ShrinkToFit();
        virtual void Clear();
        virtual void ClonePropertiesOf(const cogs::Scan& scan);
        void SetResolution(const glm::uvec2& new_resolution);
        glm::uvec2 GetResolution() const;
        uint32_t GetWidth() const;
        uint32_t GetHeight() const;
        void SetCameraParams(const ScanCameraParams& new_params);
        const ScanCameraParams& GetCameraParams() const;
        void SetCameraPosition(const glm::vec3& new_position);
        const glm::vec3& GetCameraPosition() const;
        void SetCameraBasis(const glm::mat3& new_basis, const utils::BasisDefinition& basis_def);
        glm::mat3 GetCameraBasis(const utils::BasisDefinition& basis_def) const;
        glm::vec3 GetCameraForward() const;
        glm::vec3 GetCameraUp() const;
        utils::BasisDefinition GetCameraBasisDefinition() const;
        void ChangeCameraBasisDefinition(const utils::BasisDefinition& new_def);
        std::string GetCameraBasisDefinitionId() const;
        const std::vector<Coords>& GetCoords() const;
        bool IsPointAt(const glm::uvec2& coord) const;
        bool IsPointAt(const uint32_t x_coord, const uint32_t y_coord) const;
        uint32_t AddPointAt(const glm::uvec2& coord);
        uint32_t AddPointAt(const uint32_t x_coord, const uint32_t y_coord);
        uint32_t AddPointsAt(const std::vector<glm::uvec2>& new_coords);
        uint32_t GetPointAt(const glm::uvec2& coord) const;
        uint32_t GetPointAt(const uint32_t x_coord, const uint32_t y_coord) const;
        virtual void Transform(const glm::mat4& transformation, const std::optional<utils::SpaceDefinition>& resulting_space = std::nullopt);
        std::optional<double> GetTimestamp() const;
        void SetTimestamp(std::optional<double> timestamp);
        static bool GetCameraUV(const glm::vec3& point, const ScanCameraParams& cam_params, glm::vec2& result);
        static std::vector<std::vector<float>> ComputeDepthMap(const cogs::Scan& scan);
        static std::vector<std::vector<float>> ComputeDepthMap(const cogs::Scan& scan, const glm::vec3& camera_position);
        static std::vector<std::vector<uint32_t>> ComputeIndexMap(const cogs::Scan& scan);

    protected:
        // methods

        void MakeCloneOf(const PointCloud& source);
        virtual void ExecuteCopyCommands(const std::vector<CopyCommand>& copy_info);
        virtual void TruncateSize(size_t delta_size);
        void MakeCloneOf(const Scan& source);
        virtual void TruncateSize(size_t delta_size);

## Detailed Documentation

Scan able to change and remember its current transformation.

### Construction

    DynamicScan()

Creates a new scan with zero resolution and no points.

    DynamicScan(const DynamicScan& source)

Make a deep copy of the source Scan.

    DynamicScan(DynamicScan&&)

Move-construct Scan.

    ~DynamicScan()

Destroys cloud, frees all property data and destroys grid.

### Methods

    DynamicScan& operator=(const DynamicScan& source)

Make a deep copy of the source Scan.

    DynamicScan& operator=(DynamicScan&&)

Move-construct Scan.

    virtual void Transform(const glm::mat4& transformation, const std::optional<utils::SpaceDefinition>& resulting_space = std::nullopt)

Transforms point positions and normals and camera parameters.

Parameters:

transformation | Transformation matrix applied on every point and camera parameter.
resulting_space | Resulting point cloud space after the transformation is applied.

    const glm::mat4& GetCurrentTransform() const

Returns cumulative transformation applied to scan from creation.

    void RevertTransformations()

Resets scan to its previous state and current transformation to identity.

    void ResetTransform()

Sets transformation to identity, but keep point cloud transformed as is.