#include <iostream>
#include "MRMesh/MRMesh.h"
#include "MRMesh/MRMeshLoad.h"
#include "MRMesh/MRMeshSave.h"
#include "MRMesh/MRMeshDecimate.h"
int main()
{
std::string in_file = DATA_PATH "in.obj";
std::string out_file = DATA_PATH "out.obj";
double face_ratio = 0.9; //简化比率
// load mesh
MR::Mesh mesh = MR::MeshLoad::fromAnySupportedFormat(in_file).value();
std::cout << "faces size:" << mesh.topology.faceSize() << std::endl;
std::cout << "vertex size:" << mesh.points.size() << std::endl;
auto faceSize = mesh.topology.faceSize();
MR::DecimateSettings settings;
settings.maxError = FLT_MAX;
settings.maxDeletedFaces = faceSize * face_ratio;
auto result = MR::decimateMesh(mesh, settings);
std::cout << "faces deleted: " << result.facesDeleted << std::endl;
std::cout << "vertex deleted: " << result.vertsDeleted << std::endl;
// Save
MR::MeshSave::toAnySupportedFormat(mesh, out_file);
return 0;
}