/
AABB_polyhedron_triangle_primitive.h
164 lines (136 loc) · 5.79 KB
/
AABB_polyhedron_triangle_primitive.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright (c) 2009 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Stéphane Tayeb, Pierre Alliez
//
#ifndef CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_
#define CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_
#include <CGAL/license/AABB_tree.h>
#include <CGAL/disable_warnings.h>
#define CGAL_DEPRECATED_HEADER "<CGAL/AABB_polyhedron_triangle_primitive.h>"
#define CGAL_REPLACEMENT_HEADER "<CGAL/AABB_face_graph_triangle_primitive.h>"
#include <CGAL/internal/deprecation_warning.h>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
namespace CGAL {
/// \ingroup PkgAABBTreeRef
/// \deprecated This class is deprecated since \cgal 4.3, the class
/// `AABB_face_graph_triangle_primitive` should be used instead.
///
/// Primitive type that wraps a facet handle of a polyhedron,
/// which is used as id, and allows the construction of the datum on
/// the fly. Since only the facet handle is stored in this primitive,
/// the polyhedron from which the AABB tree is built should not be
/// deleted while the AABB tree is in use.
///
/// \cgalModels `AABBPrimitive`
/// \tparam GeomTraits must provides a \c %Point_3
/// type, used as \c Point, and a \c %Triangle_3 type, used as \c
/// Datum and constructible from three arguments of type \c
/// Point.
/// \tparam Polyhedron must be a
/// \c CGAL::Polyhedron_3 whose points have type \c Point.
///
/// \sa `AABBPrimitive`
/// \sa `AABB_polyhedron_segment_primitive`
template<typename GeomTraits, typename Polyhedron>
class AABB_polyhedron_triangle_primitive
{
public:
typedef typename GeomTraits::Point_3 Point;
/// \name Types
/// @{
/// Id type.
typedef typename Polyhedron::Facet_handle Id;
/// Geometric data type.
typedef typename GeomTraits::Triangle_3 Datum;
/// @}
// Self
typedef AABB_polyhedron_triangle_primitive<GeomTraits, Polyhedron> Self;
// Constructors
AABB_polyhedron_triangle_primitive() {}
AABB_polyhedron_triangle_primitive(const AABB_polyhedron_triangle_primitive& primitive)
{
m_facet_handle = primitive.id();
}
AABB_polyhedron_triangle_primitive(const Id& handle)
: m_facet_handle(handle) { };
AABB_polyhedron_triangle_primitive(const Id* ptr)
: m_facet_handle(*ptr) { };
template <class Iterator>
AABB_polyhedron_triangle_primitive( Iterator it,
typename boost::enable_if<
boost::is_same<Id,typename Iterator::value_type>
>::type* =0
) : m_facet_handle(*it) { }
// Default destructor, copy constructor and assignment operator are ok
// Returns by constructing on the fly the geometric datum wrapped by the primitive
Datum datum() const
{
const Point& a = m_facet_handle->halfedge()->vertex()->point();
const Point& b = m_facet_handle->halfedge()->next()->vertex()->point();
const Point& c = m_facet_handle->halfedge()->next()->next()->vertex()->point();
return Datum(a,b,c);
}
// Returns a point on the primitive
Point reference_point() const
{
return m_facet_handle->halfedge()->vertex()->point();
}
// Returns the identifier
const Id& id() const { return m_facet_handle; }
Id& id() { return m_facet_handle; }
private:
/// The id, here a polyhedron facet handle
Id m_facet_handle;
}; // end class AABB_polyhedron_triangle_primitive
template<typename GeomTraits, typename Polyhedron>
class AABB_const_polyhedron_triangle_primitive
{
public:
/// AABBPrimitive types
typedef typename GeomTraits::Point_3 Point;
typedef typename GeomTraits::Triangle_3 Datum;
typedef typename Polyhedron::Facet_const_handle Id;
/// Constructors
AABB_const_polyhedron_triangle_primitive(const Id& handle)
: m_facet_handle(handle) { };
// Default destructor, copy constructor and assignment operator are ok
/// Returns by constructing on the fly the geometric datum wrapped by the primitive
Datum datum() const
{
const Point& a = m_facet_handle->halfedge()->vertex()->point();
const Point& b = m_facet_handle->halfedge()->next()->vertex()->point();
const Point& c = m_facet_handle->halfedge()->next()->next()->vertex()->point();
return Datum(a,b,c);
}
/// Returns a point on the primitive
Point reference_point() const
{
return m_facet_handle->halfedge()->vertex()->point();
}
/// Returns the identifier
Id id() const { return m_facet_handle; }
private:
/// The id, here a polyhedron facet handle
Id m_facet_handle;
}; // end class AABB_polyhedron_triangle_primitive
} // end namespace CGAL
#include <CGAL/enable_warnings.h>
#endif // CGAL_AABB_POLYHEDRON_TRIANGLE_PRIMITIVE_H_