/usr/include/CGAL/Delaunay_mesher_2.h is in libcgal-dev 4.11-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | // Copyright (c) 2004-2006 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$
//
//
// Author(s) : Laurent RINEAU
#ifndef CGAL_DELAUNAY_MESHER_2_H
#define CGAL_DELAUNAY_MESHER_2_H
#include <CGAL/license/Mesh_2.h>
#include <CGAL/Mesh_2/Refine_edges_with_clusters.h>
#include <CGAL/Mesh_2/Refine_edges_visitor.h>
#include <CGAL/Mesh_2/Refine_faces.h>
namespace CGAL {
template <typename Tr, typename Crit>
class Delaunay_mesher_2
{
/** \name \c Tr types */
typedef typename Tr::Vertex_handle Vertex_handle;
typedef typename Tr::Face_handle Face_handle;
typedef typename Tr::Edge Edge;
typedef typename Tr::Point Point;
/** \name Types needed for private member datas */
typedef Mesh_2::Refine_edges_with_clusters<Tr,
Mesh_2::Is_locally_conforming_Gabriel<Tr> > Edges_level;
typedef Mesh_2::Refine_faces<Tr, Crit, Edges_level> Faces_level;
public:
typedef Tr Triangulation;
typedef Crit Criteria;
typedef Mesh_2::Clusters<Tr> Clusters;
/** \name Types needed to mark the domain for Delaunay_mesh_2<Tr> */
typedef std::list<Point> Seeds;
typedef typename Seeds::const_iterator Seeds_iterator;
typedef Seeds_iterator Seeds_const_iterator;
private:
// --- PRIVATE MEMBER DATAS ---
Tr& tr;
Criteria criteria;
Null_mesher_level null_level;
Null_mesh_visitor null_visitor;
Clusters clusters_;
Edges_level edges_level;
Faces_level faces_level;
Mesh_2::Refine_edges_visitor_from_faces<Faces_level> visitor;
Seeds seeds;
bool seeds_mark;
public:
/** \name CONSTRUCTORS */
Delaunay_mesher_2(Tr& tr_, const Criteria& criteria_ = Criteria())
: tr(tr_),
criteria(criteria_),
null_level(),
null_visitor(),
clusters_(tr),
edges_level(tr, clusters_, null_level),
faces_level(tr, criteria, edges_level),
visitor(faces_level, edges_level, null_visitor),
initialized(false)
{
}
Delaunay_mesher_2(Tr& tr_, Edges_level& edges_level_,
const Criteria& criteria_ = Criteria())
: tr(tr_),
criteria(criteria_),
null_level(),
null_visitor(),
clusters_(tr),
edges_level(edges_level_),
faces_level(tr, criteria, edges_level),
visitor(faces_level, null_visitor),
initialized(false)
{
}
/** SEEDS HANDLING FUNCTIONS */
Seeds_const_iterator seeds_begin() const
{
return seeds.begin();
}
Seeds_const_iterator seeds_end() const
{
return seeds.end();
}
private:
/** \name INITIALIZED */
bool initialized;
public:
/** \name MARKING FUNCTIONS */
/** The value type of \a InputIterator should be \c Point, and represents
seeds. Connected components of seeds are marked with the value of
\a mark. Other components are marked with \c !mark. The connected
component of infinite faces is always marked with \c false.
*/
template <class InputIterator>
void set_seeds(InputIterator b, InputIterator e,
const bool mark = false,
const bool do_it_now = false)
{
seeds.clear();
std::copy(b, e, std::back_inserter(seeds));
seeds_mark=mark;
if(do_it_now) mark_facets();
}
void clear_seeds()
{
seeds.clear();
seeds_mark = false;
}
void mark_facets(bool domain_specified = false)
{
if(!domain_specified) {
mark_facets(tr, seeds.begin(), seeds.end(), seeds_mark);
}
else {
propagate_marks(tr.infinite_face(), false);
}
}
/** Procedure that marks facets according to a list of seeds. */
template <typename Seeds_it>
static void mark_facets(Tr& tr,
Seeds_it begin,
Seeds_it end,
bool mark = false)
{
if (tr.dimension()<2) return;
if( begin != end )
{
for(typename Tr::All_faces_iterator it=tr.all_faces_begin();
it!=tr.all_faces_end();
++it)
it->set_in_domain(!mark);
for(Seeds_it sit=begin; sit!=end; ++sit)
{
Face_handle fh=tr.locate(*sit);
if(fh!=NULL)
propagate_marks(fh, mark);
}
propagate_marks(tr.infinite_face(), false);
}
else
mark_convex_hull(tr);
}
/**
* Marks all faces of the convex hull but those connected to the
* infinite faces.
*/
static void mark_convex_hull(Tr& tr)
{
for(typename Tr::All_faces_iterator fit=tr.all_faces_begin();
fit!=tr.all_faces_end();
++fit)
fit->set_in_domain(true);
propagate_marks(tr.infinite_face(), false);
}
/** Propagates the mark \c mark recursivly. */
static void propagate_marks(const Face_handle fh, bool mark)
{
// std::queue only works with std::list on VC++6, and not with
// std::deque, which is the default
// But it should be fixed by VC++7 know. [Laurent Rineau 2003/03/24]
std::queue<Face_handle/*, std::list<Face_handle>*/> face_queue;
fh->set_in_domain(mark);
face_queue.push(fh);
while( !face_queue.empty() )
{
Face_handle fh = face_queue.front();
face_queue.pop();
for(int i=0;i<3;i++)
{
const Face_handle& nb = fh->neighbor(i);
if( !fh->is_constrained(i) && (mark != nb->is_in_domain()) )
{
nb->set_in_domain(mark);
face_queue.push(nb);
}
}
}
}
/** \name MESHING FUNCTIONS */
void refine_mesh()
{
if(initialized != true) init();
faces_level.refine(visitor);
}
/** \name REMESHING FUNCTIONS */
void set_criteria(const Criteria& criteria_,
bool recalculate_bad_faces = true)
{
criteria = criteria_;
if (recalculate_bad_faces) faces_level.scan_triangulation();
}
const Criteria& get_criteria() const
{
return criteria;
}
template <class Fh_it>
void set_bad_faces(Fh_it begin, Fh_it end)
{
faces_level.set_bad_faces(begin, end);
}
/** \name STEP BY STEP FUNCTIONS */
/**
Initialize the data structures
(The call of this function is REQUIRED before any step by step
operation).
*/
void init(bool domain_specified = false)
{
mark_facets(domain_specified);
clusters_.create_clusters();
edges_level.scan_triangulation();
faces_level.scan_triangulation();
initialized = true;
}
bool is_refinement_done ()
{
return faces_level.is_algorithm_done();
}
bool
step_by_step_refine_mesh()
{
return faces_level.try_to_insert_one_point(visitor);
}
bool try_one_step_refine_mesh()
{
return faces_level.one_step(visitor);
}
/** \name ACCESS FUNCTIONS */
const Mesh_2::Clusters<Tr>& clusters() const
{
return clusters_;
}
const Triangulation& triangulation() const
{
return tr;
}
/** \name DEBUGGING FUNCTIONS */
typedef typename Edges_level::Constrained_edge Constrained_edge;
bool is_edges_refinement_done()
{
return edges_level.is_algorithm_done();
}
Edge next_encroached_edge()
{
return edges_level.get_next_element();
}
const Face_handle next_bad_face()
{
return faces_level.get_next_element();
}
const Point next_refinement_point()
{
if( !edges_level.is_algorithm_done() )
return edges_level.refinement_point(next_encroached_edge());
else
return faces_level.refinement_point(next_bad_face());
}
typedef typename Edges_level::Edges_const_iterator
Encroached_edges_const_iterator;
typedef typename Faces_level::Bad_faces_const_iterator
Bad_faces_const_iterator;
Encroached_edges_const_iterator encroached_edges_begin() const
{
return edges_level.begin();
}
Encroached_edges_const_iterator encroached_edges_end() const
{
return edges_level.end();
}
Bad_faces_const_iterator bad_faces_begin() const
{
return faces_level.begin();
}
Bad_faces_const_iterator bad_faces_end() const
{
return faces_level.end();
}
}; // end class Delaunay_mesher_2
// --- GLOBAL FUNCTIONS ---
template <typename Tr, typename Criteria>
void
refine_Delaunay_mesh_2(Tr& t,
const Criteria& criteria = Criteria(), bool domain_specified=false)
{
typedef Delaunay_mesher_2<Tr, Criteria> Mesher;
Mesher mesher(t, criteria);
mesher.init(domain_specified);
mesher.refine_mesh();
}
template <typename Tr, typename Criteria, typename InputIterator>
void
refine_Delaunay_mesh_2(Tr& t,
InputIterator b, InputIterator e,
const Criteria& criteria = Criteria(),
bool mark = false)
{
typedef Delaunay_mesher_2<Tr, Criteria> Mesher;
Mesher mesher(t, criteria);
mesher.set_seeds(b, e, mark);
mesher.refine_mesh();
}
} // end namespace CGAL
#endif // CGAL_DELAUNAY_MESHER_2_H
|