Example #1
0
int main()
{
	// declare a map to handle the mesh
	MAP myMap;

	// add position attribute on vertices and get handler on it
	VertexAttribute<VEC3, MAP> position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
	const int nb = 2;
	Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
	cubic.embedIntoGrid(position, 10.0f, 10.0f, 10.0f);

	VolumeAttribute<VEC3,MAP> color = myMap.addAttribute<VEC3, VOLUME, MAP>("color");

	foreach_cell<VOLUME>(myMap, [&](Vol w)
	{
		color[w] = position[w.dart] + VEC3(0.5,0.5,0.5);
	});

	CGoGNout.toStd(false);
	CGoGNout.toFile("ls_map1.csv");
	myMap.dumpCSV();
	std::cout << "MAP 1 dumped in ls_map1.csv"<< std::endl;

	myMap.saveMapBin("ls_pipo.map");

	MAP myMap2;
	VertexAttribute<VEC3, MAP> position2 = myMap2.addAttribute<VEC3, VERTEX, MAP>("position");
	CellMarker<MAP,VERTEX> cm(myMap2);

	myMap2.loadMapBin("ls_pipo.map");

	if (!position2.isValid())
	{
		std::cout << "Attribute handlers are invalid after load or copy, get it agin"<< std::endl;
		// get it again (here attribute created in load)
		position2 = myMap2.getAttribute<VEC3, VERTEX, MAP>("position");
	}

	CGoGNout.toFile("ls_map2.csv");
	myMap2.dumpCSV();
	std::cout << "MAP 2 dumped in ls_map2.csv"<< std::endl;


	cm.update();
	if (cm.isMarked(myMap2.begin()))
		std::cout << "MARKED"<< std::endl;

	std::cout << " Volume Total =" << Algo::Geometry::totalVolume<PFP>(myMap2, position2)<< std::endl;

	return 0;
}