Tulip  5.1.0
Large graphs analysis and drawing
GlTools.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
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 GLTOOLS_H
22 #define GLTOOLS_H
23 #ifndef DOXYGEN_NOTFOR_DEVEL
24 #include <tulip/tulipconf.h>
25 #include <tulip/Color.h>
26 #include <tulip/Coord.h>
27 #include <tulip/Size.h>
28 #include <tulip/Matrix.h>
29 
30 #include <tulip/OpenGlIncludes.h>
31 
32 namespace tlp {
33 
34 struct BoundingBox;
35 
36 typedef Matrix<float, 4> MatrixGL;
37 TLP_GL_SCOPE const std::string& glGetErrorDescription(GLuint errorCode);
38 TLP_GL_SCOPE void glTest(const std::string &message = std::string("(no description)"));
39 TLP_GL_SCOPE void setColor(const Color &c);
40 TLP_GL_SCOPE void setColor(GLfloat *);
41 TLP_GL_SCOPE void setMaterial(const Color &c);
42 TLP_GL_SCOPE bool cameraIs3D();
43 /*
44  * Project point on screnn according to the transformation matrix (modelview * projection)
45  * and the viewport (x, y, width, height) given in parmaeter.
46  */
47 TLP_GL_SCOPE Coord projectPoint(const Coord &obj,
48  const MatrixGL &,
49  const Vector<int, 4> &viewport);
50 /*
51  * UnProject point from screen to 3D world according to the inverse transformation matrix (modelview * projection)^-1
52  * and the viewport (x, y, width, height) given in parmaeter.
53  */
54 TLP_GL_SCOPE Coord unprojectPoint(const Coord &obj,
55  const MatrixGL &,
56  const tlp::Vector<int, 4> &viewport);
57 TLP_GL_SCOPE GLfloat projectSize(const BoundingBox& bb,
58  const MatrixGL &, const MatrixGL &,const Vector<int, 4> &viewport);
59 TLP_GL_SCOPE GLfloat projectSize(const Coord& position,const Size& size,
60  const MatrixGL &, const MatrixGL &,const Vector<int, 4> &viewport);
61 TLP_GL_SCOPE float calculateAABBSize(const BoundingBox& bb,const Coord& eye,const Matrix<float, 4>& transformMatrix,const Vector<int, 4>& globalViewport,const Vector<int, 4>& currentViewport);
62 TLP_GL_SCOPE float calculate2DLod(const BoundingBox& bb,const Vector<int, 4>& globalViewport,const Vector<int, 4>& currentViewport);
63 
64 /**
65  * Computes the normals associated to the vertices of a triangulated mesh.
66  *
67  * @since Tulip 4.8
68  *
69  * @param vertices a vector containing the vertices to compute associated normals
70  * @param facesIndices a vector containing the unsigned short indices of the triangles faces (its size must be a multiple of 3)
71  * @return a vector, with the same size as the one holding vertices, filled with the computed normals
72  *
73  */
74 TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices, const std::vector<unsigned short> &facesIndices);
75 
76 /**
77  * Computes the normals associated to the vertices of a triangulated mesh.
78  *
79  * @since Tulip 4.8
80  *
81  * @param vertices a vector containing the vertices to compute associated normals
82  * @param facesIndices a vector containing the unsigned int indices of the triangles faces (its size must be a multiple of 3)
83  * @return a vector, with the same size as the one holding vertices, filled with the computed normals
84  *
85  */
86 TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices, const std::vector<unsigned int> &facesIndices);
87 
88 }
89 
90 #endif //DOXYGEN_NOTFOR_DEVEL
91 #endif
92 ///@endcond