Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
DrawingTools.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 _DRAWINGTOOLS_H
22 #define _DRAWINGTOOLS_H
23 
24 #include <vector>
25 #include <tulip/Node.h>
26 #include <tulip/Edge.h>
27 #include <tulip/Coord.h>
28 #include <tulip/BoundingBox.h>
29 
30 namespace tlp {
31 
32 template<class itType >
33 struct Iterator;
34 
35 class Graph;
36 class LayoutProperty;
37 class SizeProperty;
38 class DoubleProperty;
39 class BooleanProperty;
40 
41 /**
42  *
43  * Computes the bounding box of a graph according to nodes positions, edges bends,
44  * nodes z-rotations and sizes of elements.
45  *
46  */
47 TLP_SCOPE BoundingBox computeBoundingBox(const Graph *graph,
48  const LayoutProperty *layout,
49  const SizeProperty *size,
50  const DoubleProperty *rotation,
51  const BooleanProperty *selection = NULL);
52 
53 //======================================================================================================
54 
55 /**
56  * Compute the bounding box of graph elements according to node positions, edges bends,
57  * nodes z-rotations and sizes of elements.
58  *
59  * Iterator itN and itE will be deleted after the computations (i.e. no need to delete them yourself).
60  */
61 TLP_SCOPE BoundingBox computeBoundingBox(Iterator<node> *itN,
62  Iterator<edge> *itE,
63  const LayoutProperty *layout,
64  const SizeProperty *size,
65  const DoubleProperty *rotation,
66  const BooleanProperty *selection = NULL);
67 
68 //======================================================================================================
69 
70 /**
71  *
72  * Computes a bounding sphere (or a bounding circle if the graph has a 2D layout) of a graph according to nodes positions, edges bends,
73  * nodes z-rotations and sizes of elements.
74  *
75  * Returns a pair of tlp::Coord whose first member is the center of the bounding sphere (circle for 2D layout)
76  * and second member is the farthest point from the center (computed from graph elements positions).
77  * To get the bounding radius, you have to compute the distance between the two members of the pair
78  * (use the dist method from tlp::Coord).
79  *
80  */
81 
82 TLP_SCOPE std::pair<Coord, Coord> computeBoundingRadius (const Graph *graph,
83  const LayoutProperty *layout,
84  const SizeProperty *size,
85  const DoubleProperty *rotation,
86  const BooleanProperty *selection = NULL);
87 
88 //======================================================================================================
89 
90 /**
91  *
92  * Computes a convex hull of a graph according to nodes positions, edges bends,
93  * nodes z-rotations, and sizes of elements. Only works with 2D layouts.
94  *
95  * Returns a vector of tlp::Coord containing the vertices of the graph convex hull correctly ordered.
96  *
97  */
98 TLP_SCOPE std::vector<Coord> computeConvexHull (const Graph *graph,
99  const LayoutProperty *layout,
100  const SizeProperty *size,
101  const DoubleProperty *rotation,
102  const BooleanProperty *selection = NULL);
103 
104 //======================================================================================================
105 
106 /**
107  *
108  * Computes a convex hull of a set of points,
109  * Only works with 2D layouts.
110  *
111  * Returns a vector of tlp::Coord containing the vertices of the points convex hull correctly ordered.
112  *
113  */
114 TLP_SCOPE std::vector<Coord> computeConvexHull(const std::vector<tlp::Coord> &points);
115 
116 //======================================================================================================
117 
118 
119 /**
120  * Computes the intersection point (if any) of two 3d lines.
121  * Returns true if the line intersects, false otherwise (parallel or skew lines).
122  *
123  */
124 TLP_SCOPE bool computeLinesIntersection(const std::pair<tlp::Coord, tlp::Coord> &line1,
125  const std::pair<tlp::Coord, tlp::Coord> &line2,
126  tlp::Coord &intersectionPoint);
127 
128 //======================================================================================================
129 
130 /**
131  * Computes the centroid of a polygon.
132  * Polygon vertices must be provided correctly ordered in the points vector.
133  *
134  */
135 TLP_SCOPE tlp::Coord computePolygonCentroid(const std::vector<tlp::Coord> &points);
136 
137 
138 }
139 
140 
141 #endif
142 ///@endcond