mirror of https://github.com/CGAL/cgal
add test
This commit is contained in:
parent
d56fe72d33
commit
113079a8f8
|
|
@ -2,9 +2,6 @@
|
|||
#include <CGAL/Polygon_mesh_processing/approximated_centroidal_Voronoi_diagram_remeshing.h>
|
||||
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
|
|
@ -13,7 +10,6 @@ namespace PMP = CGAL::Polygon_mesh_processing;
|
|||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel;
|
||||
typedef CGAL::Surface_mesh<Epic_kernel::Point_3> Mesh;
|
||||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
namespace params = CGAL::parameters;
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ if(TARGET CGAL::Eigen3_support)
|
|||
target_link_libraries(test_decimation_of_planar_patches PRIVATE CGAL::Eigen3_support)
|
||||
create_single_source_cgal_program("remeshing_quality_test.cpp" )
|
||||
target_link_libraries(remeshing_quality_test PRIVATE CGAL::Eigen3_support)
|
||||
create_single_source_cgal_program("test_acvd.cpp" )
|
||||
target_link_libraries(test_acvd PRIVATE CGAL::Eigen3_support)
|
||||
|
||||
else()
|
||||
message(STATUS "NOTICE: Tests that use the Eigen library will not be compiled.")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polygon_mesh_processing/approximated_centroidal_Voronoi_diagram_remeshing.h>
|
||||
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
|
||||
#include <CGAL/Polygon_mesh_processing/bbox.h>
|
||||
#include <CGAL/subdivision_method_3.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
|
||||
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using Mesh = CGAL::Surface_mesh<K::Point_3>;
|
||||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
namespace params = CGAL::parameters;
|
||||
|
||||
void run_test(std::string fname, std::size_t genus)
|
||||
{
|
||||
Mesh mesh;
|
||||
CGAL::IO::read_polygon_mesh(fname, mesh);
|
||||
|
||||
PMP::triangulate_faces(mesh);
|
||||
CGAL::Subdivision_method_3::Loop_subdivision(mesh, params::number_of_iterations(5));
|
||||
|
||||
Mesh ref=mesh;
|
||||
CGAL::Bbox_3 bb_ref = PMP::bbox(ref);
|
||||
|
||||
PMP::approximated_centroidal_Voronoi_diagram_remeshing(mesh, 1000);
|
||||
|
||||
CGAL::Bbox_3 bb = PMP::bbox(ref);
|
||||
|
||||
assert(-(vertices(mesh).size()-edges(mesh).size()+faces(mesh).size()-2)/2==genus);
|
||||
assert(vertices(mesh).size()==1000);
|
||||
|
||||
double dx = bb.xmax()-bb.xmin(),
|
||||
dy = bb.ymax()-bb.ymin(),
|
||||
dz = bb.zmax()-bb.zmin();
|
||||
|
||||
assert(std::abs(bb.xmax()-bb_ref.xmax()) < 0.01 * dx);
|
||||
assert(std::abs(bb.ymax()-bb_ref.ymax()) < 0.01 * dy);
|
||||
assert(std::abs(bb.zmax()-bb_ref.zmax()) < 0.01 * dz);
|
||||
|
||||
std::ofstream("/tmp/out_"+std::to_string(genus)+".off") << mesh;
|
||||
|
||||
PMP::approximated_centroidal_Voronoi_diagram_remeshing(mesh, 4);
|
||||
assert(-(vertices(mesh).size()-edges(mesh).size()+faces(mesh).size()-2)/2==genus);
|
||||
|
||||
std::ofstream("/tmp/min_out_"+std::to_string(genus)+".off") << mesh;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
run_test(CGAL::data_file_path("meshes/tetrahedron.off"), 0);
|
||||
run_test(CGAL::data_file_path("meshes/torus_quad.off"), 1);
|
||||
run_test(CGAL::data_file_path("meshes/double-torus-example.off"), 2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue