<commit_before>
#include <chrono>
#include <ctime>

#include <core/cmap/cmap2.h>

CGOGN_PRAGMA_EIGEN_REMOVE_WARNINGS_ON
#include <Eigen/Dense>
CGOGN_PRAGMA_EIGEN_REMOVE_WARNINGS_OFF

#include <io/map_import.h>


#define DEFAULT_MESH_PATH CGOGN_STR(CGOGN_TEST_MESHES_PATH)

struct MyMapTraits : public cgogn::DefaultMapTraits
{
	static const unsigned int CHUNK_SIZE = 8192;
};

using Map2 = cgogn::CMap2_T<MyMapTraits, cgogn::CMap2Type<MyMapTraits>>;

using Vec3 = Eigen::Vector3d;

template<typename T>
using VertexAttributeHandler = Map2::VertexAttributeHandler<T>;
template<typename T>
using FaceAttributeHandler = Map2::FaceAttributeHandler<T>;

int main(int argc, char** argv)
{
	std::string surfaceMesh;
	if (argc < 2)
	{
		std::cout << "USAGE: " << argv[0] << " [filename]" << std::endl;
		surfaceMesh = std::string(DEFAULT_MESH_PATH) + std::string("aneurysm3D_1.off");
		std::cout << "Using default mesh : " << surfaceMesh << std::endl;
	} else {
		surfaceMesh = std::string(argv[1]);
	}

	cgogn::thread_start();
	Map2 map;
	for (int k = 0 ; k < 2 ; ++k)
	{
		cgogn::io::import_surface<Vec3>(map, surfaceMesh);

		std::chrono::time_point<std::chrono::system_clock> start, end;
		start = std::chrono::system_clock::now();

		VertexAttributeHandler<Vec3> vertex_position = map.get_attribute<Vec3, Map2::VERTEX>("position");
		VertexAttributeHandler<Vec3> vertex_normal = map.add_attribute<Vec3, Map2::VERTEX>("normal");
		FaceAttributeHandler<Vec3> face_normal = map.add_attribute<Vec3, Map2::FACE>("normal");

		map.enable_topo_cache<Map2::FACE>();
		map.enable_topo_cache<Map2::VERTEX>();
		map.enable_topo_cache<Map2::EDGE>();

		unsigned int nbf = 0;

		for	(unsigned int i = 0; i < 10; ++i)
		{
			map.foreach_cell<Map2::FACE>([&] (Map2::Face f)
			{
				++nbf;
				Vec3 v1 = vertex_position[map.phi1(f.dart)] - vertex_position[f.dart];
				Vec3 v2 = vertex_position[map.phi_1(f.dart)] - vertex_position[f.dart];
				face_normal[f] = v1.cross(v2);
			});
		}

		unsigned int nbv = 0;

		for	(unsigned int i = 0; i < 10; ++i)
		{
			map.foreach_cell<Map2::VERTEX>([&] (Map2::Vertex v)
			{
				++nbv;
				Vec3 sum({0, 0, 0});
				unsigned int nb_incident = 0;
				map.foreach_incident_face(v, [&] (Map2::Face f)
				{
					++nb_incident;
					sum += face_normal[f];
				});
				vertex_normal[v] = sum / nb_incident;
			});
		}

		unsigned int nbe = 0;

		for	(unsigned int i = 0; i < 10; ++i)
		{
			map.foreach_cell<Map2::EDGE>([&nbe] (Map2::Edge)
			{
				++nbe;
			});
		}

		std::cout << "nb vertices -> " << nbv << std::endl;
		std::cout << "nb edges -> " << nbe << std::endl;
		std::cout << "nb faces -> " << nbf << std::endl;

		end = std::chrono::system_clock::now();
		std::chrono::duration<double> elapsed_seconds = end - start;
		std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n";
	}
	cgogn::thread_stop();
	return 0;
}<commit_msg>fixed compilation of cmap2_import example.<commit_after>
#include <chrono>
#include <ctime>

#include <core/cmap/cmap2.h>

CGOGN_PRAGMA_EIGEN_REMOVE_WARNINGS_ON
#include <Eigen/Dense>
CGOGN_PRAGMA_EIGEN_REMOVE_WARNINGS_OFF

#include <io/map_import.h>


#define DEFAULT_MESH_PATH CGOGN_STR(CGOGN_TEST_MESHES_PATH)

struct MyMapTraits : public cgogn::DefaultMapTraits
{
	static const unsigned int CHUNK_SIZE = 8192;
};

using Map2 = cgogn::CMap2_T<MyMapTraits, cgogn::CMap2Type<MyMapTraits>>;

using Vec3 = Eigen::Vector3d;

template<typename T>
using VertexAttributeHandler = Map2::VertexAttributeHandler<T>;
template<typename T>
using FaceAttributeHandler = Map2::FaceAttributeHandler<T>;

int main(int argc, char** argv)
{
	std::string surfaceMesh;
	if (argc < 2)
	{
		std::cout << "USAGE: " << argv[0] << " [filename]" << std::endl;
		surfaceMesh = std::string(DEFAULT_MESH_PATH) + std::string("aneurysm3D_1.off");
		std::cout << "Using default mesh : " << surfaceMesh << std::endl;
	} else {
		surfaceMesh = std::string(argv[1]);
	}

	cgogn::thread_start();
	Map2 map;
	for (int k = 0 ; k < 2 ; ++k)
	{
		cgogn::io::import_surface<Vec3>(map, surfaceMesh);

		std::chrono::time_point<std::chrono::system_clock> start, end;
		start = std::chrono::system_clock::now();

		VertexAttributeHandler<Vec3> vertex_position = map.get_attribute<Vec3, Map2::VERTEX>("position");
		VertexAttributeHandler<Vec3> vertex_normal = map.add_attribute<Vec3, Map2::VERTEX>("normal");
		FaceAttributeHandler<Vec3> face_normal = map.add_attribute<Vec3, Map2::FACE>("normal");

		map.enable_topo_cache<Map2::FACE>();
		map.enable_topo_cache<Map2::VERTEX>();
		map.enable_topo_cache<Map2::EDGE>();

		unsigned int nbf = 0;

		for	(unsigned int i = 0; i < 10; ++i)
		{
			map.foreach_cell<Map2::FACE>([&] (Map2::FaceHandle f)
			{
				++nbf;
				Vec3 v1 = vertex_position[map.phi1(f.dart)] - vertex_position[f.dart];
				Vec3 v2 = vertex_position[map.phi_1(f.dart)] - vertex_position[f.dart];
				face_normal[f] = v1.cross(v2);
			});
		}

		unsigned int nbv = 0;

		for	(unsigned int i = 0; i < 10; ++i)
		{
			map.foreach_cell<Map2::VERTEX>([&] (Map2::VertexHandle v)
			{
				++nbv;
				Vec3 sum({0, 0, 0});
				unsigned int nb_incident = 0;
				map.foreach_incident_face(v, [&] (Map2::FaceHandle f)
				{
					++nb_incident;
					sum += face_normal[f];
				});
				vertex_normal[v] = sum / nb_incident;
			});
		}

		unsigned int nbe = 0;

		for	(unsigned int i = 0; i < 10; ++i)
		{
			map.foreach_cell<Map2::EDGE>([&nbe] (Map2::EdgeHandle)
			{
				++nbe;
			});
		}

		std::cout << "nb vertices -> " << nbv << std::endl;
		std::cout << "nb edges -> " << nbe << std::endl;
		std::cout << "nb faces -> " << nbf << std::endl;

		end = std::chrono::system_clock::now();
		std::chrono::duration<double> elapsed_seconds = end - start;
		std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n";
	}
	cgogn::thread_stop();
	return 0;
}
{'fraction_non_alphanumeric': 0.17504752030412996, 'fraction_numerical': 0.022982547088301365, 'mean_word_length': 4.608527131782946, 'pattern_counts': {'":': 0, '<': 141, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6795472', 'n_tokens_mistral': 2543, 'n_tokens_neox': 2277, 'n_words': 414}