Added a template parameter to Regular_tr_cell_base on hidden points handling

Before WP<->P implicit conversion changes, one could choose to not keep hidden
points by using `Triangulation_cell_base_3` as cell base instead of
`Regular_triangulation_cell_base_3`. This is not possible anymore as point types
will conflict.

This changes introduces a new template parameter to pass a policy on whether
to keep or discard hidden points.

It is a breaking change since it is placed before the container template
parameter, but it makes more sense that way and the container type template
was not documented.
This commit is contained in:
Mael Rouxel-Labbé 2017-04-27 11:42:34 +02:00
parent de76ccf545
commit 98226c97c4
2 changed files with 79 additions and 10 deletions

View File

@ -0,0 +1,35 @@
// Copyright (c) 2017 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 Lesser 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.
//
// Author(s) : Mael Rouxel-Labbé
#ifndef CGAL_HIDDEN_POINT_MEMORY_POLICY_H
#define CGAL_HIDDEN_POINT_MEMORY_POLICY_H
#include <CGAL/tags.h>
namespace CGAL {
// A policy to select whether hidden points should be cached in cells or discarded
// during the construction of a regular triangulation.
template < typename Tag >
struct Hidden_points_memory_policy : public Tag { };
typedef Hidden_points_memory_policy<Tag_true> Keep_hidden_points;
typedef Hidden_points_memory_policy<Tag_false> Discard_hidden_points;
} // namespace CGAL
#endif // CGAL_HIDDEN_POINT_MEMORY_POLICY_H

View File

@ -25,20 +25,23 @@
#include <CGAL/license/Triangulation_3.h>
#include <CGAL/Hidden_point_memory_policy.h>
#include <CGAL/Triangulation_cell_base_3.h>
#include <boost/core/enable_if.hpp>
#include <list>
#include <CGAL/Triangulation_cell_base_3.h>
namespace CGAL {
template < typename GT,
typename Cb = Triangulation_cell_base_3<GT >,
typename Memory_policy = Keep_hidden_points,
typename C = std::list<typename GT::Weighted_point_3> >
class Regular_triangulation_cell_base_3
: public Cb
{
public:
static const bool DO_HIDE_POINT = true;
typedef typename Cb::Vertex_handle Vertex_handle;
typedef typename Cb::Cell_handle Cell_handle;
@ -54,7 +57,7 @@ public:
template < typename TDS2 >
struct Rebind_TDS {
typedef typename Cb::template Rebind_TDS<TDS2>::Other Cb2;
typedef Regular_triangulation_cell_base_3<GT, Cb2, C> Other;
typedef Regular_triangulation_cell_base_3<GT, Cb2, Memory_policy, C> Other;
};
Regular_triangulation_cell_base_3()
@ -76,14 +79,45 @@ public:
Cell_handle n3)
: Cb(v0, v1, v2, v3, n0, n1, n2, n3) {}
Point_iterator hidden_points_begin() { return _hidden.begin(); }
Point_iterator hidden_points_end() { return _hidden.end(); }
// Memory_policy is Tag_true -------------------------------------------------
template<typename Tag = Memory_policy>
Point_iterator hidden_points_begin(typename boost::enable_if_c<Tag::value>::type* = NULL)
{ return _hidden.begin(); }
template<typename Tag = Memory_policy>
Point_iterator hidden_points_end(typename boost::enable_if_c<Tag::value>::type* = NULL)
{ return _hidden.end(); }
Point_const_iterator hidden_points_begin() const { return _hidden.begin(); }
Point_const_iterator hidden_points_end() const { return _hidden.end(); }
// const versions
template<typename Tag = Memory_policy>
Point_const_iterator hidden_points_begin(typename boost::enable_if_c<Tag::value>::type* = NULL) const
{ return _hidden.begin(); }
template<typename Tag = Memory_policy>
Point_const_iterator hidden_points_end(typename boost::enable_if_c<Tag::value>::type* = NULL) const
{ return _hidden.end(); }
void hide_point (const Weighted_point &p) { _hidden.push_back(p); }
// void unhide_point (Point_iterator i) { _hidden.delete(i); }
template<typename Tag = Memory_policy>
void hide_point(const Weighted_point& p, typename boost::enable_if_c<Tag::value>::type* = NULL)
{ _hidden.push_back(p); }
// Memory_policy is Tag_false ------------------------------------------------
template<typename Tag = Memory_policy>
Point_iterator hidden_points_begin(typename boost::disable_if_c<Tag::value>::type* = NULL)
{ return hidden_points_end(); }
template<typename Tag = Memory_policy>
Point_iterator hidden_points_end(typename boost::disable_if_c<Tag::value>::type* = NULL)
{ return _hidden.end(); }
// const versions
template<typename Tag = Memory_policy>
Point_const_iterator hidden_points_begin(typename boost::disable_if_c<Tag::value>::type* = NULL) const
{ return hidden_points_end(); }
template<typename Tag = Memory_policy>
Point_const_iterator hidden_points_end(typename boost::disable_if_c<Tag::value>::type* = NULL) const
{ return _hidden.end(); }
template<typename Tag = Memory_policy>
void hide_point(const Weighted_point&, typename boost::disable_if_c<Tag::value>::type* = NULL)
{ }
//note this function is not requested by the RegularTriangulationCellBase_3
//it should be replaced everywhere by weighted_circumcenter()