<commit_before>#include "resourceloader.hpp"

#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <FreeImage.h>
#include <memory>
#include <vector>
#include <fstream>
#include <iostream>
#include <json.hpp>

#include <Utilities/utilities.hpp>
#include <Core/glapi.hpp>
#include <Resources/model3d.hpp>
#include <Utilities/utilities.hpp>
#include <Models/line.hpp>
#include <Models/staticmodel.hpp>

using namespace gl;
using json = nlohmann::json;

std::vector<std::shared_ptr<IRenderObject>> ResourceLoader::LoadScene(std::shared_ptr<GlutDisplay> display, std::string filename) {
    std::vector<std::shared_ptr<IRenderObject>> renderObjects;

    std::string contents;
    std::ifstream in(filename, std::ios::in | std::ios::binary);
    if (in) {
        in.seekg(0, std::ios::end);
        contents.resize(in.tellg());
        in.seekg(0, std::ios::beg);
        in.read(&contents[0], contents.size());
        in.close();
    } else {
        std::cout << "Couldn't load " << filename << std::endl;
        return renderObjects;
    }

    json scene = json::parse(contents);
    std::vector<json> objects = scene["objects"];

    for(json object : objects) {
        std::string type = object["type"];
        if(type == "line") {
            glm::vec3 head, tail, color;

            std::vector<float> head3f = object["head"];
            if(head3f.size() == 3) {
                head = glm::vec3(head3f[0], head3f[1], head3f[2]);
            } else {
                std::cout << "elements in head for model line not equal to 3" << std::endl;
                continue;
            }

            std::vector<float> tail3f = object["tail"];
            if(tail3f.size() == 3) {
                tail = glm::vec3(tail3f[0], tail3f[1], tail3f[2]);
            } else {
                std::cout << "elements in tail for model line not equal to 3" << std::endl;
                continue;
            }
<commit_msg>lines can be loaded from a json file<commit_after>#include "resourceloader.hpp"

#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <FreeImage.h>
#include <memory>
#include <vector>
#include <fstream>
#include <iostream>
#include <json.hpp>

#include <Utilities/utilities.hpp>
#include <Core/glapi.hpp>
#include <Resources/model3d.hpp>
#include <Utilities/utilities.hpp>
#include <Models/line.hpp>
#include <Models/staticmodel.hpp>

using namespace gl;
using json = nlohmann::json;

std::vector<std::shared_ptr<IRenderObject>> ResourceLoader::LoadScene(std::shared_ptr<GlutDisplay> display, std::string filename) {
    std::vector<std::shared_ptr<IRenderObject>> renderObjects;

    std::string contents;
    std::ifstream in(filename, std::ios::in | std::ios::binary);
    if (in) {
        in.seekg(0, std::ios::end);
        contents.resize(in.tellg());
        in.seekg(0, std::ios::beg);
        in.read(&contents[0], contents.size());
        in.close();
    } else {
        std::cout << "Couldn't load " << filename << std::endl;
        return renderObjects;
    }

    json scene = json::parse(contents);
    std::vector<json> objects = scene["objects"];

    for(json object : objects) {
        std::string type = object["type"];
        if(type == "line") {
            glm::vec3 head, tail, color;

            std::vector<float> head3f = object["shit"];
            if(head3f.size() == 3) {
                head = glm::vec3(head3f[0], head3f[1], head3f[2]);
            } else {
                std::cout << "elements in head for model line not equal to 3" << std::endl;
                continue;
            }

            std::vector<float> tail3f = object["tail"];
            if(tail3f.size() == 3) {
                tail = glm::vec3(tail3f[0], tail3f[1], tail3f[2]);
            } else {
                std::cout << "elements in tail for model line not equal to 3" << std::endl;
                continue;
            }

{'fraction_non_alphanumeric': 0.16248382923673999, 'fraction_numerical': 0.013971539456662354, 'mean_word_length': 2.7173076923076924, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 47, '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': '2209486', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1241, 'n_words': 269}