Rumba C++ SDK
Delaunay.h
Go to the documentation of this file.
1 /*
2 
3  *
4  ***
5  *****
6  ********************* Mercenaries Engineering SARL
7  ***************** Copyright (C) 2018
8  *************
9  ********* http://www.mercenaries-engineering.com
10  ***********
11  **** ****
12  ** **
13 
14 */
15 #pragma once
16 
17 #include <vector>
18 #include <mutex>
19 
20 #include <ImathVec.h>
21 
22 #include <Maquina/Export.h>
23 
24 namespace maquina
25 {
27 
32  {
33  public:
36 
39  DelaunayTriangulation2D(const std::vector<Imath::V2d>& points);
40 
42  bool is_inside_super_triangle(const Imath::V2d& p);
43 
48  bool insert(const Imath::V2d& p);
49 
51  std::vector<Imath::V2d> points() const;
52 
55  const std::vector<int>& convex_hull() const;
56 
59  const std::vector<Imath::V3i>& triangulation() const;
60 
63  std::vector<std::pair<int, double>> nnc(const Imath::V2d& p) const;
64 
66  // TODO
67  // Voronoi2D voronoi() const;
68 
70  static bool is_in_circumcircle(const Imath::V2d& p, const Imath::V2d& a, const Imath::V2d& b, const Imath::V2d& c);
71 
72  private:
73  // actually performs the insertion of the i-th point.
74  void perform_insertion(int i);
75  // returns the list of indices of the triangles invalidated by the insertion of p.
76  std::vector<size_t> _invalidated_triangles(const Imath::V2d& p) const;
77  // returns the list of triangle-aware boundary edges of the Bowyer-Watson enveloppe around p.
78  std::vector<Imath::V3i> _bowyer_watson_boundary_edges(const std::vector<size_t>& invalid_triangles) const;
79 
80  int _n_set_points;
81  std::vector<Imath::V2d> _points; // contains the set of points + the additional building points (super-triangle points)
82  std::vector<Imath::V3i> _triangles; // the full triangulation of the point set AND the super triangle
83 
84  mutable std::vector<int> _convex_hull; // the convex hull of the set of points
85  mutable std::vector<Imath::V3i> _triangulation; // the result of the triangulation
86  mutable bool _is_convex_hull_dirty = true; // True if a point has been inserted since the last convex hull request, false otherwise
87  mutable bool _is_triangulation_dirty = true; // True if a point has been inserted since the last triangulation request, false otherwise
88 
89  mutable std::mutex _mutex; // to synchronize accesses
90  };
91 }
A 2D Delaunay triangulation.
Definition: Delaunay.h:31
This version of the SDK is unstable, i-e, it may change with no warning.
Definition: AddCurveAction.h:20
#define MAQUINA_EXPORT
Definition: Export.h:31
Definition: ImathVec.h:61