Tulip  4.6.0
Better Visualization Through Research
library/tulip-ogl/include/tulip/GlConvexHull.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 #ifndef GL_CONVEX_HULL_H
00022 #define GL_CONVEX_HULL_H
00023 
00024 #include <vector>
00025 
00026 #include <tulip/Color.h>
00027 #include <tulip/GlComposite.h>
00028 
00029 namespace tlp {
00030 
00031 struct ConvexHullItem;
00032 class Graph;
00033 
00034 /** \brief Class used to represent ConvexHull
00035  *
00036  * Class used to represent ConvexHull. GlHierarchyConvexHull class use this to create all convexHull of the graph
00037  */
00038 class TLP_GL_SCOPE GlConvexHull: public GlComposite {
00039 public:
00040 
00041   /**
00042    * Default constructor
00043    */
00044   GlConvexHull() {}
00045 
00046   /**
00047    * Build a Polygon with the convex hull of points
00048    */
00049   GlConvexHull(const std::vector<Coord> &points,
00050                const std::vector<Color> &fillColors,
00051                const std::vector<Color> &outlineColors,
00052                const bool filled,
00053                const bool outlined,
00054                const std::string &name,
00055                bool computeHull=true);
00056 
00057   virtual ~GlConvexHull() {}
00058 
00059   /**
00060    * Function used to visit composite's children
00061    */
00062   virtual void acceptVisitor(GlSceneVisitor *visitor) {
00063     if(boundingBox.isValid()) {
00064       visitor->visit(this);
00065     }
00066 
00067     for(std::list<GlSimpleEntity*>::iterator it=_sortedElements.begin(); it!=_sortedElements.end(); ++it) {
00068       (*it)->acceptVisitor(visitor);
00069     }
00070   }
00071 
00072 
00073   /**
00074    * Retrun the name of this convex hull
00075    */
00076   std::string getName() {
00077     return _name;
00078   }
00079 
00080   /**
00081    * Draw the convexHull
00082    */
00083   virtual void draw(float lod,Camera *camera);
00084 
00085   /**
00086    * Static function who build a hierarchy of convexHull with the given graph
00087    */
00088   static ConvexHullItem *buildConvexHullsFromHierarchy(Graph *graph,
00089       std::vector<Color> fColors,
00090       std::vector<Color> oColors,
00091       bool deduceFromChilds = true,
00092       Graph *root = NULL,
00093       unsigned int depth = 0);
00094 
00095   /**
00096    * Translate entity
00097    */
00098   virtual void translate(const Coord& mouvement);
00099 
00100   /**
00101    * Function to export data in outString (in XML format)
00102    */
00103   virtual void getXML(std::string &outString);
00104 
00105   /**
00106    * Function to set data with inString (in XML format)
00107    */
00108   virtual void setWithXML(const std::string &inString, unsigned int &currentPosition);
00109 
00110   tlp::Graph *_graph;
00111 
00112 protected:
00113   std::vector<Coord> _points;
00114   std::vector<Color> _fillColors;
00115   std::vector<Color> _outlineColors;
00116   bool _filled;
00117   bool _outlined;
00118   std::string _name;
00119 };
00120 
00121 struct ConvexHullItem {
00122   GlConvexHull* hull;
00123   Graph *_graph;
00124   std::string name;
00125   std::vector<ConvexHullItem *> children;
00126 };
00127 
00128 }
00129 #endif
00130 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties