#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Alpha_shape_3.h>
#include <CGAL/Periodic_3_regular_triangulation_traits_3.h>
#include <CGAL/Periodic_3_regular_triangulation_3.h>
#include <CGAL/Random.h>
#include <fstream>
#include <iostream>
typedef CGAL::Triangulation_data_structure_3<AsVb,AsCb> Tds;
typedef P3RT3::Bare_point Bare_point;
typedef P3RT3::Weighted_point Weighted_point;
int main()
{
CGAL::Random random(8);
std::list<Weighted_point> pts;
std::ifstream is("./data/bunny_1000");
int n;
is >> n;
std::cout << "Reading " << n << " points " << std::endl;
Bare_point bp;
for( ; n>0 ; n--) {
is >> bp;
Weighted_point p(bp, 0.0001 * random.get_double(0., 0.015625));
pts.push_back(p);
}
P3RT3 prt(PK::Iso_cuboid_3(-0.1,0.,-0.1, 0.1,0.2,0.1));
prt.insert(pts.begin(), pts.end(), true);
if(prt.is_triangulation_in_1_sheet())
{
std::cout << "Switching to 1-sheeted covering" << std::endl;
prt.convert_to_1_sheeted_covering();
}
std::cout << "Periodic Regular computed." << std::endl;
Alpha_shape_3 as(prt);
std::cout << "Alpha shape computed in REGULARIZED mode by default." << std::endl;
Alpha_shape_3::NT alpha_solid = as.find_alpha_solid();
Alpha_shape_3::Alpha_iterator opt = as.find_optimal_alpha(1);
std::cout << "Smallest alpha value to get a solid through data points is " << alpha_solid << std::endl;
std::cout << "Optimal alpha value to get one connected component is " << *opt << std::endl;
as.set_alpha(*opt);
assert(as.number_of_solid_components() == 1);
return 0;
}