Tulip  5.0.0
Large graphs analysis and drawing
GlTools.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
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 #if defined(_MSC_VER)
31 #include <Windows.h>
32 #endif
33 
34 #if defined(__APPLE__)
35 #include <OpenGL/gl.h>
36 #else
37 #include <GL/gl.h>
38 #endif
39 
40 namespace tlp {
41 
42 struct BoundingBox;
43 
44 typedef Matrix<float, 4> MatrixGL;
45 TLP_GL_SCOPE const std::string& glGetErrorDescription(GLuint errorCode);
46 TLP_GL_SCOPE void glTest(const std::string &message = std::string("(no description)"));
47 TLP_GL_SCOPE void setColor(const Color &c);
48 TLP_GL_SCOPE void setColor(GLfloat *);
49 TLP_GL_SCOPE void setMaterial(const Color &c);
50 TLP_GL_SCOPE bool cameraIs3D();
51 /*
52  * Project point on screnn according to the transformation matrix (modelview * projection)
53  * and the viewport (x, y, width, height) given in parmaeter.
54  */
55 TLP_GL_SCOPE Coord projectPoint(const Coord &obj,
56  const MatrixGL &,
57  const Vector<int, 4> &viewport);
58 /*
59  * UnProject point from screen to 3D world according to the inverse transformation matrix (modelview * projection)^-1
60  * and the viewport (x, y, width, height) given in parmaeter.
61  */
62 TLP_GL_SCOPE Coord unprojectPoint(const Coord &obj,
63  const MatrixGL &,
64  const tlp::Vector<int, 4> &viewport);
65 TLP_GL_SCOPE GLfloat projectSize(const BoundingBox& bb,
66  const MatrixGL &, const MatrixGL &,const Vector<int, 4> &viewport);
67 TLP_GL_SCOPE GLfloat projectSize(const Coord& position,const Size& size,
68  const MatrixGL &, const MatrixGL &,const Vector<int, 4> &viewport);
69 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);
70 TLP_GL_SCOPE float calculate2DLod(const BoundingBox& bb,const Vector<int, 4>& globalViewport,const Vector<int, 4>& currentViewport);
71 
72 /**
73  * Computes the normals associated to the vertices of a triangulated mesh.
74  *
75  * @since Tulip 4.8
76  *
77  * @param vertices a vector containing the vertices to compute associated normals
78  * @param facesIndices a vector containing the unsigned short indices of the triangles faces (its size must be a multiple of 3)
79  * @return a vector, with the same size as the one holding vertices, filled with the computed normals
80  *
81  */
82 TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices, const std::vector<unsigned short> &facesIndices);
83 
84 /**
85  * Computes the normals associated to the vertices of a triangulated mesh.
86  *
87  * @since Tulip 4.8
88  *
89  * @param vertices a vector containing the vertices to compute associated normals
90  * @param facesIndices a vector containing the unsigned int indices of the triangles faces (its size must be a multiple of 3)
91  * @return a vector, with the same size as the one holding vertices, filled with the computed normals
92  *
93  */
94 TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices, const std::vector<unsigned int> &facesIndices);
95 
96 }
97 
98 #endif //DOXYGEN_NOTFOR_DEVEL
99 #endif
100 ///@endcond