1 // Copyright (c) 2015 INRIA Sophia-Antipolis (France).
2 // All rights reserved.
3 //
4 // This file is part of CGAL (www.cgal.org).
5 //
6 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Efficient_RANSAC_traits.h $
7 // $Id: Efficient_RANSAC_traits.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
9 //
10 //
11 // Author(s)     : Sven Oesau, Yannick Verdie, Clément Jamin, Pierre Alliez
12 //
13 
14 #ifndef CGAL_SHAPE_DETECTION_EFFICIENT_RANSAC_TRAITS_H
15 #define CGAL_SHAPE_DETECTION_EFFICIENT_RANSAC_TRAITS_H
16 
17 #include <CGAL/license/Shape_detection.h>
18 #include <CGAL/Search_traits_3.h>
19 
20 namespace CGAL {
21   namespace Shape_detection {
22   /*!
23     \ingroup PkgShapeDetectionRANSAC
24     \brief %Default traits class for the `CGAL::Shape_detection::Efficient_RANSAC`.
25 
26     \cgalModels `EfficientRANSACTraits`
27 
28     \tparam Gt must be a model of the concept `Kernel` with `Gt::FT` being `float` or `double`.
29 
30     \tparam InputRange must be a model of `Range` with random access iterators,
31     providing input points and normals through the following property maps.
32 
33     \tparam InputPointMap must be a model of `ReadablePropertyMap` with `std::iterator_traits<Input_range::iterator>::%value_type` as key type and `Geom_traits::Point_3` as value type.
34 
35     \tparam InputNormalMap must be a model of `ReadablePropertyMap` with `std::iterator_traits<Input_range::iterator>::%value_type` as key type and `Geom_traits::Vector_3` as value type.
36   */
37   template <class Gt,
38             class InputRange,
39             class InputPointMap,
40             class InputNormalMap>
41   struct Efficient_RANSAC_traits {
42     ///
43     typedef typename Gt::FT FT;
44     ///
45     typedef typename Gt::Point_3 Point_3;
46     ///
47     typedef typename Gt::Vector_3 Vector_3;
48     ///
49     typedef typename Gt::Sphere_3 Sphere_3;
50     ///
51     typedef typename Gt::Segment_3 Segment_3;
52     ///
53     typedef typename Gt::Line_3 Line_3;
54     ///
55     typedef typename Gt::Circle_2 Circle_2;
56     ///
57     typedef typename Gt::Plane_3 Plane_3;
58     ///
59     typedef typename Gt::Point_2 Point_2;
60     ///
61     typedef typename Gt::Vector_2 Vector_2;
62     ///
63     typedef InputRange Input_range;
64     ///
65     typedef InputPointMap Point_map;
66     ///
67     typedef InputNormalMap Normal_map;
68     ///
69     typedef CGAL::Search_traits_3<Gt> Search_traits;
70     ///
71     Efficient_RANSAC_traits(const Gt& gt =  Gt())
m_gtEfficient_RANSAC_traits72       : m_gt(gt) {}
73 
74     typedef typename Gt::Construct_point_3 Construct_point_3;
construct_point_3_objectEfficient_RANSAC_traits75     Construct_point_3 construct_point_3_object() const
76     { return m_gt.construct_point_3_object(); }
77 
78     typedef typename Gt::Construct_vector_3 Construct_vector_3;
construct_vector_3_objectEfficient_RANSAC_traits79     Construct_vector_3 construct_vector_3_object() const
80     { return m_gt.construct_vector_3_object(); }
81 
82     typedef typename Gt::Construct_point_2 Construct_point_2;
construct_point_2_objectEfficient_RANSAC_traits83     Construct_point_2 construct_point_2_object() const
84     { return m_gt.construct_point_2_object(); }
85 
86     typedef typename Gt::Construct_vector_2 Construct_vector_2;
construct_vector_2_objectEfficient_RANSAC_traits87     Construct_vector_2 construct_vector_2_object() const
88     { return m_gt.construct_vector_2_object(); }
89 
90     typedef typename Gt::Construct_sphere_3 Construct_sphere_3;
construct_sphere_3_objectEfficient_RANSAC_traits91     Construct_sphere_3 construct_sphere_3_object() const
92     { return m_gt.construct_sphere_3_object(); }
93 
94     typedef typename Gt::Construct_line_3 Construct_line_3;
construct_line_3_objectEfficient_RANSAC_traits95     Construct_line_3 construct_line_3_object() const
96     { return m_gt.construct_line_3_object(); }
97 
98     typedef typename Gt::Construct_circle_2 Construct_circle_2;
construct_circle_2_objectEfficient_RANSAC_traits99     Construct_circle_2 construct_circle_2_object() const
100     { return m_gt.construct_circle_2_object(); }
101 
102     typedef typename Gt::Construct_point_on_3 Construct_point_on_3;
construct_point_on_3_objectEfficient_RANSAC_traits103     Construct_point_on_3 construct_point_on_3_object() const
104     { return m_gt.construct_point_on_3_object(); }
105 
106     typedef typename Gt::Compute_x_2 Compute_x_2;
compute_x_2_objectEfficient_RANSAC_traits107     Compute_x_2 compute_x_2_object() const
108     { return m_gt.compute_x_2_object(); }
109 
110     typedef typename Gt::Compute_y_2 Compute_y_2;
compute_y_2_objectEfficient_RANSAC_traits111     Compute_y_2 compute_y_2_object() const
112     { return m_gt.compute_y_2_object(); }
113 
114     typedef typename Gt::Compute_x_3 Compute_x_3;
compute_x_3_objectEfficient_RANSAC_traits115     Compute_x_3 compute_x_3_object() const
116     { return m_gt.compute_x_3_object(); }
117 
118     typedef typename Gt::Compute_y_3 Compute_y_3;
compute_y_3_objectEfficient_RANSAC_traits119     Compute_y_3 compute_y_3_object() const
120     { return m_gt.compute_y_3_object(); }
121 
122     typedef typename Gt::Compute_z_3 Compute_z_3;
compute_z_3_objectEfficient_RANSAC_traits123     Compute_z_3 compute_z_3_object() const
124     { return m_gt.compute_z_3_object(); }
125 
126     typedef typename Gt::Compute_squared_length_3 Compute_squared_length_3;
compute_squared_length_3_objectEfficient_RANSAC_traits127     Compute_squared_length_3 compute_squared_length_3_object() const
128     { return m_gt.compute_squared_length_3_object(); }
129 
130     typedef typename Gt::Compute_squared_length_2 Compute_squared_length_2;
compute_squared_length_2_objectEfficient_RANSAC_traits131     Compute_squared_length_2 compute_squared_length_2_object() const
132     { return m_gt.compute_squared_length_2_object(); }
133 
134     typedef typename Gt::Construct_scaled_vector_3 Construct_scaled_vector_3;
construct_scaled_vector_3_objectEfficient_RANSAC_traits135     Construct_scaled_vector_3 construct_scaled_vector_3_object() const
136     { return m_gt.construct_scaled_vector_3_object(); }
137 
138     typedef typename Gt::Construct_sum_of_vectors_3 Construct_sum_of_vectors_3;
construct_sum_of_vectors_3_objectEfficient_RANSAC_traits139     Construct_sum_of_vectors_3 construct_sum_of_vectors_3_object() const
140     { return m_gt.construct_sum_of_vectors_3_object(); }
141 
142     typedef typename Gt::Construct_translated_point_3 Construct_translated_point_3;
construct_translated_point_3_objectEfficient_RANSAC_traits143     Construct_translated_point_3 construct_translated_point_3_object() const
144     { return m_gt.construct_translated_point_3_object(); }
145 
146     typedef typename Gt::Compute_scalar_product_3 Compute_scalar_product_3;
compute_scalar_product_3_objectEfficient_RANSAC_traits147     Compute_scalar_product_3 compute_scalar_product_3_object() const
148     { return m_gt.compute_scalar_product_3_object(); }
149 
150     typedef typename Gt::Construct_cross_product_vector_3 Construct_cross_product_vector_3;
construct_cross_product_vector_3_objectEfficient_RANSAC_traits151     Construct_cross_product_vector_3 construct_cross_product_vector_3_object() const
152     { return m_gt.construct_cross_product_vector_3_object(); }
153 
154     typedef typename Gt::Construct_center_3 Construct_center_3;
construct_center_3_objectEfficient_RANSAC_traits155     Construct_center_3 construct_center_3_object() const
156     { return m_gt.construct_center_3_object(); }
157 
158     typedef typename Gt::Construct_center_2 Construct_center_2;
construct_center_2_objectEfficient_RANSAC_traits159     Construct_center_2 construct_center_2_object() const
160     { return m_gt.construct_center_2_object(); }
161 
162     typedef typename Gt::Compute_squared_radius_3 Compute_squared_radius_3;
compute_squared_radius_3_objectEfficient_RANSAC_traits163     Compute_squared_radius_3 compute_squared_radius_3_object() const
164     { return m_gt.compute_squared_radius_3_object(); }
165 
166     typedef typename Gt::Compute_squared_radius_2 Compute_squared_radius_2;
compute_squared_radius_2_objectEfficient_RANSAC_traits167     Compute_squared_radius_2 compute_squared_radius_2_object() const
168     { return m_gt.compute_squared_radius_2_object(); }
169 
170     typedef typename Gt::Collinear_2 Collinear_2;
collinear_2_objectEfficient_RANSAC_traits171     Collinear_2 collinear_2_object() const
172     { return m_gt.collinear_2_object(); }
173 
174     ///
175     typedef typename Gt::Intersect_3 Intersect_3;
176     ///
intersection_3_objectEfficient_RANSAC_traits177     Intersect_3 intersection_3_object() const
178     { return m_gt.intersection_3_object(); }
179 
180   private:
181     Gt m_gt;
182   };
183 
184 } } // end of namespace CGAL::Shape_detection
185 
186 #endif // CGAL_SHAPE_DETECTION_EFFICIENT_RANSAC_TRAITS_H
187