# class cogs::Importer

## Overview

Universal file importer for COGS structures. More…

    #include <Importer.h>

    class Importer {
    public:
        // construction

        Importer();
        Importer(const std::string& filename);
        Importer(const Importer& other);
        Importer(const Importer&& other);
        ~Importer();

        // methods

        Importer& operator=(const Importer& other);
        Importer& operator=(const Importer&& other);
        bool LoadFile(const std::string& filename);
        void CloseFile();
        size_t GetPointCloudCount() const;
        bool GetPointCloud(cogs::PointCloud& out_cloud, size_t id = 0) const;
        size_t GetScanCount() const;
        bool GetScan(cogs::Scan& out_scan, size_t id = 0) const;
        size_t GetMeshCount() const;
        bool GetMesh(cogs::Mesh& out_meshmodel, size_t id = 0) const;
        std::vector<cogs::Mesh> GetAllMeshes() const;
        std::vector<std::string> GetMeshNames() const;
        bool GetMeshByName(const std::string& name, cogs::Mesh& out_meshmodel) const;
        uint32_t GetSkeletonCount() const;
        bool GetSkeleton(cogs::Skeleton& out_skeleton, size_t id = 0) const;
        std::vector<std::string> GetSkeletonNames() const;
        bool GetSkeletonByName(const std::string& name, cogs::Skeleton& out_skeleton) const;
        bool GetArmature(cogs::Armature& out_armature) const;
        bool GetAllSkeletonActions(std::vector<cogs::SkeletonAction>& out_actions) const;
        bool GetAllSkeletonActions(const std::string& skeleton_name, std::vector<cogs::SkeletonAction>& out_actions) const;
        bool GetSkeletonActionByName(const std::string& skeleton_name, const std::string& action_name, cogs::SkeletonAction& out_action) const;
    };

## Detailed Documentation

Universal file importer for COGS structures.

Supports all COGS file extensions which can be found in cogs-file-format-extensions.

Internally uses Assimp library which supports common data formats found in http://assimp.sourceforge.net/main_features_formats.html. However, compatibility is not guaranteed for all file formats.

Assimp import was tested on the following file formats:

- Wavefront (.obj)

- Autodesk Filmbox (.fbx)

- COLLADA (.dae)

- Biovision Hierarchy (.bvh)

### Methods

    bool LoadFile(const std::string& filename)

Loads the file. When the file is COGS file, it remains open. Returns success.

    void CloseFile()

When loaded file was in COGS file format, closes it. Otherwise, does nothing.

    size_t GetPointCloudCount() const

Returns number of point clouds contained in a loaded file.

    bool GetPointCloud(cogs::PointCloud& out_cloud, size_t id = 0) const

Requests point cloud structure from the loaded file.

Parameters:

out_cloud | Object, to which should data be loaded.
id | Index of object in the file when there are more of the same type.

Returns:

Whether load finished successfully, and output is valid.

    size_t GetScanCount() const

Returns number of scans contained in a loaded file.

    bool GetScan(cogs::Scan& out_scan, size_t id = 0) const

Requests scan structure from the loaded file.

Parameters:

out_scan | Object, to which should data be loaded.
id | Index of object in the file when there are more of the same type.

Returns:

Whether load finished successfully, and output is valid.

    size_t GetMeshCount() const

Returns number of meshes contained in a loaded file.

    bool GetMesh(cogs::Mesh& out_meshmodel, size_t id = 0) const

Requests mesh structure from the loaded file.

Parameters:

out_meshmodel | Object, to which should data be loaded.
id | Index of object in the file when there are more of the same type.

Returns:

Whether load finished successfully, and output is valid.

    std::vector<cogs::Mesh> GetAllMeshes() const

Returns all meshes from the loaded file.

    std::vector<std::string> GetMeshNames() const

Returns names of all loaded meshes. Not supported by cogs files.

    bool GetMeshByName(const std::string& name, cogs::Mesh& out_meshmodel) const

Finds and requests mesh structure from the loaded file.

Parameters:

out_meshmodel | Object, to which should data be loaded.
name | Name identifier of an object.

Returns:

Whether load finished successfully, and output is valid.

    uint32_t GetSkeletonCount() const

Returns number of skeletons contained in a loaded file.

    bool GetSkeleton(cogs::Skeleton& out_skeleton, size_t id = 0) const

Requests skeleton structure from the loaded file.

Parameters:

out_skeleton | Object, to which should data be loaded.
id | Index of object in the file when there are more of the same type.

Returns:

Whether load finished successfully, and output is valid.

    std::vector<std::string> GetSkeletonNames() const

Returns names of all loaded skeletons. Not supported by cogs files.

    bool GetSkeletonByName(const std::string& name, cogs::Skeleton& out_skeleton) const

Finds and requests mesh structure from the loaded file.

Parameters:

out_skeleton | Object, to which should data be loaded.
name | Name identifier of an object to find.

Returns:

Whether load finished successfully, and output is valid.

    bool GetArmature(cogs::Armature& out_armature) const

Requests armature structure from the loaded file.

Parameters:

out_armature | Object, to which should data be loaded.
id | Index of object in the file when there are more of the same type.

Returns:

Whether load finished successfully, and output is valid.

    bool GetAllSkeletonActions(std::vector<cogs::SkeletonAction>& out_actions) const

Requests all skeleton actions from the loaded file.

Parameters:

out_actions | Array in which output should be stored.

Returns:

Whether load finished successfully, and output is valid.

    bool GetAllSkeletonActions(const std::string& skeleton_name, std::vector<cogs::SkeletonAction>& out_actions) const

Requests all skeleton actions from the loaded file, compatible with specific skeleton.

Parameters:

skeleton_name | Name of skeleton object, actions should be compatible with.
out_actions | Array in which output should be stored.

Returns:

Whether load finished successfully, and output is valid.

    bool GetSkeletonActionByName(const std::string& skeleton_name, const std::string& action_name, cogs::SkeletonAction& out_action) const

Requests a skeleton action from the loaded file, compatible with specific skeleton.

Parameters:

skeleton_name | Name of skeleton object, actions should be compatible with.
action_name | Name of the requested action.
out_actions | Object, to which should data be loaded.

Returns:

Whether load finished successfully, and output is valid.