#include <CGAL/Periodic_3_mesh_3/config.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/make_periodic_3_mesh_3.h>
#include <CGAL/optimize_periodic_3_mesh_3.h>
#include <CGAL/Periodic_3_mesh_triangulation_3.h>
#include <CGAL/Periodic_3_mesh_3/IO/File_medit.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/number_type_config.h>
#include <cmath>
#include <iostream>
#include <fstream>
typedef K::FT FT;
typedef K::Point_3 Point;
typedef K::Iso_cuboid_3 Iso_cuboid;
typedef FT (Function)(const Point&);
typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3;
FT double_p(const Point& p)
{
const FT cx = std::cos(2 * CGAL_PI * p.x()),
cy = std::cos(2 * CGAL_PI * p.y()),
cz = std::cos(2 * CGAL_PI * p.z());
const FT c2x = std::cos(4 * CGAL_PI * p.x()),
c2y = std::cos(4 * CGAL_PI * p.y()),
c2z = std::cos(4 * CGAL_PI * p.z());
return 0.5 * (cx*cy + cy*cz + cz*cx) + 0.2 * (c2x + c2y + c2z);
}
int main(int argc, char** argv)
{
int domain_size = (argc > 1) ? atoi(argv[1]) : 1;
int number_of_copies_in_output = (argc > 2) ? atoi(argv[2]) : 8;
Iso_cuboid canonical_cube(0, 0, 0, domain_size, domain_size, domain_size);
Periodic_mesh_domain domain =
Periodic_mesh_domain::create_implicit_mesh_domain(double_p, canonical_cube);
Periodic_mesh_criteria criteria(params::facet_angle(30)
.facet_size(0.05 * domain_size)
.facet_distance(0.025 * domain_size)
.cell_radius_edge_ratio(2.)
.cell_size(0.05 * domain_size));
C3t3 c3t3 = CGAL::make_periodic_3_mesh_3<C3t3>(domain, criteria,
params::odt(params::convergence(0.03).freeze_bound(0.02).time_limit(30)),
params::lloyd(params::max_iteration_number(10)),
params::perturb(params::sliver_bound(10).time_limit(30)),
params::exude(params::sliver_bound(10).time_limit(0)));
std::ofstream medit_file("output_implicit_shape_optimized.mesh");
CGAL::IO::output_periodic_mesh_to_medit(medit_file, c3t3);
C3t3 c3t3_bis = CGAL::make_periodic_3_mesh_3<C3t3>(domain, criteria,
params::no_odt().
no_lloyd().
no_perturb().
no_exude());
std::ofstream medit_file_bis("output_implicit_shape_non-optimized.mesh");
CGAL::IO::output_periodic_mesh_to_medit(medit_file_bis, c3t3_bis);
std::ofstream medit_file_ter("output_implicit_shape_two_steps.mesh");
CGAL::IO::output_periodic_mesh_to_medit(medit_file_ter, c3t3_bis, number_of_copies_in_output);
std::cout << "EXIT SUCCESS" << std::endl;
return 0;
}
Mesh_optimization_return_code lloyd_optimize_periodic_3_mesh_3(C3T3 &c3t3, const MeshDomain &domain, const NamedParameters &np=parameters::default_values())
The function lloyd_optimize_periodic_3_mesh_3() is a periodic mesh optimization process based on the ...
Definition: optimize_periodic_3_mesh_3.h:183
Mesh_optimization_return_code perturb_periodic_3_mesh_3(C3T3 &c3t3, const MeshDomain &domain, const NamedParameters &np=parameters::default_values())
The function perturb_periodic_3_mesh_3() is a mesh optimizer that improves the quality of a Delaunay ...
Definition: optimize_periodic_3_mesh_3.h:37
Mesh_optimization_return_code exude_periodic_3_mesh_3(C3T3 &c3t3, const NamedParameters &np=parameters::default_values())
The function exude_periodic_3_mesh_3() performs a sliver exudation process on a periodic Delaunay mes...
Definition: optimize_periodic_3_mesh_3.h:90
Mesh_optimization_return_code odt_optimize_periodic_3_mesh_3(C3T3 &c3t3, const MeshDomain &domain, const NamedParameters &np=parameters::default_values())
The function odt_optimize_periodic_3_mesh_3() is a periodic mesh optimization process based on the mi...
Definition: optimize_periodic_3_mesh_3.h:134