#include <CGAL/bisect_failures.h>
#include <CGAL/boost/graph/Euler_operations.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/clip.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <iostream>
int main(int argc, char* argv[]) {
const std::string filename = (argc > 1) ? argv[1] :
CGAL::data_file_path(
"meshes/non_manifold.off");
Mesh mesh_a;
std::cerr << "Error: cannot read file " << filename << "\n";
return EXIT_FAILURE;
}
std::cout << "Loaded mesh with " << mesh_a.number_of_vertices() << " vertices and "
<< mesh_a.number_of_faces() << " faces\n";
Mesh mesh_b;
std::cerr << "Error: cannot read file " << clip_name << "\n";
return EXIT_FAILURE;
}
std::cout << "Loaded clipping mesh mesh with " << mesh_b.number_of_vertices() << " vertices and "
<< mesh_b.number_of_faces() << " faces\n";
auto get_size = [](const Mesh& m) -> std::size_t {
return m.number_of_faces();
};
auto simplify = [](Mesh& m, int start, int end) -> bool {
for(auto i = end - 1; i >= start; --i) {
const auto f = m.faces().begin() + i;
}
return m.is_valid();
};
auto run = [&mesh_b](Mesh& mesh) -> int {
return CGAL::Polygon_mesh_processing::clip(mesh, mesh_b) ? EXIT_SUCCESS : EXIT_FAILURE;
};
auto save = [](const Mesh& m, const std::string& prefix) {
std::string out_filename = prefix + ".off";
std::cerr << "Warning: Could not save mesh to " << out_filename << "\n";
} else {
std::cout << "Saved mesh with " << m.number_of_faces()
<< " faces to " << out_filename << "\n";
}
};
std::cout << "\n=== Starting bisection to find minimal failing case ===\n\n";
if(result == EXIT_SUCCESS) {
std::cout << "\nNo failure detected during bisection.\n";
} else {
std::cout << "\nFailure detected during bisection. Result code: " << result << "\n";
}
return EXIT_SUCCESS;
}
void remove_face(typename boost::graph_traits< Graph >::halfedge_descriptor h, Graph &g)
bool read_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
bool write_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
int bisect_failures(const InputData &data, GetSizeFn get_size_fn, SimplifyFn simplify_fn, RunFn run_fn, SaveFn save_fn)
Bisects input data by iteratively simplifying it to identify the minimal failing case.
Definition: bisect_failures.h:78
std::string data_file_path(const std::string &filename)