/
Advancing_front_surface_reconstruction_cell_base_3.h
256 lines (210 loc) · 6.79 KB
/
Advancing_front_surface_reconstruction_cell_base_3.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
// Copyright (c) 2015 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) : Frank Da, David Cohen-Steiner, Andreas Fabri
#ifndef CGAL_ADVANCING_FRONT_SURFACE_RECONSTRUCTION_CELL_BASE_3_H
#define CGAL_ADVANCING_FRONT_SURFACE_RECONSTRUCTION_CELL_BASE_3_H
#include <CGAL/license/Advancing_front_surface_reconstruction.h>
#include <CGAL/Delaunay_triangulation_cell_base_3.h>
namespace CGAL {
/*!
\ingroup PkgAdvancingFrontSurfaceReconstructionRef
The class `Advancing_front_surface_reconstruction_cell_base_3` is the default
cell type for the class `Advancing_front_surface_reconstruction`.
\tparam Traits has to be a model of `DelaunayTriangulationTraits_3`.
\tparam Cb has to be a model of `DelaunayTriangulationCellBase_3`.
*/
template < typename Traits, typename Cb = Delaunay_triangulation_cell_base_3<Traits> >
class Advancing_front_surface_reconstruction_cell_base_3 : public Cb
{
public:
template < typename TDS2 >
struct Rebind_TDS {
typedef typename Cb::template Rebind_TDS<TDS2>::Other Cb2;
typedef Advancing_front_surface_reconstruction_cell_base_3<Traits,Cb2> Other;
};
typedef typename Cb::Vertex_handle Vertex_handle;
typedef typename Cb::Cell_handle Cell_handle;
private:
#ifdef AFSR_FACET_NUMBER
int _facet_number[4];
#endif
typedef double coord_type;
#ifdef AFSR_LAZY
typedef typename CGAL::Simple_cartesian<coord_type>::Point_3 D_Point;
#endif
//-------------------- DATA MEMBERS ---------------------------------
coord_type* _smallest_radius_facet_tab;
unsigned char selected_facet;
#ifdef AFSR_LAZY
D_Point* _circumcenter;
coord_type* _squared_radius;
#endif
//-------------------- CONSTRUCTORS ----------------------------------
public:
Advancing_front_surface_reconstruction_cell_base_3()
: Cb(),
_smallest_radius_facet_tab(nullptr), selected_facet(0)
#ifdef AFSR_LAZY
, _circumcenter(nullptr), _squared_radius(nullptr)
#endif
{
#ifdef AFSR_FACET_NUMBER
for(int i = 0; i < 4; i++){
_facet_number[i] = -1;
}
#endif
}
Advancing_front_surface_reconstruction_cell_base_3(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3)
: Cb( v0, v1, v2, v3),
_smallest_radius_facet_tab(nullptr), selected_facet(0)
#ifdef AFSR_LAZY
, _circumcenter(nullptr), _squared_radius(nullptr)
#endif
{
#ifdef FACET_NUMBER
for(int i = 0; i < 4; i++){
_facet_number[i] = -1;
}
#endif
}
Advancing_front_surface_reconstruction_cell_base_3(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3,
Cell_handle n0, Cell_handle n1, Cell_handle n2, Cell_handle n3)
: Cb(v0, v1, v2, v3,
n0, n1, n2, n3),
_smallest_radius_facet_tab(nullptr), selected_facet(0)
#ifdef AFSR_LAZY
, _circumcenter(nullptr), _squared_radius(nullptr)
#endif
{
#ifdef AFSR_FACET_NUMBER
for(int i = 0; i < 4; i++){
_facet_number[i] = -1;
}
#endif
}
//-------------------- DESTRUCTOR -----------------------------------
inline ~Advancing_front_surface_reconstruction_cell_base_3()
{
if (_smallest_radius_facet_tab != nullptr)
delete[] _smallest_radius_facet_tab;
#ifdef AFSR_LAZY
if (_circumcenter != nullptr)
delete _circumcenter;
if (_squared_radius != nullptr)
delete _squared_radius;
#endif
}
//-------------------- MEMBER FUNCTIONS ----------------------------
public:
inline void clear()
{
if (_smallest_radius_facet_tab != nullptr)
delete[] _smallest_radius_facet_tab;
_smallest_radius_facet_tab = nullptr;
selected_facet = 0;
#ifdef AFSR_LAZY
if (_circumcenter != nullptr)
delete _circumcenter;
_circumcenter = nullptr;
if (_squared_radius != nullptr)
delete _squared_radius;
_squared_radius = nullptr;
#endif
}
//-------------------------------------------------------------------
inline coord_type smallest_radius(const int& i)
{
if (_smallest_radius_facet_tab == nullptr)
return -1;
return _smallest_radius_facet_tab[i];
}
inline void set_smallest_radius(const int& i, const coord_type& c)
{
if (_smallest_radius_facet_tab == nullptr)
{
_smallest_radius_facet_tab = new coord_type[4];
for(int i = 0; i < 4; i++)
_smallest_radius_facet_tab[i] = -1;
}
_smallest_radius_facet_tab[i] = c;
}
// pour un controle de l'allocation memoire... utile???
inline bool alloc_smallest_radius_tab(coord_type* ptr)
{
if (_smallest_radius_facet_tab==nullptr)
{
_smallest_radius_facet_tab = ptr;
return true;
}
return false;
}
//-------------------------------------------------------------------
#ifdef FACET_NUMBER
void set_facet_number(int i, int n){}
{
_facet_number[i] = n;
}
int facet_number(int i)
{
return _facet_number[i];
}
#else
void set_facet_number(int, int){}
int facet_number(int){return 0;}
#endif
//-------------------------------------------------------------------
inline void select_facet(const int& i)
{
selected_facet |= (1 << i);
}
inline void unselect_facet(const int& i)
{
selected_facet &= (15 - (1 << i));
}
inline bool is_selected_facet(const int& i)
{
return (selected_facet & (1 << i)) != 0;
}
inline bool has_facet_on_surface(const int& i)
{
return (selected_facet & (1 << i)) != 0;
}
#ifdef AFSR_LAZY
//-------------------------------------------------------------------
inline D_Point* lazy_circumcenter()
{
return _circumcenter;
}
inline void set_lazy_circumcenter(const D_Point& p)
{
_circumcenter = new D_Point(p);
}
//-------------------------------------------------------------------
inline coord_type* lazy_squared_radius()
{
return _squared_radius;
}
inline void set_lazy_squared_radius(const coord_type& sr)
{
_squared_radius = new coord_type(sr);
}
#endif //AFSR_LAZY
};
} // namespace CGAL
#endif // CGAL_ADVANCING_FRONT_SURFACE_RECONSTRUCTION_CELL_BASE_3_H