Ejemplo n.º 1
0
int test4()
{
	std::cout << "= TEST 4 = random bool cleaning with set_false_byte" << std::endl;

	ChunkArrayContainer<BLK_SZ,  bool> container;
	ChunkArray<BLK_SZ,bool>* att1 = container.add_attribute<bool>("bools");

	for (unsigned int i = 0; i < NB_LINES; ++i)
		container.insert_lines<1>();

	for(unsigned int i = container.begin(); i != container.end(); container.next(i))
	{
		att1->set_value(i, true);
	}

	for (unsigned int j = 0; j < 100; ++j)
	{
		for (unsigned int i = 0; i < NB_LINES/2; ++i)
		{
			att1->set_false_byte(i);
			att1->set_false_byte(NB_LINES-1-i);
		}
	}

	std::cout << "---> OK" << std::endl;
	return 0;
}
Ejemplo n.º 2
0
int test2()
{
	std::cout << "= TEST 2 = ref bool" << std::endl;

	ChunkArrayContainer<BLK_SZ, bool> container;
	ChunkArray<BLK_SZ,int>* att1 = container.add_attribute<int>("entier");
	ChunkArray<BLK_SZ,float>* att2 = container.add_attribute<float>("reel");
	ChunkArray<BLK_SZ,Vec3f>* att3 = container.add_attribute<Vec3f>("Vec3f");

	for (unsigned int i = 0; i < NB_LINES; ++i)
		container.insert_lines<1>();

	for(unsigned int i = container.begin(); i != container.end(); container.next(i))
	{
		(*att1)[i] = 1+int(i);
		(*att2)[i] = 3.0f + 0.1f*float(i);
		(*att3)[i] = Vec3f(float(i), float(i), float(i));
	}

	for (unsigned int j = 0; j < 100; ++j)
	{
		for (unsigned int i = 0; i < NB_LINES/10; ++i)
		{
			container.remove_lines<1>(j%2+1+i*10);
			container.remove_lines<1>(j%2+3+i*10);
			container.remove_lines<1>(j%2+8+i*10);
		}

		for (unsigned int i = 0; i < 3*NB_LINES/10; ++i)
			container.insert_lines<1>();
	}

	std::cout << "---> OK" << std::endl;
	return 0;
}
Ejemplo n.º 3
0
int test2()
{
	cgogn_log_info("bench_chunk_array") << "= TEST 2 = ref bool" ;

	ChunkArrayContainer<BLK_SZ, bool> container;
	ChunkArray<BLK_SZ,int32>* att1 = container.add_chunk_array<int32>("entier");
	ChunkArray<BLK_SZ,float32>* att2 = container.add_chunk_array<float32>("reel");
	ChunkArray<BLK_SZ,Vec3f>* att3 = container.add_chunk_array<Vec3f>("Vec3f");

	for (uint32 i = 0; i < NB_LINES; ++i)
		container.insert_lines<1>();

	for(uint32 i = container.begin(); i != container.end(); container.next(i))
	{
		(*att1)[i] = 1+int32(i);
		(*att2)[i] = 3.0f + 0.1f*float32(i);
		(*att3)[i] = Vec3f(float32(i), float32(i), float32(i));
	}

	for (uint32 j = 0; j < 100; ++j)
	{
		for (uint32 i = 0; i < NB_LINES/10; ++i)
		{
			container.remove_lines<1>(j%2+1+i*10);
			container.remove_lines<1>(j%2+3+i*10);
			container.remove_lines<1>(j%2+8+i*10);
		}

		for (uint32 i = 0; i < 3*NB_LINES/10; ++i)
			container.insert_lines<1>();
	}

	cgogn_log_info("bench_chunk_array") << "---> OK" ;
	return 0;
}
Ejemplo n.º 4
0
int test4()
{
	cgogn_log_info("bench_chunk_array") << "= TEST 4 = random bool cleaning with set_false_byte" ;

	ChunkArrayContainer<BLK_SZ, uint8> container;
	ChunkArrayBool<BLK_SZ>* att1 = container.add_marker_attribute();

	for (uint32 i = 0; i < NB_LINES; ++i)
		container.insert_lines<1>();

	for(uint32 i = container.begin(); i != container.end(); container.next(i))
	{
		att1->set_value(i, true);
	}

	for (uint32 j = 0; j < 100; ++j)
	{
		for (uint32 i = 0; i < NB_LINES/2; ++i)
		{
			att1->set_false_byte(i);
			att1->set_false_byte(NB_LINES-1-i);
		}
	}

	cgogn_log_info("bench_chunk_array") << "---> OK" ;
	return 0;
}
Ejemplo n.º 5
0
int test5()
{
	std::cout << "= TEST 5 = Traversal" << std::endl;

	ChunkArrayContainer<BLK_SZ, unsigned int> container;
	ChunkArray<BLK_SZ,unsigned int>* att1 = container.add_attribute<unsigned int>("uints");

	for (unsigned int i = 0; i < NB_LINES; ++i)
		container.insert_lines<1>();

	for(unsigned int i = container.begin(); i != container.end(); container.next(i))
		att1->operator[](i) = i;

	for(unsigned int i = container.begin(); i < container.end(); i += 9)
		container.remove_lines<1>(i);

	unsigned int  total = 0;
	for (unsigned int j = 0; j < 50; ++j)
	{
		for(unsigned int i = container.begin(); i != container.end(); container.next(i))
		{
			if (att1->operator[](i) % i != 0)
				total += att1->operator[](i);
		}
		total = - total;
	}

	std::cout << "---> OK " << total << std::endl;
	return 0;
}
Ejemplo n.º 6
0
int test5()
{
	cgogn_log_info("bench_chunk_array") << "= TEST 5 = Traversal" ;

	ChunkArrayContainer<BLK_SZ, uint32> container;
	ChunkArray<BLK_SZ,uint32>* att1 = container.add_chunk_array<uint32>("uints");

	for (uint32 i = 0; i < NB_LINES; ++i)
		container.insert_lines<1>();

	for(uint32 i = container.begin(); i != container.end(); container.next(i))
		att1->operator[](i) = i;

	for(uint32 i = container.begin(); i < container.end(); i += 9)
		container.remove_lines<1>(i);

	uint32  total = 0;
	for (uint32 j = 0; j < 50; ++j)
	{
		for(uint32 i = container.begin(); i != container.end(); container.next(i))
		{
			if (att1->operator[](i) % i != 0)
				total += att1->operator[](i);
		}
		total = - total;
	}

	cgogn_log_info("bench_chunk_array") << "---> OK " << total ;
	return 0;
}
Ejemplo n.º 7
0
int test_save()
{
	std::cout << "=============== TEST SAVE ===============" << std::endl;

	ChunkArrayContainer container;

	ChunkArray<float>* att1 = container.add_attribute<float>("float");
	ChunkArray<std::string>* att4 = container.add_attribute<std::string>("std::string");
	ChunkArray<DoubleVecList>* att2 = container.add_attribute<DoubleVecList>("ListVecDouble");
	ChunkArray<StringListVec>* att3 = container.add_attribute<StringListVec>("VecListString");
	ChunkArray<StringArray>* att_string_array = container.add_attribute<StringArray>("StringArray");

	for (unsigned int i = 0u; i < 10u; ++i)
		container.insert_lines<1>();

	for(unsigned int i = container.begin(); i != container.end(); container.next(i))
	{
		(*att1)[i] = 0.1f*float(i);
		(*att4)[i] = std::string(3,char('Z'-i));

		(*att2)[i] = {{3.0 + 0.1*double(i),15.0 + 0.1*double(i)}, {103.0 + 0.1*double(i), 203.0 + 0.1*double(i), 303.0 + 0.1*double(i)}};

		(*att3)[i] = {{"riri","riri"},{"fifi","fifi"},{"loulou","loulou"}};

		(*att_string_array)[i] = {"riri" + std::to_string(i), "fifi" + std::to_string(i)};
		if (i%2)
		{
			(*att2)[i].front().push_back(0.0);
			(*att2)[i].back().push_back(1.0);
		}
		else
		{
			(*att3)[i][1].push_front(std::string(3,char('A'+i)));
		}
	}
	(*att2)[9].push_back({9.0,8.,7.0});

	container.remove_lines<1>(5);


	for(unsigned int i = container.begin(); i != container.end(); container.next(i))
	{
		if (att1)
			std::cout << "FLOAT=" << (*att1)[i] << "/";

		if (att4)
			std::cout << "STR=" << (*att4)[i] << "/";

		if (att2)
		{
			std::cout << " ATT2 = ";
			for (const auto& v : (*att2)[i])
			{
				for (auto x : v)
					std::cout << x << " ";
				std::cout << "/ ";
			}
		}

		if (att3)
		{
			std::cout << " ATT3 = ";
			for (const auto& v : (*att3)[i])
			{
				for (auto x : v)
					std::cout << x << " ";
				std::cout << "/ ";
			}

		}

		if (att_string_array)
		{
			std::cout << " att_string_array = ";
			for (const auto& v : (*att_string_array)[i])
			{
					std::cout << v << " ";
			}
			std::cout << "/ ";
		}
		std::cout << std::endl;
	}
	std::cout << "----------------------------------------" << std::endl;

	std::ofstream of("pipo.map", std::ios::binary);
	container.save(of);
	of.close();
	return 0;
}