Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYFaceSetGraphic.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
25 
26 #include <QtOpenGL>
27 #include "TYFaceSetGraphic.h"
28 #include "gui/gl/TYRenderContext.h"
29 
31 
33 
34 void TYFaceSetGraphic::update(bool force /*=false*/)
35 {
37 }
38 
40 {
42 
43  TYTabPoint sommets = getElement()->sommets();
44 
45  size_t nbPts = sommets.size();
46  TYPoint pt;
47  for (size_t i = 0; i < nbPts; i++)
48  {
49  pt = sommets[i];
50  boundingBox.Enlarge((float)(pt._x), (float)(pt._y), (float)(pt._z));
51  }
52  return boundingBox;
53 }
54 
56 {
57  if (_highlight)
58  {
59  float color[4];
60  glGetFloatv(GL_CURRENT_COLOR, color);
61  if (renderContext.pass == TYRenderPass::Overlay)
62  {
63  drawName(renderContext);
64  }
65  glColor3f(color[0], color[1], color[2]);
66  }
67 
68  if (_visible)
69  {
70  TYTabLPPolygon faces = getElement()->faces();
71  TYTabVector normals = getElement()->normals();
72  size_t nbFaces = faces.size();
73 
74  // Polygon representant la face
75  TYPolygon* pFace = NULL;
76  OVector3D normal;
77  OPoint3D sommet;
78 
79  // glBegin(GL_QUADS);
80 
81  for (int i = 0; i < nbFaces; i++)
82  {
83  pFace = faces[i];
84 
85  if ((pFace != NULL) && (pFace->getNbPts() == 4))
86  {
87  glBegin(GL_QUADS);
88  for (int j = 0; j < 4; j++)
89  {
90  sommet = pFace->getPoint(j);
91  glVertex3f(sommet._x, sommet._y, sommet._z);
92  }
93  glEnd();
94 
96  {
97  normal = normals[i];
98  glNormal3f(normal._x, normal._y, normal._z);
99  OPoint3D p1 = pFace->getCenter();
100  displayNormal(normal * 5, p1);
101  }
102  }
103  }
104 
105  // glEnd();
106  }
107 }
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
std::vector< OVector3D > TYTabVector
Collection de OVector3D.
Definition: TYDefines.h:398
std::vector< LPTYPolygon > TYTabLPPolygon
Collection de pointeurs de TYPolygon.
Definition: TYDefines.h:349
Representation d'un ensemble de faces (fichier header)
Contexte de rendu utilisé par les fonctions d'affichage.
@ Overlay
The current render pass is for overlay elements.
The box class.
Definition: 3d.h:1346
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
Definition: 3d.cpp:1614
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
The 3D point class.
Definition: 3d.h:487
The 3D vector class.
Definition: 3d.h:298
classe graphique pour un element de base
void drawName(TYRenderContext &renderContext)
bool _visible
Inique si l'element est visible.
static bool _gDrawNormals
Indique si les normals doivent etre visible.
OBox boundingBox() const
bool _highlight
Indique si le highlight est active pour cet element.
void displayNormal(OVector3D normal, OPoint3D p1)
virtual void update(bool force=false)
virtual void update(bool force=false)
virtual void display(TYRenderContext &renderContext)
TYFaceSetGraphic(TYFaceSet *pElement)
virtual ~TYFaceSetGraphic()
virtual OBox computeBoundingBox() const
size_t getNbPts() const
Definition: TYPolygon.h:107
OPoint3D getPoint(size_t index) const
Definition: TYPolygon.h:134
OPoint3D getCenter() const
Definition: TYPolygon.h:172
TYRenderPass pass