class cogs::Scan — HIRO 0.7.0 documentation

# class cogs::Scan

## Overview

Set of 3D data points which are additionally organized over 2D grid. More…

    #include <Scan.h>

    class Scan: public cogs::PointCloud {
    public:
        // typedefs

        typedef glm::uvec2 Coords;

        // fields

        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;

        // construction

        Scan();
        Scan(const Scan& source);
        Scan(Scan&&);
        ~Scan();

        // methods

        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 Scan& source);
        virtual void TruncateSize(size_t delta_size);
    };

### Inherited Members

    public:
        // typedefs

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

        // 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;

        // 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);

    protected:
        // methods

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

## Detailed Documentation

Set of 3D data points which are additionally organized over 2D grid.

Class extends PointCloud by holding point indices in 2D grid. Adding of new points must be done strictly through grid so that each point has a valid grid coordinate.

### Typedefs

    typedef glm::uvec2 Coords

Type of point Coordinates.

### Fields

    static const uint32_t INVALID_INDEX

Index which is never assigned to any point. Indicates invalid points.

### Construction

    Scan()

Creates a new scan with zero resolution and no points.

    Scan(const Scan& source)

Make a deep copy of the source Scan.

    Scan(Scan&&)

Move-construct Scan.

    ~Scan()

Destroys cloud, frees all property data and destroys grid.

### Methods

    Scan& operator=(const Scan& source)

Make a deep copy of the source Scan.

    Scan& operator=(Scan&&)

Move-construct Scan.

    virtual bool Import(const std::string& filename)

Imports scan from a file.

    virtual bool Export(const std::string& filename) const

Exports scan to a file.

    virtual void Reserve(uint32_t new_capacity)

Changes capacity of cloud. This method is not adding any points.

    virtual void ShrinkToFit()

Frees spare memory so that new capacity exactly matches size.

    virtual void Clear()

Removes all points from cloud.

    virtual void ClonePropertiesOf(const cogs::Scan& scan)

Calls PointCloud::ClonePropertiesOf and additionally copies resolution and camera parameters.

    void SetResolution(const glm::uvec2& new_resolution)

Changes grid resolution new grid points are empty and old points may be erased.

Camera parameters remain unchanged.

    glm::uvec2 GetResolution() const

Returns current grid resolution.

    uint32_t GetWidth() const

Returns current grid width.

    uint32_t GetHeight() const

Returns current grid height.

    void SetCameraParams(const ScanCameraParams& new_params)

Sets camera parameters to the new value.

    const ScanCameraParams& GetCameraParams() const

Returns currently set camera parameters.

    void SetCameraPosition(const glm::vec3& new_position)

Sets camera position to the new value.

    const glm::vec3& GetCameraPosition() const

Returns currently set camera position.

    void SetCameraBasis(const glm::mat3& new_basis, const utils::BasisDefinition& basis_def)

Sets camera basis to the new value.

    glm::mat3 GetCameraBasis(const utils::BasisDefinition& basis_def) const

Returns currently set camera basis in the specified basis definition.

    glm::vec3 GetCameraForward() const

Returns camera forward direction.

    glm::vec3 GetCameraUp() const

Returns camera up direction.

    utils::BasisDefinition GetCameraBasisDefinition() const

Returns current camera basis definition.

    void ChangeCameraBasisDefinition(const utils::BasisDefinition& new_def)

Changes camera basis definition and transforms internal camera basis to the new one.

    std::string GetCameraBasisDefinitionId() const

Returns string representation of current camera basis definition.

    const std::vector<Coords>& GetCoords() const

Returns points coordinates.

    bool IsPointAt(const glm::uvec2& coord) const

Checks whether the coordinates are valid and occupied by a point.

    bool IsPointAt(const uint32_t x_coord, const uint32_t y_coord) const

Checks whether the coordinates are valid and occupied by a point.

    uint32_t AddPointAt(const glm::uvec2& coord)

Adds new point at grid coordinate. Returns point index.

    uint32_t AddPointAt(const uint32_t x_coord, const uint32_t y_coord)

Adds new point at grid coordinate. Returns point index.

    uint32_t AddPointsAt(const std::vector<glm::uvec2>& new_coords)

Adds a vector of new points at grid coordinates. Returns starting point index.

    uint32_t GetPointAt(const glm::uvec2& coord) const

Returns point index at grid coordinate. May return Scan::INVALID_INDEX if there is no point.

    uint32_t GetPointAt(const uint32_t x_coord, const uint32_t y_coord) const

Returns point index at grid coordinate. May return Scan::INVALID_INDEX if there is no point.

    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.

    std::optional<double> GetTimestamp() const

Returns optional timestamp (milliseconds between device connection and scan capture).

    void SetTimestamp(std::optional<double> timestamp)

Set custom synthetic timestamp in milliseconds.

    static bool GetCameraUV(const glm::vec3& point, const ScanCameraParams& cam_params, glm::vec2& result)

Returns coordinate for given point.

    static std::vector<std::vector<float>> ComputeDepthMap(const cogs::Scan& scan)

Computes depth map from scan.

    static std::vector<std::vector<float>> ComputeDepthMap(const cogs::Scan& scan, const glm::vec3& camera_position)

Computes depth map from scan and custom camera position.

    static std::vector<std::vector<uint32_t>> ComputeIndexMap(const cogs::Scan& scan)

Computes map of point indices from scan.

    void MakeCloneOf(const Scan& source)

Deep-clone source Scan.

    virtual void TruncateSize(size_t delta_size)

Decreases cloud size by the specified number of points.