Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYRectangleGraphic.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
24 
25 #include "TYRectangleGraphic.h"
26 
28 
30 
31 void TYRectangleGraphic::update(bool force /*=false*/)
32 {
34 }
35 
37 {
38  OBox reset;
39  _boundingBox = reset;
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 }
47 
48 void TYRectangleGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
49 {
50  if (_highlight)
51  {
52  float color[4];
53  glGetFloatv(GL_CURRENT_COLOR, color);
54  if (_bFirstDisp)
55  {
57  _bFirstDisp = false;
58  }
60  if (mode == GL_COMPILE)
61  {
62  drawName(pModelerElement);
63  }
64  glColor3f(color[0], color[1], color[2]);
65  }
66 
67  if (_visible)
68  {
70 
71  glBegin(GL_QUADS);
72 
73  // Calcul de la normale a la face
74  OVector3D normal = getElement()->normal();
75  normal.normalize();
76  glNormal3f(normal._x, normal._y, normal._z);
77 
78  for (int i = 0; i < 4; i++)
79  {
80  glVertex3f(getElement()->_pts[i]._x, getElement()->_pts[i]._y, getElement()->_pts[i]._z);
81  }
82 
83  glEnd();
84  // Calcul du volume englobant pour le fit:
86 
88  {
89  OPoint3D p1;
90  OVector3D n = normal * 5;
91  p1._x = (_boundingBox._max._x + _boundingBox._min._x) / 2;
92  p1._y = (_boundingBox._max._y + _boundingBox._min._y) / 2;
93  p1._z = (_boundingBox._max._z + _boundingBox._min._z) / 2;
94  displayNormal(n, p1);
95  }
96  }
97 }
Representation graphique d'un rectangle (fichier header)
The box class.
Definition: 3d.h:1294
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:1371
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1372
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(TYElement *pModelerElement=nullptr)
static OBox _globalBoundingBox
bool _visible
Inique si l'element est visible.
static bool _gDrawNormals
Indique si les normals doivent etre visible.
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 computeBoundingBox()
TYRectangleGraphic(TYRectangle *pElement)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)