Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYFaceSetGraphic.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 
25 
26 #include "TYFaceSetGraphic.h"
27 
29 
31 
32 void TYFaceSetGraphic::update(bool force /*=false*/)
33 {
35 }
36 
38 {
39  OBox reset;
40  _boundingBox = reset;
41 
42  TYTabPoint sommets = getElement()->sommets();
43 
44  size_t nbPts = sommets.size();
45  TYPoint pt;
46  for (size_t i = 0; i < nbPts; i++)
47  {
48  pt = sommets[i];
49  _boundingBox.Enlarge((float)(pt._x), (float)(pt._y), (float)(pt._z));
50  }
51 }
52 
53 void TYFaceSetGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
54 {
55  if (_highlight)
56  {
57  float color[4];
58  glGetFloatv(GL_CURRENT_COLOR, color);
59  if (_bFirstDisp)
60  {
62  _bFirstDisp = false;
63  }
65  if (mode == GL_COMPILE)
66  {
67  drawName(pModelerElement);
68  }
69  glColor3f(color[0], color[1], color[2]);
70  }
71 
72  if (_visible)
73  {
74  TYTabLPPolygon faces = getElement()->faces();
75  TYTabVector normals = getElement()->normals();
76  size_t nbFaces = faces.size();
77 
78  // Polygon representant la face
79  TYPolygon* pFace = NULL;
80  OVector3D normal;
81  OPoint3D sommet;
82 
83  // glBegin(GL_QUADS);
84 
85  for (int i = 0; i < nbFaces; i++)
86  {
87  pFace = faces[i];
88 
89  if ((pFace != NULL) && (pFace->getNbPts() == 4))
90  {
91  glBegin(GL_QUADS);
92  for (int j = 0; j < 4; j++)
93  {
94  sommet = pFace->getPoint(j);
95  glVertex3f(sommet._x, sommet._y, sommet._z);
96  }
97  glEnd();
98 
100  {
101  normal = normals[i];
102  glNormal3f(normal._x, normal._y, normal._z);
103  OPoint3D p1 = pFace->getCenter();
104  displayNormal(normal * 5, p1);
105  }
106  }
107  }
108 
109  // glEnd();
110 
111  // Calcul du volume englobant pour le fit:
113  }
114 }
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)
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
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(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)
TYFaceSetGraphic(TYFaceSet *pElement)
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
virtual ~TYFaceSetGraphic()
virtual void computeBoundingBox()
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