#include <fstream>
#include <iostream>
#include <algorithm>
#include <CGAL/Scale_space_surface_reconstruction_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/IO/read_off_points.h>
typedef std::vector< Point > Point_collection;
void dump_reconstruction(
const Reconstruction& reconstruct, std::string name)
{
std::ofstream output(name.c_str());
std::ostream_iterator<Point>(output,"\n"));
output << "3 " << *it << std::endl;
}
int main(int argc, char* argv[]) {
Point_collection points;
if (argc!=2){
std::cerr << "Error, no input file provided\n";
return 1;
}
std::ifstream in(argv[1]);
std::cout << "Reading " << std::flush;
if( !in || !CGAL::read_off_points( in, std::back_inserter( points ) ) ) {
std::cerr << "Error: cannot read file" << std::endl;
return EXIT_FAILURE;
}
std::cout << "done: " << points.size() << " points." << std::endl;
reconstruct.insert( points.begin(), points.end() );
reconstruct.increase_scale( 2 );
std::cout << "Neighborhood squared radius is "
<< reconstruct.neighborhood_squared_radius() << std::endl;
reconstruct.reconstruct_surface();
std::cout << "First reconstruction done." << std::endl;
dump_reconstruction(reconstruct, "reconstruction1.off");
reconstruct.increase_scale( 2 );
std::cout << "Neighborhood squared radius is "
<< reconstruct.neighborhood_squared_radius() << std::endl;
reconstruct.reconstruct_surface();
std::cout << "Second reconstruction done." << std::endl;
dump_reconstruction(reconstruct, "reconstruction2.off");
std::cout << "Reconstructions are ready to be examinated in your favorite viewer" << std::endl;
return EXIT_SUCCESS;
}