#ifndef FACE_CONFIG_H
#define FACE_CONFIG_H

#include "Base_config.h"

namespace p2c
{

struct Face_config : Base_config
{
    std::string dir_project;
    std::string fn_pointset;
    std::string fn_invtrans_mesh;
    std::string fn_invtrans_final_mesh;
    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_frontal_image;
    std::string fn_contour_eyes;
    std::string fn_ears_landmarks;
    std::string fn_cameras;
    std::string fn_landmarks_facialfeatures;
    std::string fn_landmark_validity;
    std::string fn_openpose_keypoint_folder;
    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;

    int int_detail_level;

    double dbl_mouth_shut_weight;
    double dbl_eyelid_weight;
    double dbl_ears_lm_weight;
    double dbl_keep_body_vertices_weight;

    bool b_textured;
    bool b_provide_texture_manually;
    bool b_manual_eye_contour;
    bool b_initial_alignment_with_pca;
    bool b_inspect_detected_landmarks;
    bool b_openpose_landmarks;
    bool b_automatic_facialfeatures;

    bool b_has_face_scan;
    bool b_poisson_merge_for_face_texture;

public:
    Face_config() :
        int_detail_level(2),
        dbl_mouth_shut_weight(0.0),
        dbl_eyelid_weight(0.0),
        dbl_ears_lm_weight(0.0),
        dbl_keep_body_vertices_weight(0.0),
        b_textured(true),
        b_provide_texture_manually(false),
        b_manual_eye_contour(false),
        b_initial_alignment_with_pca(false),
        b_inspect_detected_landmarks(false),
        b_openpose_landmarks(true),
        b_automatic_facialfeatures(true),
        b_has_face_scan(false),
        b_poisson_merge_for_face_texture(true)
    {}

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

                b_has_face_scan = true;
            }
        }

        if (!b_has_face_scan) return;

        find_key(data, "fn_pointset", fn_pointset, 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_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_frontal_image", fn_frontal_image, dir_project);
        find_key(data, "fn_contour_eyes", fn_contour_eyes, dir_project);
        find_key(data, "fn_ears_landmarks", fn_ears_landmarks, dir_project);
        find_key(data, "fn_cameras", fn_cameras, dir_project);
        find_key(data, "fn_landmarks_facialfeatures", fn_landmarks_facialfeatures, dir_project);
        find_key(data, "fn_landmark_validity", fn_landmark_validity, dir_project);
        find_key(data, "fn_openpose_keypoint_folder", fn_openpose_keypoint_folder, 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, "int_detail_level", int_detail_level);

        find_key(data, "dbl_mouth_shut_weight", dbl_mouth_shut_weight);
        find_key(data, "dbl_eyelid_weight", dbl_eyelid_weight);
        find_key(data, "dbl_ears_lm_weight", dbl_ears_lm_weight);
        find_key(data, "dbl_keep_body_vertices_weight", dbl_keep_body_vertices_weight);

        find_key(data, "b_textured", b_textured);
        find_key(data, "b_provide_texture_manually", b_provide_texture_manually);
        find_key(data, "b_manual_eye_contour", b_manual_eye_contour);
        find_key(data, "b_initial_alignment_with_pca", b_initial_alignment_with_pca);
        find_key(data, "b_inspect_detected_landmarks", b_inspect_detected_landmarks);
        find_key(data, "b_openpose_landmarks", b_openpose_landmarks);
        find_key(data, "b_automatic_facialfeatures", b_automatic_facialfeatures);
        find_key(data, "b_poisson_merge_for_face_texture", b_poisson_merge_for_face_texture);
    }
};

}

#endif
