Program Listing for File LSROptionsYamlExtensions.hpp

Return to documentation for file (include/lvr2/config/LSROptionsYamlExtensions.hpp)

#ifndef LVR2_LSR_OPTIONS_YAML_EXTENSIONS
#define LVR2_LSR_OPTIONS_YAML_EXTENSIONS

#include <yaml-cpp/yaml.h>

#include "lvr2/reconstruction/LargeScaleReconstruction.hpp"

namespace YAML
{
template<>
struct convert<lvr2::LSROptions>
{
    static Node encode(const lvr2::LSROptions& options)
    {
        Node node;

        node["bigMesh"] = options.hasOutput(lvr2::LSROutput::BigMesh);
        node["debugChunks"] = options.hasOutput(lvr2::LSROutput::ChunksPly);
        node["useGPU"] = options.useGPU;
        node["voxelSizes"] = options.voxelSizes;
        node["bgVoxelSize"] = options.bgVoxelSize;
        node["scale"] = options.scale;
        node["nodeSize"] = options.nodeSize;
        node["partMethod"] = options.partMethod;
        node["ki"] = options.ki;
        node["kd"] = options.kd;
        node["kn"] = options.kn;
        node["flipPoint"] = options.flipPoint;
        node["useRansac"] = options.useRansac;
        node["extrude"] = options.extrude;
        node["removeDanglingArtifacts"] = options.removeDanglingArtifacts;
        node["cleanContours"] = options.cleanContours;
        node["fillHoles"] = options.fillHoles;
        node["optimizePlanes"] = options.optimizePlanes;
        node["planeNormalThreshold"] = options.planeNormalThreshold;
        node["planeIterations"] = options.planeIterations;
        node["minPlaneSize"] = options.minPlaneSize;
        node["smallRegionThreshold"] = options.smallRegionThreshold;
        node["retesselate"] = options.retesselate;
        node["lineFusionThreshold"] = options.lineFusionThreshold;

        return node;
    }

    static bool decode(const Node& node, lvr2::LSROptions& options)
    {
        if (!node.IsMap())
        {
            return false;
        }

        if (node["bigMesh"])
        {
            options.output.insert(lvr2::LSROutput::BigMesh);
        }

        if (node["debugChunks"])
        {
            options.output.insert(lvr2::LSROutput::ChunksPly);
        }

        if (node["useGPU"])
        {
            options.useGPU = node["useGPU"].as<bool>();
        }

        if (node["voxelSizes"])
        {
            options.voxelSizes = node["voxelSizes"].as<std::vector<float>>();
        }

        if (node["bgVoxelSize"])
        {
            options.bgVoxelSize = node["bgVoxelSize"].as<float>();
        }

        if (node["scale"])
        {
            options.scale = node["scale"].as<float>();
        }

        if (node["nodeSize"])
        {
            options.nodeSize = node["nodeSize"].as<uint>();
        }

        if (node["partMethod"])
        {
            options.partMethod = node["partMethod"].as<int>();
        }

        if (node["ki"])
        {
            options.ki = node["ki"].as<int>();
        }

        if (node["kd"])
        {
            options.kd = node["kd"].as<int>();
        }

        if (node["kn"])
        {
            options.kn = node["kn"].as<int>();
        }

        if (node["useRansac"])
        {
            options.useRansac = node["useRansac"].as<bool>();
        }

        if (node["flipPoint"])
        {
            options.flipPoint = node["flipPoint"].as<std::vector<float>>();
        }

        if (node["extrude"])
        {
            options.extrude = node["extrude"].as<bool>();
        }

        if (node["removeDanglingArtifacts"])
        {
            options.removeDanglingArtifacts = node["removeDanglingArtifacts"].as<int>();
        }

        if (node["cleanContours"])
        {
            options.cleanContours = node["cleanContours"].as<int>();
        }

        if (node["fillHoles"])
        {
            options.fillHoles = node["fillHoles"].as<int>();
        }

        if (node["optimizePlanes"])
        {
            options.optimizePlanes = node["optimizePlanes"].as<bool>();
        }

        if (node["planeNormalThreshold"])
        {
            options.planeNormalThreshold = node["planeNormalThreshold"].as<float>();
        }

        if (node["planeIterations"])
        {
            options.planeIterations = node["planeIterations"].as<int>();
        }

        if (node["minPlaneSize"])
        {
            options.minPlaneSize = node["minPlaneSize"].as<int>();
        }

        if (node["smallRegionThreshold"])
        {
            options.smallRegionThreshold = node["smallRegionThreshold"].as<int>();
        }

        if (node["retesselate"])
        {
            options.retesselate = node["retesselate"].as<bool>();
        }

        if (node["lineFusionThreshold"])
        {
            options.lineFusionThreshold = node["lineFusionThreshold"].as<float>();
        }

        return true;
    }
};
}  // namespace YAML

#endif