Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYRectangleGraphic.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 
24 
25 #include "TYRectangleGraphic.h"
27 
29 
31 
32 void TYRectangleGraphic::update(bool force /*=false*/)
33 {
35 }
36 
38 {
40 
41  for (int i = 0; i < 4; i++)
42  {
43  boundingBox.Enlarge((float)(getElement()->_pts[i]._x), (float)(getElement()->_pts[i]._y),
44  (float)(getElement()->_pts[i]._z));
45  }
46  return boundingBox;
47 }
48 
50 {
51  if (_highlight)
52  {
53  float color[4];
54  glGetFloatv(GL_CURRENT_COLOR, color);
55  if (renderContext.pass == TYRenderPass::Overlay)
56  {
57  drawName(renderContext);
58  }
59  glColor3f(color[0], color[1], color[2]);
60  }
61 
62  if (_visible)
63  {
64  glBegin(GL_QUADS);
65 
66  // Calcul de la normale a la face
67  OVector3D normal = getElement()->normal();
68  normal.normalize();
69  glNormal3f(normal._x, normal._y, normal._z);
70 
71  for (int i = 0; i < 4; i++)
72  {
73  glVertex3f(getElement()->_pts[i]._x, getElement()->_pts[i]._y, getElement()->_pts[i]._z);
74  }
75 
76  glEnd();
77 
79  {
80  OPoint3D p1;
81  OVector3D n = normal * 5;
82  p1._x = (boundingBox()._max._x + boundingBox()._min._x) / 2;
83  p1._y = (boundingBox()._max._y + boundingBox()._min._y) / 2;
84  p1._z = (boundingBox()._max._z + boundingBox()._min._z) / 2;
85  displayNormal(n, p1);
86  }
87  }
88 }
Representation graphique d'un rectangle (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
OPoint3D _min
Minimal coordinates of the OBox.
Definition: 3d.h:1423
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1424
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
OVector3D normal(const OVector3D &vector2, const OVector3D &vector3) const
Computes the normal with this vector and 2 others.
Definition: 3d.cpp:220
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
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 display(TYRenderContext &renderContext)
virtual OBox computeBoundingBox() const
virtual void update(bool force=false)
TYRectangleGraphic(TYRectangle *pElement)
TYRenderPass pass