1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <CGAL/Polygonal_surface_reconstruction.h>
#include "Kernel_type.h"
#include "SMesh_type.h"
#include "Scene_points_with_normal_item.h"
#ifdef CGAL_USE_SCIP
# include <CGAL/SCIP_mixed_integer_program_traits.h>
#endif
#ifdef CGAL_USE_GLPK
# include <CGAL/GLPK_mixed_integer_program_traits.h>
#endif
typedef CGAL::Polygonal_surface_reconstruction<Kernel> Polygonal_surface_reconstruction;
SMesh* polygonal_reconstruct (const Point_set& points,
double data_fitting,
double data_coverage,
double model_complexity,
const QString& solver_name)
{
// Avoid warnings if no solver is available
CGAL_USE (data_fitting);
CGAL_USE (data_coverage);
CGAL_USE (model_complexity);
CGAL_USE (solver_name);
Point_set::Property_map<int> shape_map
= points.property_map<int>("shape").value();
Polygonal_surface_reconstruction poly
(points, points.point_map(), points.normal_map(), shape_map);
SMesh* mesh = new SMesh;
#if defined(CGAL_USE_SCIP)
if (solver_name == QString("SCIP"))
{
if (!poly.reconstruct<CGAL::SCIP_mixed_integer_program_traits<double> >(*mesh,
data_fitting,
data_coverage,
model_complexity))
{
std::cerr << "Error: " << poly.error_message() << std::endl;
delete mesh;
return nullptr;
}
}
#endif
#if defined(CGAL_USE_GLPK)
if (solver_name == QString("GLPK"))
{
if (!poly.reconstruct<CGAL::GLPK_mixed_integer_program_traits<double> >(*mesh,
data_fitting,
data_coverage,
model_complexity))
{
std::cerr << "Error: " << poly.error_message() << std::endl;
delete mesh;
return nullptr;
}
}
#endif
return mesh;
}
|