File: Simple_feature.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 (72 lines) | stat: -rw-r--r-- 1,978 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
// Copyright (c) 2017 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Classification/include/CGAL/Classification/Feature/Simple_feature.h $
// $Id: include/CGAL/Classification/Feature/Simple_feature.h b26b07a1242 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s)     : Simon Giraudot

#ifndef CGAL_CLASSIFICATION_SIMPLE_FEATURE_H
#define CGAL_CLASSIFICATION_SIMPLE_FEATURE_H

#include <CGAL/license/Classification.h>

#include <vector>
#include <CGAL/Classification/Feature_base.h>

namespace CGAL {

namespace Classification {

namespace Feature {

  /*!
    \ingroup PkgClassificationFeatures

    %Feature based on a user-defined scalar field.

    \tparam InputRange model of `ConstRange`. Its iterator type
    is `RandomAccessIterator`.
    \tparam PropertyMap model of `ReadablePropertyMap` whose key
    type is the value type of the iterator of `PointRange` and value type
    is statically castable to `float`.
  */
template <typename InputRange, typename PropertyMap>
class Simple_feature : public Feature_base
{
  const InputRange& m_input;
  PropertyMap m_pmap;

public:
  /*!
    \brief constructs the feature using an input range and a property map.

    \param input point range.
    \param property_map property map to access scalar field.
    \param name name of the property (no default name is given).
  */
  Simple_feature (const InputRange& input,
                  PropertyMap property_map,
                  const std::string& name)
    : m_input (input), m_pmap (property_map)
  {
    this->set_name (name);
  }
  /// \cond SKIP_IN_MANUAL
  virtual float value (std::size_t pt_index)
  {
    return static_cast<float> (get (m_pmap, *(m_input.begin()+pt_index)));
  }
  /// \endcond
};

} // namespace Feature

} // namespace Classification

} // namespace CGAL

#endif // CGAL_CLASSIFICATION_SIMPLE_FEATURE_H