Tulip  5.2.1
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, const MatrixGL &, const Vector<int, 4> &viewport);
48 /*
49  * UnProject point from screen to 3D world according to the inverse transformation matrix (modelview
50  * * projection)^-1
51  * and the viewport (x, y, width, height) given in parmaeter.
52  */
53 TLP_GL_SCOPE Coord unprojectPoint(const Coord &obj, const MatrixGL &,
54  const tlp::Vector<int, 4> &viewport);
55 TLP_GL_SCOPE GLfloat projectSize(const BoundingBox &bb, const MatrixGL &, const MatrixGL &,
56  const Vector<int, 4> &viewport);
57 TLP_GL_SCOPE GLfloat projectSize(const Coord &position, const Size &size, const MatrixGL &,
58  const MatrixGL &, const Vector<int, 4> &viewport);
59 TLP_GL_SCOPE float calculateAABBSize(const BoundingBox &bb, const Coord &eye,
60  const Matrix<float, 4> &transformMatrix,
61  const Vector<int, 4> &globalViewport,
62  const Vector<int, 4> &currentViewport);
63 TLP_GL_SCOPE float calculate2DLod(const BoundingBox &bb, const Vector<int, 4> &globalViewport,
64  const Vector<int, 4> &currentViewport);
65 
66 /**
67  * Computes the normals associated to the vertices of a triangulated mesh.
68  *
69  * @since Tulip 4.8
70  *
71  * @param vertices a vector containing the vertices to compute associated normals
72  * @param facesIndices a vector containing the unsigned short indices of the triangles faces (its
73  * size must be a multiple of 3)
74  * @return a vector, with the same size as the one holding vertices, filled with the computed
75  * normals
76  *
77  */
78 TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices,
79  const std::vector<unsigned short> &facesIndices);
80 
81 /**
82  * Computes the normals associated to the vertices of a triangulated mesh.
83  *
84  * @since Tulip 4.8
85  *
86  * @param vertices a vector containing the vertices to compute associated normals
87  * @param facesIndices a vector containing the unsigned int indices of the triangles faces (its size
88  * must be a multiple of 3)
89  * @return a vector, with the same size as the one holding vertices, filled with the computed
90  * normals
91  *
92  */
93 TLP_GL_SCOPE std::vector<Coord> computeNormals(const std::vector<Coord> &vertices,
94  const std::vector<unsigned int> &facesIndices);
95 } // namespace tlp
96 
97 #endif // DOXYGEN_NOTFOR_DEVEL
98 #endif
99 ///@endcond