Tulip  4.6.0
Better Visualization Through Research
library/tulip-core/include/tulip/DrawingTools.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 _DRAWINGTOOLS_H
00022 #define _DRAWINGTOOLS_H
00023 
00024 #include <vector>
00025 #include <tulip/Node.h>
00026 #include <tulip/Edge.h>
00027 #include <tulip/Coord.h>
00028 #include <tulip/BoundingBox.h>
00029 #include <tulip/Matrix.h>
00030 
00031 namespace tlp {
00032 
00033 template<class itType >
00034 struct Iterator;
00035 
00036 class Graph;
00037 class LayoutProperty;
00038 class SizeProperty;
00039 class DoubleProperty;
00040 class BooleanProperty;
00041 
00042 typedef Matrix<float, 3> Mat3f;
00043 
00044 /**
00045   *
00046   * Computes the bounding box of a graph according to nodes positions, edges bends,
00047   * nodes z-rotations and sizes of elements.
00048   *
00049   */
00050 TLP_SCOPE   BoundingBox computeBoundingBox(const Graph *graph,
00051     const LayoutProperty *layout,
00052     const SizeProperty *size,
00053     const DoubleProperty *rotation,
00054     const BooleanProperty *selection = NULL);
00055 
00056 //======================================================================================================
00057 
00058 /**
00059  * Compute the bounding box of graph elements according to node positions, edges bends,
00060  * nodes z-rotations and sizes of elements.
00061  *
00062  * Iterator itN and itE will be deleted after the computations (i.e. no need to delete them yourself).
00063  */
00064 TLP_SCOPE BoundingBox computeBoundingBox(Iterator<node> *itN,
00065     Iterator<edge> *itE,
00066     const LayoutProperty *layout,
00067     const SizeProperty *size,
00068     const DoubleProperty *rotation,
00069     const BooleanProperty *selection = NULL);
00070 
00071 //======================================================================================================
00072 
00073 /**
00074   *
00075   * Computes a bounding sphere (or a bounding circle if the graph has a 2D layout) of a graph according to nodes positions, edges bends,
00076   * nodes z-rotations and sizes of elements.
00077   *
00078   * Returns a pair of tlp::Coord whose first member is the center of the bounding sphere (circle for 2D layout)
00079   * and second member is the farthest point from the center (computed from graph elements positions).
00080   * To get the bounding radius, you have to compute the distance between the two members of the pair
00081   * (use the dist method from tlp::Coord).
00082   *
00083   */
00084 
00085 TLP_SCOPE   std::pair<Coord, Coord> computeBoundingRadius (const Graph *graph,
00086     const LayoutProperty *layout,
00087     const SizeProperty *size,
00088     const DoubleProperty *rotation,
00089     const BooleanProperty *selection = NULL);
00090 
00091 //======================================================================================================
00092 
00093 /**
00094   *
00095   * Computes a convex hull of a graph according to nodes positions, edges bends,
00096   * nodes z-rotations, and sizes of elements. Only works with 2D layouts.
00097   *
00098   * Returns a vector of tlp::Coord containing the vertices of the graph convex hull correctly ordered.
00099   *
00100   */
00101 TLP_SCOPE   std::vector<Coord> computeConvexHull (const Graph *graph,
00102     const LayoutProperty *layout,
00103     const SizeProperty *size,
00104     const DoubleProperty *rotation,
00105     const BooleanProperty *selection = NULL);
00106 
00107 //======================================================================================================
00108 
00109 /**
00110   *
00111   * Computes a convex hull of a set of points,
00112   * Only works with 2D layouts.
00113   *
00114   * Returns a vector of tlp::Coord containing the vertices of the points convex hull correctly ordered.
00115   *
00116   */
00117 TLP_SCOPE std::vector<Coord> computeConvexHull(const std::vector<tlp::Coord> &points);
00118 
00119 //======================================================================================================
00120 
00121 
00122 /**
00123  * Computes the intersection point (if any) of two 3d lines.
00124  * Returns true if the line intersects, false otherwise (parallel or skew lines).
00125  *
00126  */
00127 TLP_SCOPE bool computeLinesIntersection(const std::pair<tlp::Coord, tlp::Coord> &line1,
00128                                         const std::pair<tlp::Coord, tlp::Coord> &line2,
00129                                         tlp::Coord &intersectionPoint);
00130 
00131 //======================================================================================================
00132 
00133 /**
00134  * Computes the centroid of a polygon.
00135  * Polygon vertices must be provided correctly ordered in the points vector.
00136  *
00137  */
00138 TLP_SCOPE tlp::Coord computePolygonCentroid(const std::vector<tlp::Coord> &points);
00139 
00140 //======================================================================================================
00141 
00142 /**
00143  * Checks if a layout is co-planar, returns true if so.
00144  * If the layout is co-planar, the inverse transform matrix is also returned
00145  * in order to project the layout in the z=0 plane.
00146  *
00147  */
00148 TLP_SCOPE bool isLayoutCoPlanar(const std::vector<Coord> &points, Mat3f &invTransformMatrix);
00149 
00150 }
00151 
00152 
00153 #endif
00154 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties