<commit_before>// This file is distributed under the MIT license.
// See the LICENSE file for details.

#include <algorithm>

#include <boost/filesystem.hpp>

#include "moana_loader.h"
#include "model.h"
#include "obj_loader.h"
#include "ply_loader.h"
#include "vsnray_loader.h"

//-------------------------------------------------------------------------------------------------
// Helpers
//

enum model_type { Moana, OBJ, PLY, VSNRAY, Unknown };

static model_type get_type(std::string const& filename)
{
    boost::filesystem::path p(filename);


    // Moana (json files)
    // TODO: check here if this is really a "moana" file

    static const std::string moana_extensions[] = { ".json" };

    if (std::find(moana_extensions, moana_extensions + 1, p.extension()) != moana_extensions + 1)
    {
        return Moana;
    }


    // OBJ

    static const std::string obj_extensions[] = { ".obj", ".OBJ" };

    if (std::find(obj_extensions, obj_extensions + 2, p.extension()) != obj_extensions + 2)
    {
        return OBJ;
    }


    // PLY

    static const std::string ply_extensions[] = { ".ply", ".PLY" };

    if (std::find(ply_extensions, ply_extensions + 2, p.extension()) != ply_extensions + 2)
    {
        return PLY;
    }

    // VSNRAY

    static const std::string vsnray_extensions[] = { ".vsnray", ".VSNRAY" };

    if (std::find(vsnray_extensions, vsnray_extensions + 2, p.extension()) != vsnray_extensions + 2)
    {
        return VSNRAY;
    }

    return Unknown;
}

// FN is either a single filename (std::string)
// or a list of filenames (std::vector<std::string>)
template <typename FN>
bool load_model(FN const& fn, visionaray::model& mod, model_type mt)
{
    static_assert(
            std::is_same<FN, std::string>::value ||
            std::is_same<FN, std::vector<std::string>>::value,<commit_msg>Find model type using a map<commit_after>// This file is distributed under the MIT license.
// See the LICENSE file for details.

#include <type_traits>
#include <unordered_map>

#include <boost/filesystem.hpp>

#include "moana_loader.h"
#include "model.h"
#include "obj_loader.h"
#include "ply_loader.h"
#include "vsnray_loader.h"

//-------------------------------------------------------------------------------------------------
// Helpers
//

enum model_type { Moana, OBJ, PLY, VSNRAY, Unknown };

static model_type get_type(std::string const& filename)
{
    std::unordered_map<std::string, model_type> ext2type;
    // TODO: check here if this is really a "moana" file
    ext2type.insert(std::make_pair(".json", Moana));
    ext2type.insert(std::make_pair(".obj", OBJ));
    ext2type.insert(std::make_pair(".OBJ", OBJ));
    ext2type.insert(std::make_pair(".ply", PLY));
    ext2type.insert(std::make_pair(".PLY", PLY));
    ext2type.insert(std::make_pair(".vsnray", VSNRAY));
    ext2type.insert(std::make_pair(".VSNRAY", VSNRAY));

    boost::filesystem::path p(filename);

    auto result = ext2type.find(p.extension().string());

    if (result != ext2type.end())
    {
        return result->second;
    }

    return Unknown;
}

// FN is either a single filename (std::string)
// or a list of filenames (std::vector<std::string>)
template <typename FN>
bool load_model(FN const& fn, visionaray::model& mod, model_type mt)
{
    static_assert(
            std::is_same<FN, std::string>::value ||
            std::is_same<FN, std::vector<std::string>>::value,
{'fraction_non_alphanumeric': 0.20410557184750733, 'fraction_numerical': 0.005278592375366569, 'mean_word_length': 2.806919642857143, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1162638', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1087, 'n_words': 266}