1 #ifndef SCENE_POLYHEDRON_SHORTEST_PATH_ITEM_H
2 #define SCENE_POLYHEDRON_SHORTEST_PATH_ITEM_H
3 
4 #include "Scene_polyhedron_shortest_path_item_config.h"
5 #include "Scene_polyhedron_item_decorator.h"
6 #include <CGAL/Three/Scene_interface.h>
7 #include "Messages_interface.h"
8 
9 #include "Kernel_type.h"
10 
11 
12 
13 #include <CGAL/Qt/qglviewer.h>
14 #include <QKeyEvent>
15 #include <QMouseEvent>
16 #include <QMainWindow>
17 #include <QObject>
18 
19 #include <string>
20 #include <list>
21 
22 #ifndef Q_MOC_RUN
23 #include <CGAL/Surface_mesh_shortest_path.h>
24 #endif
25 
26 #include <CGAL/AABB_face_graph_triangle_primitive.h>
27 #include <CGAL/AABB_traits.h>
28 #include <CGAL/AABB_tree.h>
29 
30 #include <boost/current_function.hpp>
31 
32 struct Scene_polyhedron_shortest_path_item_priv;
33 
34 class SCENE_POLYHEDRON_SHORTEST_PATH_ITEM_EXPORT Scene_polyhedron_shortest_path_item : public Scene_polyhedron_item_decorator
35 {
36   Q_OBJECT
37 
38   friend class Polyhedron_demo_shortest_path_plugin;
39 
40 public:
41   typedef CGAL::Three::Scene_interface::Bbox Bbox;
42 
43   typedef boost::property_map<Face_graph, CGAL::vertex_point_t>::type VertexPointMap;
44 
45   typedef boost::graph_traits<Face_graph> GraphTraits;
46   typedef GraphTraits::face_descriptor face_descriptor;
47   typedef GraphTraits::face_iterator face_iterator;
48 
49   typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Face_graph> Surface_mesh_shortest_path_traits;
50   typedef CGAL::Surface_mesh_shortest_path<Surface_mesh_shortest_path_traits> Surface_mesh_shortest_path;
51   typedef Surface_mesh_shortest_path::Face_location Face_location;
52   typedef CGAL::AABB_face_graph_triangle_primitive<Face_graph, VertexPointMap> AABB_face_graph_primitive;
53   typedef CGAL::AABB_traits<Kernel, AABB_face_graph_primitive> AABB_face_graph_traits;
54   typedef CGAL::AABB_tree<AABB_face_graph_traits> AABB_face_graph_tree;
55 
56   typedef Surface_mesh_shortest_path_traits::Barycentric_coordinates Barycentric_coordinates;
57   typedef Surface_mesh_shortest_path_traits::Construct_barycentric_coordinates Construct_barycentric_coordinates;
58   typedef Surface_mesh_shortest_path_traits::Ray_3 Ray_3;
59   typedef Surface_mesh_shortest_path_traits::Point_3 Point_3;
60   typedef Surface_mesh_shortest_path_traits::FT FT;
61 
62   enum Selection_mode
63   {
64     INSERT_POINTS_MODE = 0,
65     REMOVE_POINTS_MODE = 1,
66     SHORTEST_PATH_MODE = 2
67   };
68 
69   enum Primitives_mode
70   {
71     VERTEX_MODE = 0,
72     EDGE_MODE = 1,
73     FACE_MODE = 2
74   };
75 
76 public:
77   void common_constructor();
78   Scene_polyhedron_shortest_path_item();
79   Scene_polyhedron_shortest_path_item(Scene_face_graph_item* polyhedronItem, CGAL::Three::Scene_interface* sceneInterface, Messages_interface* messages, QMainWindow* mainWindow);
80   ~Scene_polyhedron_shortest_path_item();
81 
82   void set_selection_mode(Selection_mode mode);
83   Selection_mode get_selection_mode() const;
84   void set_primitives_mode(Primitives_mode mode);
85   Primitives_mode get_primitives_mode() const;
86 
87   virtual bool supportsRenderingMode(RenderingMode m) const;
88   using Scene_polyhedron_item_decorator::draw;
89   virtual void draw(CGAL::Three::Viewer_interface*) const;
90   // Points OpenGL drawing
91   virtual void drawPoints(CGAL::Three::Viewer_interface*) const;
92 
93   virtual Scene_polyhedron_shortest_path_item* clone() const;
94 
95   bool deferred_load(Scene_face_graph_item* polyhedronItem, CGAL::Three::Scene_interface* sceneInterface, Messages_interface* messages, QMainWindow* mainWindow);
96   virtual bool load(const std::string& file_name);
97   virtual bool save(const std::string& file_name) const;
98   void initializeBuffers(CGAL::Three::Viewer_interface *) const;
99   void computeElements() const;
100   void invalidateOpenGLBuffers();
101 protected:
102   void initialize(Scene_face_graph_item* polyhedronItem, CGAL::Three::Scene_interface* sceneInterface, Messages_interface* messages, QMainWindow* mainWindow);
103   void deinitialize();
104 
105   virtual bool isFinite() const;
106   virtual bool isEmpty() const;
107   virtual void compute_bbox()const;
108   virtual QString toolTip() const;
109   friend struct Scene_polyhedron_shortest_path_item_priv;
110   Scene_polyhedron_shortest_path_item_priv* d;
111 
112 protected:
113   bool eventFilter(QObject* /*target*/, QEvent * gen_event);
114 
115 public Q_SLOTS:
116   void poly_item_changed();
117   void connectNewViewer(QObject* o);
118 };
119 
120 #endif // SCENE_POLYHEDRON_SHORTEST_PATH_ITEM_H
121