Pass a copy of the GT to the VD2 adaptation traits (and not the DTOS)

That's because the previous formulation is awkward:
- VD2 that takes a copy (or a swap) of DT_0 yielding a DT_1;
- adaptation traits requiring a const& to a DT_0, which might then
  go out of scope.

In theory, we want to have the triangulation to get the nice "dt.point(v)",
but it's too heavy to copy the full triangulation just for the adaptations
traits, so just copy the GT and use old school v->point().
This commit is contained in:
Mael Rouxel-Labbé 2021-05-05 16:59:22 +02:00
parent e94127c23c
commit 942d461e4c
3 changed files with 18 additions and 42 deletions

View File

@ -22,15 +22,17 @@
namespace CGAL {
template <typename DTOS>
template <typename DToS2>
struct Delaunay_triangulation_on_sphere_adaptation_traits_2
{
public:
typedef DTOS Delaunay_graph;
typedef typename Delaunay_graph::Geom_traits Geom_traits;
typedef DToS2 Delaunay_graph;
typedef typename DToS2::Geom_traits Geom_traits;
typedef typename Geom_traits::Point_on_sphere_2 Point_2;
typedef Point_2 Site_2;
typedef CGAL_VORONOI_DIAGRAM_2_INS::DToS2_Point_accessor<DTOS> Access_site_2;
typedef CGAL_VORONOI_DIAGRAM_2_INS::DToS2_Voronoi_point_2<DTOS> Construct_Voronoi_point_2;
typedef CGAL_VORONOI_DIAGRAM_2_INS::Point_accessor<Point_2,DToS2,Tag_true> Access_site_2;
typedef CGAL_VORONOI_DIAGRAM_2_INS::DToS2_Voronoi_point_2<DToS2> Construct_Voronoi_point_2;
typedef typename Delaunay_graph::Vertex_handle Delaunay_vertex_handle;
typedef typename Delaunay_graph::Edge Delaunay_edge;
@ -39,22 +41,19 @@ public:
typedef CGAL::Tag_false Has_nearest_site_2;
typedef CGAL_VORONOI_DIAGRAM_2_INS::Null_functor Nearest_site_2;
Delaunay_triangulation_on_sphere_adaptation_traits_2(const DTOS& dtos) : dtos(dtos) { }
Delaunay_triangulation_on_sphere_adaptation_traits_2(const Geom_traits& gt) : gt(gt) { }
Access_site_2 access_site_2_object() const
{ return Access_site_2(dtos); }
{ return Access_site_2(gt); }
Construct_Voronoi_point_2 construct_Voronoi_point_2_object() const
{ return Construct_Voronoi_point_2(dtos); }
{ return Construct_Voronoi_point_2(gt); }
Nearest_site_2 nearest_site_2_object() const
{ return Nearest_site_2(); }
typedef typename Geom_traits::Point_on_sphere_2 Point_2;
typedef Point_2 Site_2;
private:
const DTOS& dtos;
const Geom_traits gt; // intentional copy
};
} //namespace CGAL

View File

@ -77,27 +77,27 @@ public:
//=========================================================================
template<class DTOS>
template<class DToS2>
struct DToS2_Voronoi_point_2
{
private:
typedef typename DTOS::Geom_traits Geom_traits;
typedef typename DToS2::Geom_traits Geom_traits;
typedef typename Geom_traits::Point_on_sphere_2 Point_on_sphere_2;
public:
typedef typename DToS2::Face_handle Face_handle;
typedef Point_on_sphere_2 result_type;
typedef typename DTOS::Face_handle Face_handle;
DToS2_Voronoi_point_2(const DTOS& dtos) : dtos(dtos) { }
DToS2_Voronoi_point_2(const Geom_traits& gt) : gt(gt) { }
result_type operator()(const Face_handle f) const
{
return dtos.geom_traits().construct_circumcenter_on_sphere_2_object()(
dtos.point(f, 0), dtos.point(f, 1), dtos.point(f, 2));
return gt.construct_circumcenter_on_sphere_2_object()(
f->vertex(0)->point(), f->vertex(1)->point(), f->vertex(2)->point());
}
private:
const DTOS& dtos;
const Geom_traits& gt;
};
//=========================================================================

View File

@ -71,29 +71,6 @@ struct Point_accessor
//=========================================================================
template <typename DTOS>
struct DToS2_Point_accessor
{
private:
typedef typename DTOS::Geom_traits::Point_on_sphere_2 Point_on_sphere_2;
public:
typedef const Point_on_sphere_2& result_type;
typedef typename DTOS::Vertex_handle Vertex_handle;
DToS2_Point_accessor(const DTOS& dtos) : dtos(dtos) { }
result_type operator()(const Vertex_handle v) const
{
return dtos.point(v);
}
private:
const DTOS& dtos;
};
//=========================================================================
} // namespace Internal
} // namespace VoronoiDiagram_2
} // namespace CGAL