32 #ifndef DROP_CGAL // in case we do not have the code for CGAL
34 #ifndef __FASTJET_DNNPLANE_HH__
35 #define __FASTJET_DNNPLANE_HH__
37 #include "fastjet/internal/Triangulation.hh"
38 #include "fastjet/internal/DynamicNearestNeighbours.hh"
40 FASTJET_BEGIN_NAMESPACE
56 class DnnPlane :
public DynamicNearestNeighbours {
63 DnnPlane(
const std::vector<EtaPhi> &,
const bool & verbose =
false );
68 int NearestNeighbourIndex(
const int ii)
const ;
72 double NearestNeighbourDistance(
const int ii)
const ;
77 bool Valid(
const int index)
const;
79 void RemoveAndAddPoints(
const std::vector<int> & indices_to_remove,
80 const std::vector<EtaPhi> & points_to_add,
81 std::vector<int> & indices_added,
82 std::vector<int> & indices_of_updated_neighbours);
85 EtaPhi etaphi(
const int i)
const;
87 double eta(
const int i)
const;
89 double phi(
const int i)
const;
104 std::vector<SuperVertex> _supervertex;
109 static const bool _crash_on_coincidence =
false;
115 inline double _euclid_distance(
const Point& p1,
const Point& p2)
const {
116 double distx= p1.x()-p2.x();
117 double disty= p1.y()-p2.y();
118 return distx*distx+disty*disty;
124 void _SetNearest(
const int j);
136 void _SetAndUpdateNearest(
const int j,
137 std::vector<int> & indices_of_updated_neighbours);
143 int _CheckIfVertexPresent(
const Vertex_handle & vertex,
144 const int its_index);
155 inline bool _is_closer_to(
const Point &pref,
156 const Point &candidate,
157 const Vertex_handle &near,
160 dist = _euclid_distance(pref, candidate);
161 return _is_closer_to_with_hint(pref, candidate, near, dist, mindist);
166 inline bool _is_closer_to_with_hint(
const Point &pref,
167 const Point &candidate,
168 const Vertex_handle &near,
191 if ((std::abs(dist-mindist)<DISTANCE_FOR_CGAL_CHECKS) &&
192 _is_not_null(near) &&
193 (_euclid_distance(candidate, near->point())<DISTANCE_FOR_CGAL_CHECKS)){
201 if (_verbose) std::cout <<
"using CGAL's distance ordering" << std::endl;
202 if (CGAL::compare_distance_to_point(pref, candidate, near->point())!=CGAL::LARGER){
206 }
else if (dist <= mindist) {
223 static const double DISTANCE_FOR_CGAL_CHECKS;
231 inline static bool _is_not_null(
const Vertex_handle & vh) {
239 return vh.operator->();
248 inline int DnnPlane::NearestNeighbourIndex(
const int ii)
const {
249 return _supervertex[ii].NNindex;}
251 inline double DnnPlane::NearestNeighbourDistance(
const int ii)
const {
252 return _supervertex[ii].NNdistance;}
254 inline bool DnnPlane::Valid(
const int index)
const {
255 if (index >= 0 && index < static_cast<int>(_supervertex.size())) {
256 return _is_not_null(_supervertex[index].vertex);
264 inline EtaPhi DnnPlane::etaphi(
const int i)
const {
265 Point * p = & (_supervertex[i].vertex->point());
266 return EtaPhi(p->x(),p->y()); }
268 inline double DnnPlane::eta(
const int i)
const {
269 return _supervertex[i].vertex->point().x(); }
271 inline double DnnPlane::phi(
const int i)
const {
272 return _supervertex[i].vertex->point().y(); }
275 FASTJET_END_NAMESPACE
277 #endif // __FASTJET_DNNPLANE_HH__