File: Contour_regularization_2.h

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (83 lines) | stat: -rw-r--r-- 2,579 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2020 GeometryFactory SARL (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Shape_regularization/include/CGAL/Shape_regularization/internal/Contour_regularization_2.h $
// $Id: include/CGAL/Shape_regularization/internal/Contour_regularization_2.h b26b07a1242 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s)     : Dmitry Anisimov, Simon Giraudot
//

#ifndef CGAL_SHAPE_REGULARIZATION_CONTOUR_REGULARIZATION_2_H
#define CGAL_SHAPE_REGULARIZATION_CONTOUR_REGULARIZATION_2_H

#include <CGAL/license/Shape_regularization.h>

// Boost includes.
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Named_function_parameters.h>

// Internal includes.
#include <CGAL/Shape_regularization/internal/Closed_contour_2.h>
#include <CGAL/Shape_regularization/internal/Open_contour_2.h>

namespace CGAL {
namespace Shape_regularization {
namespace internal {

  struct CLOSED { };
  struct OPEN { };

  template<
  typename ContourTag,
  typename ContourDirections,
  typename GeomTraits>
  class Contour_regularization_2 {

  public:
    using Contour_tag = ContourTag;
    using Contour_directions = ContourDirections;
    using Traits = GeomTraits;

    using FT = typename Traits::FT;
    using Regularization = typename std::conditional<
      std::is_same<ContourTag, CLOSED>::value,
      internal::Closed_contour_2<Contour_directions, Traits>,
      internal::Open_contour_2<Contour_directions, Traits> >::type;

    template<
    typename InputRange,
    typename PointMap,
    typename NamedParameters>
    Contour_regularization_2(
      const ContourDirections& directions,
      const InputRange& input_range,
      const PointMap point_map,
      const NamedParameters& np,
      const GeomTraits&) {

      CGAL_precondition(input_range.size() >= 2);
      const FT max_offset_2 = parameters::choose_parameter(
        parameters::get_parameter(np, internal_np::maximum_offset), FT(1) / FT(2));
      m_regularization = std::make_unique<Regularization>(
        directions, max_offset_2);
      m_regularization->initialize(input_range, point_map);
    }

    template<typename OutputIterator>
    OutputIterator regularize(OutputIterator contour) {
      return m_regularization->regularize(contour);
    }

  private:
    std::unique_ptr<Regularization> m_regularization;
  };

} // namespace internal
} // namespace Shape_regularization
} // namespace CGAL

#endif // CGAL_SHAPE_REGULARIZATION_CONTOUR_REGULARIZATION_2_H