#ifndef GENERAL_CONFIG_H
#define GENERAL_CONFIG_H

#include "Base_config.h"
#include "Gender.h"

namespace p2c
{

struct General_config : Base_config
{
    std::string fn_result;
    std::string fn_folder_fieldliner;

    bool b_adjust_eye_and_teeth_luminance;
    bool b_icspace_retargeting;
    bool b_convert_skeleton;
    bool b_hidewindow;
    bool b_graph_cut_texture;
    bool b_adjust_iris_color;
    bool b_left_hand;
    bool b_with_subsampling;
    bool b_write_full_avatar_in_scanpose;
    bool b_use_dualquaternion_skinning;
    bool b_disable_normal_pruning;
    bool b_get_scale_from_pointset;
    bool b_write_invtrans_even_if_not_textured;
    bool b_smooth_heel_after_pca;
    bool b_stop_after_landmark_selection;

    double dbl_result_height;
    double dbl_result_scaling;

    config::Gender gender;

public:
    General_config () :
        fn_folder_fieldliner(""),
        b_icspace_retargeting(false),
        b_convert_skeleton(false),
        b_hidewindow(false),
        b_graph_cut_texture(false),
        b_adjust_iris_color(false),
        b_left_hand(false),
        b_with_subsampling(true),
        b_write_full_avatar_in_scanpose(false),
        b_use_dualquaternion_skinning(false),
        b_disable_normal_pruning(false),
        b_get_scale_from_pointset(false),
        b_write_invtrans_even_if_not_textured(true),
        b_smooth_heel_after_pca(false),
        b_stop_after_landmark_selection(false),
        dbl_result_height(1.80),
        gender(config::GENDER_UNSPECIFIED)

    {}

    void init(const std::vector<std::string>& argv, std::map<std::string, std::string>& data)
    {
        for (size_t i = 0; i < argv.size(); ++i)
        {
            if (argv[i] == "-o" && argv.size() > i+1)
            {
                fn_result = argv[i+1];
            }
            else if (argv[i] == "-l")
            {
                b_left_hand = true;
            }
            else if (argv[i] == "-r")
            {
                b_left_hand = false;
            }
            else if (argv[i] == "-s" && argv.size() > i+1)
            {
                std::stringstream ss(argv[i+1]);
                ss >> dbl_result_scaling;
            }
            else if (argv[i] == "-h" && argv.size() > i+1)
            {
                std::stringstream ss(argv[i+1]);
                ss >> dbl_result_height;
            }
            else if (argv[i] == "-g" && argv.size() > i+1)
            {
                std::string gender_arg = argv[i+1];
                if (gender_arg == "Male")   gender = config::GENDER_MALE;
                if (gender_arg == "Female") gender = config::GENDER_FEMALE;
            }
            else if (argv[i] == "--hidewindow")
            {
                b_hidewindow = true;
            }
            else if (argv[i] == "--stop_after_landmark_selection")
            {
                b_stop_after_landmark_selection = true;
            }
        }

        find_key(data, "fn_folder_fieldliner", fn_folder_fieldliner);

        find_key(data, "b_adjust_eye_and_teeth_luminance", b_adjust_eye_and_teeth_luminance);
        find_key(data, "b_icspace_retargeting", b_icspace_retargeting);
        find_key(data, "b_convert_skeleton", b_convert_skeleton);
        find_key(data, "b_graph_cut_texture", b_graph_cut_texture);
        find_key(data, "b_adjust_iris_color", b_adjust_iris_color);
        find_key(data, "b_with_subsampling", b_with_subsampling);
        find_key(data, "b_write_full_avatar_in_scanpose", b_write_full_avatar_in_scanpose);
        find_key(data, "b_use_dualquaternion_skinning", b_use_dualquaternion_skinning);
        find_key(data, "b_disable_normal_pruning", b_disable_normal_pruning);
        find_key(data, "b_get_scale_from_pointset", b_get_scale_from_pointset);
        find_key(data, "b_write_invtrans_even_if_not_textured", b_write_invtrans_even_if_not_textured);
        find_key(data, "b_smooth_heel_after_pca", b_smooth_heel_after_pca);

    }
};

}

#endif
