<commit_before>#include "proxy/DataCollector.h"
#include "object/object.h"

#include <map>

namespace aten {
	void DataCollector::collect(
		std::vector<aten::ShapeParameter>& shapeparams,
		std::vector<aten::PrimitiveParamter>& primparams,
		std::vector<aten::LightParameter>& lightparams,
		std::vector<aten::MaterialParameter>& mtrlparms,
		std::vector<aten::vertex>& vtxparams)
	{
		const auto& shapes = aten::transformable::getShapes();

		int order = 0;
		std::map<transformable*, int> orderMap;

		for (auto s : shapes) {
			auto type = s->getParam().type;

			switch (type) {
			case ShapeType::Polygon:
			{
				auto param = s->getParam();
				shapeparams.push_back(param);

				const int primcnt = primparams.size();

				if (primcnt <= param.primid) {
					primparams.resize(primparams.size() + param.primid + param.primnum);
				}

				s->getPrimitives(&primparams[param.primid]);

				orderMap.insert(std::pair<transformable*, int>(s, order++));
			}
				break;
			case ShapeType::Sphere:
			case ShapeType::Cube:
			{
				auto param = s->getParam();
				param.mtrl.idx = aten::material::findMaterialIdx((aten::material*)param.mtrl.ptr);
				shapeparams.push_back(param);

				orderMap.insert(std::pair<transformable*, int>(s, order++));
			}
				break;
			default:
				break;
			}	
		}

		// Not gurantee order of the object which the instance has.
		for (auto s : shapes) {
			auto type = s->getParam().type;

			if (type == ShapeType::Instance) {
				auto param = s->getParam();
				auto obj = s->getHasObject();
				
				auto it = orderMap.find((transformable*)(obj));
				AT_ASSERT(it != orderMap.end());

				// Specify the index of the object which the instance has.
				param.shapeid = it->second;

				param.area = it->first->getParam().area;

				shapeparams.push_back(param);
			}
		}

		const auto& lights = aten::Light::getLights();

		for (auto l : lights) {
			auto param = l->param();
			lightparams.push_back(param);
		}

		const auto& mtrls = aten::material::getMaterials();

		for (auto m : mtrls) {
			mtrlparms.push_back(m->param());
		}

		const auto& faces = aten::face::faces();

		for (auto f : faces) {
			primparams.push_back(f->param);
		}

		const auto& vtxs = aten::VertexManager::getVertices();

		for (auto v : vtxs) {
			vtxparams.push_back(v);
		}
	}
}<commit_msg>Fix a bug about timing to register parameters.<commit_after>#include "proxy/DataCollector.h"
#include "object/object.h"

#include <map>

namespace aten {
	void DataCollector::collect(
		std::vector<aten::ShapeParameter>& shapeparams,
		std::vector<aten::PrimitiveParamter>& primparams,
		std::vector<aten::LightParameter>& lightparams,
		std::vector<aten::MaterialParameter>& mtrlparms,
		std::vector<aten::vertex>& vtxparams)
	{
		const auto& shapes = aten::transformable::getShapes();

		int order = 0;
		std::map<transformable*, int> orderMap;

		for (auto s : shapes) {
			auto type = s->getParam().type;

			switch (type) {
			case ShapeType::Polygon:
			{
				auto param = s->getParam();

				const int primcnt = primparams.size();

				if (primcnt <= param.primid) {
					primparams.resize(primparams.size() + param.primid + param.primnum);
				}

				s->getPrimitives(&primparams[param.primid]);

				orderMap.insert(std::pair<transformable*, int>(s, order++));
			}
				break;
			case ShapeType::Sphere:
			case ShapeType::Cube:
			{
				orderMap.insert(std::pair<transformable*, int>(s, order++));
			}
				break;
			default:
				break;
			}	
		}

		// Not gurantee order of the object which the instance has.
		for (auto s : shapes) {
			auto type = s->getParam().type;

			if (type == ShapeType::Instance) {
				auto param = s->getParam();
				auto obj = s->getHasObject();
				
				auto it = orderMap.find((transformable*)(obj));
				AT_ASSERT(it != orderMap.end());

				// Specify the index of the object which the instance has.
				param.shapeid = it->second;

				param.area = it->first->getParam().area;

				shapeparams.push_back(param);
			}
			else if (type == ShapeType::Polygon) {
				auto param = s->getParam();
				shapeparams.push_back(param);
			}
			else if (type == ShapeType::Sphere
				|| type == ShapeType::Cube)
			{
				auto param = s->getParam();
				param.mtrl.idx = aten::material::findMaterialIdx((aten::material*)param.mtrl.ptr);
				shapeparams.push_back(param);
			}
		}

		const auto& lights = aten::Light::getLights();

		for (auto l : lights) {
			auto param = l->param();
			lightparams.push_back(param);
		}

		const auto& mtrls = aten::material::getMaterials();

		for (auto m : mtrls) {
			mtrlparms.push_back(m->param());
		}

		const auto& faces = aten::face::faces();

		for (auto f : faces) {
			primparams.push_back(f->param);
		}

		const auto& vtxs = aten::VertexManager::getVertices();

		for (auto v : vtxs) {
			vtxparams.push_back(v);
		}
	}
}
{'fraction_non_alphanumeric': 0.16060669021400373, 'fraction_numerical': 0.00041554124246831497, 'mean_word_length': 3.576045627376426, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 48, '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': '6026742', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1630, 'n_words': 342}