Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlConvexHull.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef GL_CONVEX_HULL_H
22 #define GL_CONVEX_HULL_H
23 
24 #include <vector>
25 #include <tulip/BoundingBox.h>
26 #include <tulip/Graph.h>
27 #include <tulip/Color.h>
28 #include <tulip/Coord.h>
29 
30 #include <tulip/GlComposite.h>
31 
32 namespace tlp {
33 
34 struct ConvexHullItem;
35 
36 /** \brief Class used to represent ConvexHull
37  *
38  * Class used to represent ConvexHull. GlHierarchyConvexHull class use this to create all convexHull of the graph
39  */
40 class TLP_GL_SCOPE GlConvexHull: public GlComposite {
41 public:
42 
43  /**
44  * Default constructor
45  */
46  GlConvexHull() {}
47 
48  /**
49  * Build a Polygon with the convex hull of points
50  */
51  GlConvexHull(const std::vector<Coord> &points,
52  const std::vector<Color> &fillColors,
53  const std::vector<Color> &outlineColors,
54  const bool filled,
55  const bool outlined,
56  const std::string &name,
57  bool computeHull=true);
58 
59  virtual ~GlConvexHull() {}
60 
61  /**
62  * Function used to visit composite's children
63  */
64  virtual void acceptVisitor(GlSceneVisitor *visitor) {
65  if(boundingBox.isValid()) {
66  visitor->visit(this);
67  }
68 
69  for(std::list<GlSimpleEntity*>::iterator it=_sortedElements.begin(); it!=_sortedElements.end(); ++it) {
70  (*it)->acceptVisitor(visitor);
71  }
72  }
73 
74 
75  /**
76  * Retrun the name of this convex hull
77  */
78  std::string getName() {
79  return _name;
80  }
81 
82  /**
83  * Draw the convexHull
84  */
85  virtual void draw(float lod,Camera *camera);
86 
87  /**
88  * Static function who build a hierarchy of convexHull with the given graph
89  */
90  static ConvexHullItem *buildConvexHullsFromHierarchy(Graph *graph,
91  std::vector<Color> fColors,
92  std::vector<Color> oColors,
93  bool deduceFromChilds = true,
94  Graph *root = NULL,
95  unsigned int depth = 0);
96 
97  /**
98  * Translate entity
99  */
100  virtual void translate(const Coord& mouvement);
101 
102  /**
103  * Function to export data in outString (in XML format)
104  */
105  virtual void getXML(std::string &outString);
106 
107  /**
108  * Function to set data with inString (in XML format)
109  */
110  virtual void setWithXML(const std::string &inString, unsigned int &currentPosition);
111 
112  tlp::Graph *_graph;
113 
114 protected:
115  std::vector<Coord> _points;
116  std::vector<Color> _fillColors;
117  std::vector<Color> _outlineColors;
118  bool _filled;
119  bool _outlined;
120  std::string _name;
121 };
122 
123 struct ConvexHullItem {
124  GlConvexHull* hull;
125  Graph *_graph;
126  std::string name;
127  std::vector<ConvexHullItem *> children;
128 };
129 
130 }
131 #endif
132 ///@endcond