#ifndef BODY_CONFIG_H
#define BODY_CONFIG_H

#include "Base_config.h"

namespace p2c
{

struct Body_config : public Base_config
{
    std::string dir_project;
    std::string fn_pointset;
    std::string fn_landmarks;
    std::string fn_landmark_validity;
    std::string fn_invtrans_mesh;
    std::string fn_invtrans_final_mesh;
    std::string fn_pose;
    std::string fn_metashape_project;
    std::string fn_texture;
    std::string fn_normal_map;
    std::string fn_ao_map;
    std::string fn_roughness_map;
    std::string fn_openpose_keypoint_folder;
    std::string fn_cameras;
    std::string fn_apple_mesh;
    std::string fn_apple_rgb;
    std::string fn_apple_nm;
    std::string fn_apple_ao;
    std::string fn_apple_roughness;


    bool b_landmarks_only_before_finefit;
    bool b_textured;
    bool b_provide_texture_manually;
    bool b_repair_hand_texture;
    bool b_repair_armpit_texture;
    bool b_replace_floor_plane;
    bool b_openpose_landmarks;
    bool b_inspect_detected_landmarks;
    bool b_write_invtrans_even_if_not_textured;
    bool b_check_for_normal_flip_on_load;
    bool b_use_cpc_for_ik;
    bool b_has_body_scan;

    int int_detail_level;

    double dbl_mouth_shut_weight;
    double dbl_landmark_weight_multiplier;
    double dbl_posefit_lambda;
    double dbl_landmark_weight_ik;

    Body_config() :
        b_landmarks_only_before_finefit(true),
        b_textured(true),
        b_provide_texture_manually(false),
        b_repair_hand_texture(true),
        b_repair_armpit_texture(true),
        b_replace_floor_plane(true),
        b_openpose_landmarks(false),
        b_inspect_detected_landmarks(true),
        b_write_invtrans_even_if_not_textured(false),
        b_check_for_normal_flip_on_load(false),
        b_use_cpc_for_ik(true),
        b_has_body_scan(false),
        int_detail_level(2),
        dbl_mouth_shut_weight(0.0),
        dbl_landmark_weight_multiplier(0.6),
        dbl_posefit_lambda(1.0),
        dbl_landmark_weight_ik(1.0)
    {}

    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] == "-b" && argv.size() > i+1)
            {
                dir_project = argv[i+1];
                if (dir_project.back() != '/')
                    dir_project.push_back('/');

                b_has_body_scan = true;
            }
        }

        find_key(data, "fn_pointset", fn_pointset, dir_project);
        find_key(data, "fn_landmarks", fn_landmarks, dir_project);
        find_key(data, "fn_landmark_validity", fn_landmark_validity, dir_project);
        find_key(data, "fn_invtrans_mesh", fn_invtrans_mesh, dir_project);
        find_key(data, "fn_invtrans_final_mesh", fn_invtrans_final_mesh, dir_project);
        find_key(data, "fn_pose", fn_pose, dir_project);
        find_key(data, "fn_metashape_project", fn_metashape_project, dir_project);
        find_key(data, "fn_texture", fn_texture, dir_project);
        find_key(data, "fn_normal_map", fn_normal_map, dir_project);
        find_key(data, "fn_ao_map", fn_ao_map, dir_project);
        find_key(data, "fn_roughness_map", fn_roughness_map, dir_project);
        find_key(data, "fn_openpose_keypoint_folder", fn_openpose_keypoint_folder, dir_project);
        find_key(data, "fn_cameras", fn_cameras, dir_project);
        find_key(data, "fn_apple_mesh", fn_apple_mesh, dir_project);
        find_key(data, "fn_apple_rgb", fn_apple_rgb, dir_project);
        find_key(data, "fn_apple_nm", fn_apple_nm, dir_project);
        find_key(data, "fn_apple_ao", fn_apple_ao, dir_project);
        find_key(data, "fn_apple_roughness", fn_apple_roughness, dir_project);

        find_key(data, "b_landmarks_only_before_finefit", b_landmarks_only_before_finefit);
        find_key(data, "b_textured", b_textured);
        find_key(data, "b_provide_texture_manually", b_provide_texture_manually);
        find_key(data, "b_repair_hand_texture", b_repair_hand_texture);
        find_key(data, "b_repair_armpit_texture", b_repair_armpit_texture);
        find_key(data, "b_replace_floor_plane", b_replace_floor_plane);
        find_key(data, "b_openpose_landmarks", b_openpose_landmarks);
        find_key(data, "b_inspect_detected_landmarks", b_inspect_detected_landmarks);
        find_key(data, "b_write_invtrans_even_if_not_textured", b_write_invtrans_even_if_not_textured);
        find_key(data, "b_check_for_normal_flip_on_load", b_check_for_normal_flip_on_load);
        find_key(data, "b_use_cpc_for_ik", b_use_cpc_for_ik);


        find_key(data, "int_detail_level", int_detail_level);

        find_key(data, "dbl_mouth_shut_weight", dbl_mouth_shut_weight);
        find_key(data, "dbl_landmark_weight_multiplier", dbl_landmark_weight_multiplier);
        find_key(data, "dbl_posefit_lambda", dbl_posefit_lambda);
        find_key(data, "dbl_landmark_weight_ik", dbl_landmark_weight_ik);

    }

};

}


#endif
