1 // Copyright (c) 2013 INRIA Sophia-Antipolis (France),
2 //               2014-2015 GeometryFactory (France).
3 // All rights reserved.
4 //
5 // This file is part of CGAL (www.cgal.org).
6 //
7 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Mesh_2/include/CGAL/Constrained_Delaunay_triangulation_face_base_2.h $
8 // $Id: Constrained_Delaunay_triangulation_face_base_2.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
9 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
10 //
11 // Author(s) : Jane Tournois, Raul Gallegos
12 //
13 
14 #ifndef CGAL_CONSTRAINED_DELAUNAY_TRIANGULATION_FACE_BASE_2_H
15 #define CGAL_CONSTRAINED_DELAUNAY_TRIANGULATION_FACE_BASE_2_H
16 
17 #include <CGAL/license/Mesh_2.h>
18 
19 
20 #include <CGAL/triangulation_assertions.h>
21 #include <CGAL/Constrained_triangulation_face_base_2.h>
22 
23 namespace CGAL {
24 
25 template <typename Kernel,
26           class Fb = CGAL::Constrained_triangulation_face_base_2<Kernel> >
27 class Constrained_Delaunay_triangulation_face_base_2
28   : public Fb
29 {
30 public:
31   typedef Fb Base;
32   typedef typename Base::Vertex_handle  Vertex_handle;
33   typedef typename Base::Face_handle    Face_handle;
34   typedef std::pair<Face_handle, int>   Edge_cdt;
35   typedef Constrained_Delaunay_triangulation_face_base_2 CDT_face_base;
36 
37   typedef typename Kernel::Point_2      Point;
38   typedef typename Kernel::Segment_2    Segment;
39 
40   struct Edge
41   {
42     Face_handle face;
43     int index;
EdgeEdge44     Edge()
45       : face(), index(-1)
46     {}
EdgeEdge47     Edge(Face_handle face_, int index_)
48       : face(face_), index(index_)
49     {}
50   };
51 
52 private:
53   bool m_blind;
54   Edge m_blinding_constraint;
55 
56 public:
57   template < typename TDS2 >
58   struct Rebind_TDS {
59     typedef typename Base::template Rebind_TDS<TDS2>::Other Fb2;
60     typedef Constrained_Delaunay_triangulation_face_base_2<Kernel,Fb2>
61       Other;
62   };
63 
64 public:
Constrained_Delaunay_triangulation_face_base_2()65   Constrained_Delaunay_triangulation_face_base_2()
66     : Base(),
67       m_blind(false)
68   {
69   }
Constrained_Delaunay_triangulation_face_base_2(Vertex_handle v1,Vertex_handle v2,Vertex_handle v3)70   Constrained_Delaunay_triangulation_face_base_2( Vertex_handle v1,
71                                                   Vertex_handle v2,
72                                                   Vertex_handle v3)
73     : Base(v1,v2,v3),
74       m_blind(false)
75   {
76   }
Constrained_Delaunay_triangulation_face_base_2(Vertex_handle v1,Vertex_handle v2,Vertex_handle v3,Face_handle f1,Face_handle f2,Face_handle f3)77   Constrained_Delaunay_triangulation_face_base_2( Vertex_handle v1,
78                                                   Vertex_handle v2,
79                                                   Vertex_handle v3,
80                                                   Face_handle f1,
81                                                   Face_handle f2,
82                                                   Face_handle f3)
83     : Base(v1,v2,v3,f1,f2,f3),
84       m_blind(false)
85   {
86   }
Constrained_Delaunay_triangulation_face_base_2(Face_handle f)87   Constrained_Delaunay_triangulation_face_base_2(Face_handle f)
88     : Base(f),
89       m_blind(false)
90   {
91   }
92 
93   // sees its circumcenter or not?
is_blind()94   bool is_blind() const { return m_blind; }
set_blind(const bool b)95   void set_blind(const bool b){ m_blind = b; }
96 
97   // if blind, the constrained edge that prevents the face
98   // to see its circumcenter
blinding_constraint()99   Edge_cdt blinding_constraint() const
100   {
101     CGAL_precondition(this->is_blind());
102     return std::make_pair(m_blinding_constraint.face,
103                           m_blinding_constraint.index);
104   }
set_blinding_constraint(const Edge_cdt & e)105   void set_blinding_constraint(const Edge_cdt& e)
106   {
107     CGAL_precondition(this->is_blind());
108     CGAL_precondition(e.first->is_constrained(e.second));
109     m_blinding_constraint.face = e.first;
110     m_blinding_constraint.index = e.second;
111   }
112 };
113 
114 } //namespace CGAL
115 
116 #endif //CGAL_CONSTRAINED_DELAUNAY_TRIANGULATION_FACE_BASE_2_2_H
117