Add a test

This commit is contained in:
Mael Rouxel-Labbé 2023-09-20 16:58:59 +02:00
parent d092d4b0e3
commit 985c8a7825
3 changed files with 162 additions and 0 deletions

View File

@ -12,6 +12,7 @@ create_single_source_cgal_program("test_edge_collapse_Envelope.cpp")
create_single_source_cgal_program("test_edge_collapse_Polyhedron_3.cpp")
create_single_source_cgal_program("test_edge_profile_link.cpp")
create_single_source_cgal_program("test_edge_deprecated_stop_predicates.cpp")
create_single_source_cgal_program("test_edge_collapse_stability.cpp")
find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater)
include(CGAL_Eigen3_support)

View File

@ -0,0 +1,90 @@
OFF
36 50 0
104605.80000019073 1217329.6000003815 134.27659606933594
104605.75 1217329.6000003815 134.27859497070312
104605.55000019073 1217329.7999992371 134.29460144042969
104605.80000019073 1217329.7999992371 134.28489685058594
104605.75 1217329.7999992371 134.28680419921875
104605.75 1217329.75 134.28469848632812
104605.55000019073 1217329.75 134.2926025390625
104605.55000019073 1217329.7000007629 134.29060363769531
104605.80000019073 1217329.75 134.28280639648438
104605.84999990463 1217329.7999992371 134.28300476074219
104605.69999980927 1217329.7999992371 134.2886962890625
104605.55000019073 1217329.6499996185 134.28860473632812
104605.55000019073 1217329.6000003815 134.28660583496094
104605.84999990463 1217329.6000003815 134.27470397949219
104605.59999990463 1217329.7999992371 134.2926025390625
104605.75 1217329.7000007629 134.2825927734375
104605.65000009537 1217329.75 134.28860473632812
104605.80000019073 1217329.7000007629 134.28070068359375
104605.84999990463 1217329.75 134.28089904785156
104605.69999980927 1217329.7000007629 134.28460693359375
104605.90000009537 1217329.7999992371 134.28109741210938
104605.90000009537 1217329.6499996185 134.27490234375
104605.90000009537 1217329.7000007629 134.27690124511719
104605.65000009537 1217329.5499992371 134.28059387207031
104605.59999990463 1217329.5 134.28050231933594
104605.90000009537 1217329.5499992371 134.27070617675781
104605.69999980927 1217329.6000003815 134.28059387207031
104605.65000009537 1217329.6499996185 134.28460693359375
104605.59999990463 1217329.7000007629 134.28860473632812
104605.65000009537 1217329.4500007629 134.27650451660156
104605.59999990463 1217329.6000003815 134.28460693359375
104605.55000019073 1217329.5 134.28250122070312
104605.55000019073 1217329.5499992371 134.28450012207031
104605.90000009537 1217329.75 134.27900695800781
104605.84999990463 1217329.7000007629 134.27879333496094
104605.84999990463 1217329.6499996185 134.27679443359375
3 30 23 26
3 3 4 5
3 26 23 1
3 22 33 34
3 8 9 3
3 17 0 35
3 17 1 0
3 4 10 5
3 15 1 17
3 8 3 5
3 15 26 1
3 6 14 2
3 0 25 13
3 35 0 13
3 6 16 14
3 28 16 6
3 7 28 6
3 8 5 15
3 16 10 14
3 8 15 17
3 16 5 10
3 18 8 17
3 16 19 5
3 19 15 5
3 18 20 9
3 18 9 8
3 11 28 7
3 11 27 28
3 21 35 13
3 21 22 35
3 22 34 35
3 31 24 32
3 24 23 32
3 24 29 23
3 29 1 23
3 19 26 15
3 27 26 19
3 28 27 19
3 28 19 16
3 29 0 1
3 30 26 27
3 29 25 0
3 18 33 20
3 34 33 18
3 34 18 17
3 34 17 35
3 32 23 30
3 32 30 12
3 12 30 11
3 30 27 11

View File

@ -0,0 +1,71 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
// Simplification function
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Edge_count_stop_predicate.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_cost.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/LindstromTurk_placement.h>
#include <CGAL/boost/graph/IO/polygon_mesh_io.h>
//bbox
#include <CGAL/Polygon_mesh_processing/bbox.h>
#include <iostream>
#include <fstream>
namespace SMS = CGAL::Surface_mesh_simplification;
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Surface;
typedef SMS::LindstromTurk_cost<Surface> Cost;
typedef SMS::LindstromTurk_placement<Surface> Placement;
int main(int argc, char** argv)
{
std::cout.precision(17);
std::cerr.precision(17);
std::string filename = (argc > 1) ? argv[1] : "data/far_xy.off";
Surface mesh;
if(!CGAL::IO::read_polygon_mesh(filename, mesh))
{
std::cerr << "Failed to read input mesh: " << filename << std::endl;
return EXIT_FAILURE;
}
std::cout << "input has " << num_vertices(mesh) << " vertices." << std::endl;
CGAL::Iso_cuboid_3<Kernel> bbox(CGAL::Polygon_mesh_processing::bbox(mesh));
// scale a bit the bounding box bbox, because the kernel is SC
bbox = { bbox.min() - 0.01 * (bbox.max() - bbox.min()),
bbox.max() + 0.01 * (bbox.max() - bbox.min()) };
std::cout << "Bbox: " << bbox << std::endl;
SMS::Edge_count_stop_predicate<Surface> stop(num_halfedges(mesh)/10);
Placement placement_ref;
SMS::edge_collapse(mesh, stop,
CGAL::parameters::get_cost(Cost())
.get_placement(placement_ref));
CGAL::IO::write_polygon_mesh("out.off", mesh, CGAL::parameters::stream_precision(17));
for(auto v : vertices(mesh))
{
if(bbox.has_on_unbounded_side(mesh.point(v)))
{
std::cerr << "Error: " << mesh.point(v) << " is outside" << std::endl;
}
}
std::cout << "output has " << vertices(mesh).size() << " vertices." << std::endl;
return EXIT_SUCCESS;
}