File: Surface_reconstruction_polygonal_impl.cpp

package info (click to toggle)
cgal 6.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,952 kB
  • sloc: cpp: 811,597; ansic: 208,576; sh: 493; python: 411; makefile: 286; javascript: 174
file content (68 lines) | stat: -rw-r--r-- 2,209 bytes parent folder | download | duplicates (2)
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;
}