I try to use triangulated surface mesh simplification of cgal. I used Garland&Heckbert Simplification to simplify my mesh, but it tooks so long. My data has 50000 nv, 165883 ne and 109521 nf, which needs almost 30mins with 0.2 stop_ratio. Is the runtime cost reasonable? I also check whether the input mesh is valid by using CGAL::is_valid_polygon_mesh. It is valid. how can i solve this problem? Thank you so much...
the runtime cost of mesh with 165883 edges
the runtime cost of mesh with 8282 edges
enter code here
#include <fstream>
#include <iostream>
#include <iterator>
#include <vector>
#include "gltf-loader.h"
#define TINYGLTF_NO_STB_IMAGE_WRITE
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "tiny_gltf.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/draw_surface_mesh.h>
#include <CGAL/draw_polygon_2.h>
#include <CGAL/Polygon_mesh_processing/repair.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_normal_change_placement.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/GarlandHeckbert_policies.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/stitch_borders.h>
#include <chrono>
#include <vector>
using namespace example;
namespace PMP = CGAL::Polygon_mesh_processing;
namespace NP = CGAL::parameters;
//typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> CGAL_Mesh;
typedef CGAL_Mesh::Vertex_index vertex_descriptor;
typedef CGAL_Mesh::Face_index face_descriptor;
namespace SMS = CGAL::Surface_mesh_simplification;
CGAL_Mesh inital_mesh;
const char* filename = "C:\\Users\\Administrator\\source\\repos\\CMakeProject4\\CMakeProject4\\input.off";
if (!PMP::IO::read_polygon_mesh(filename, inital_mesh) || CGAL::is_empty(inital_mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
std::chrono::steady_clock::time_point start_time = std::chrono::steady_clock::now();
double stop_ratio = 0.2;
std::cout << "start edge collages." << std::endl;
SMS::Count_ratio_stop_predicate<CGAL_Mesh> stop(stop_ratio);
typedef typename SMS::GarlandHeckbert_policies<CGAL_Mesh, K> GH_policies;
typedef typename GH_policies::Get_cost GH_cost;
typedef typename GH_policies::Get_placement GH_placement;
typedef SMS::Bounded_normal_change_placement<GH_placement> Bounded_GH_placement;
bool check_mesh = CGAL::is_valid_polygon_mesh(inital_mesh);
std::cout << "vaild or in valid" <<check_mesh<< std::endl;
GH_policies gh_policies(inital_mesh);
const GH_cost& gh_cost = gh_policies.get_cost();
const GH_placement& gh_placement = gh_policies.get_placement();
Bounded_GH_placement placement(gh_placement);
std::cout << "Input mesh has " << num_vertices(inital_mesh) << " nv "<< num_edges(inital_mesh) << " ne "
<< num_faces(inital_mesh) << " nf" << std::endl;
/*internal::cgal_enable_sms_trace = true;*/
int r = SMS::edge_collapse(inital_mesh, stop,
CGAL::parameters::get_cost(gh_cost)
.get_placement(placement));