Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYRayGraphic.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 
16 /*
17  *
18  */
19 
21 
22 #include "TYRayGraphic.h"
23 
24 bool TYRayGraphic::_gVisible = false;
25 
27 
29 
30 void TYRayGraphic::update(bool force /*=false*/)
31 {
33 }
34 
36 {
37  OBox reset;
38  _boundingBox = reset;
39 }
40 
42 {
43  switch (e.type)
44  {
45  case TYSOURCE:
46  _r = 1.0f;
47  _g = 1.0f;
48  _b = 0.0f; // jaune;
49  break;
50 
51  case TYDIFFRACTION:
52  _r = 0.2f;
53  _g = 0.55f;
54  _b = 0.91f; // bleu
55  break;
56 
57  case TYREFLEXION:
58  _r = 1.0f;
59  _g = 0.0f;
60  _b = 0.0f; // rouge
61  break;
62 
63  case TYREFLEXIONSOL:
64  _r = 1.0f;
65  _g = 0.5f;
66  _b = 0.0f; // orange
67 
68  case TYREFRACTION:
69  // Do nothing
70  // _r=0.0f; _g=0.84f; _b=0.35f; // vert
71  break;
72 
73  case TYRECEPTEUR:
74  _r = 1.0f;
75  _g = 0.43f;
76  _b = 0.71f; // rose
77  break;
78 
79  case TY_NO_TYPE:
80  // Do nothing ?
81  break;
82 
83  case TY_ALL_TYPE:
84  // Do nothing ?
85  break;
86  }
87 }
88 
89 void TYRayGraphic::display(TYElement* pModelerElement /*= nullptr*/, GLenum mode /*= GL_RENDER*/)
90 {
91  TYRay* pRay = getElement();
92 
93  if (_visible)
94  {
95  // Dessine les evenements du rayon
96  glLineWidth(2.0);
97  glBegin(GL_LINE_STRIP);
98 
101  for (unsigned int j = 0; j < pRay->getEvents().size(); j++)
102  {
103  acoustic_event* e = pRay->getEvents().at(j);
104 
105  if (j != 0)
106  {
107  // 2nd point du segment
108  OPoint3D pt(e->pos);
109  glVertex3f(pt._x, pt._y, pt._z);
110  }
111 
112  getRayEventColor(*e);
113  glColor3f(_r, _g, _b);
114  _lastRayEventType = e->type;
115  _lastRayEventPos = e->pos;
116 
117  // 1er point du segment
118  OPoint3D pt(e->pos);
119  glVertex3f(pt._x, pt._y, pt._z);
120  }
121 
122  glEnd();
123  }
124 }
@ TYREFLEXION
Definition: acoustic_path.h:25
@ TYRECEPTEUR
Definition: acoustic_path.h:29
@ TYSOURCE
Definition: acoustic_path.h:28
@ TY_NO_TYPE
Definition: acoustic_path.h:23
@ TYREFLEXIONSOL
Definition: acoustic_path.h:26
@ TYREFRACTION
Definition: acoustic_path.h:27
@ TY_ALL_TYPE
Definition: acoustic_path.h:30
@ TYDIFFRACTION
Definition: acoustic_path.h:24
The box class.
Definition: 3d.h:1294
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
classe graphique pour un element de base
bool _visible
Inique si l'element est visible.
virtual void update(bool force=false)
virtual void computeBoundingBox()
int _repeatRayEventCount
Definition: TYRayGraphic.h:83
void getRayEventColor(acoustic_event &e)
TYPoint _lastRayEventPos
Definition: TYRayGraphic.h:82
TYRayGraphic(TYRay *pElement)
virtual ~TYRayGraphic()
virtual void update(bool force=false)
static bool _gVisible
Indique si toutes les instances sont visibles.
Definition: TYRayGraphic.h:75
virtual void display(TYElement *pModelerElement=nullptr, GLenum mode=GL_RENDER)
int _lastRayEventType
Definition: TYRayGraphic.h:81
Classe decrivant un rayon acoustique gere par un lancer de rayon. Cette classe doit permettre la mode...
Definition: TYRay.h:35
This class store data and provide functions to manipulate event in the acoustic context.
Definition: acoustic_path.h:40
ACOUSTIC_EVENT_TYPES type
Event type.
Definition: acoustic_path.h:60
OPoint3D pos
Event position.
Definition: acoustic_path.h:53
virtual tab_acoustic_events & getEvents()
Get the events list of the ray.