bench_remesh.cpp 2.41 KB
Newer Older
Sylvain Thery's avatar
benches  
Sylvain Thery committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"

#include "Geometry/vector_gen.h"

#include "Algo/Import/import.h"
#include "Algo/Export/export.h"

#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"

#include "Algo/Modelisation/subdivision.h"
#include "Algo/Decimation/decimation.h"

#include "Utils/chrono.h"
#include "Algo/Filtering/average.h"

using namespace CGoGN ;

struct PFP: public PFP_STANDARD
{
	// definition of the map
	typedef EmbeddedMap2 MAP ;
};

typedef PFP::MAP MAP ;


int main(int argc, char **argv)
{

	if(argc != 2)
		return 1;

	MAP myMap;

	std::vector<std::string> attrNames ;
	if(!Algo::Surface::Import::importMesh<PFP>(myMap, argv[1], attrNames))
	{
		CGoGNerr << "could not import " << argv[1] << CGoGNendl ;
		return 2;
	}
Sylvain Thery's avatar
Sylvain Thery committed
43
	VertexAttribute<PFP::VEC3, MAP> position = myMap.getAttribute<PFP::VEC3,VERTEX,MAP>( attrNames[0]) ;
Sylvain Thery's avatar
benches  
Sylvain Thery committed
44 45 46 47 48 49 50 51 52 53 54


	Utils::Chrono chrono;

	chrono.start();

	Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
	Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
	Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
	unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;

55 56
	std::vector<VertexAttribute<typename PFP::VEC3, MAP> > attr;
	attr.push_back(position);
Sylvain Thery's avatar
benches  
Sylvain Thery committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;

	Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
	Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
	nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;

	Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;

	Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
	Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
	nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;

	Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;

	Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position) ;
	Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position) ;

	CGoGNout << "BenchTime dynamic "<< chrono.elapsed() << " ms"<< CGoGNendl;

	Algo::Surface::Export::exportOFF<PFP>(myMap,position,"bench_res.off");

	return 0;
}