Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYBatiment.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 
20 #if TY_USE_IHM
23 #endif
24 
25 #include "TYBatiment.h"
26 #include "Tympan/core/logging.h"
27 
30 
32 {
34  setIsRayonnant(false);
35 }
36 
38 {
39  *this = other;
40 }
41 
43 
45 {
46  if (this != &other)
47  {
49  }
50  return *this;
51 }
52 
53 bool TYBatiment::operator==(const TYBatiment& other) const
54 {
55  if (this != &other)
56  {
57  if (TYAcousticVolumeNode::operator!=(other))
58  {
59  return false;
60  }
61  }
62  return true;
63 }
64 
65 bool TYBatiment::operator!=(const TYBatiment& other) const
66 {
67  return !operator==(other);
68 }
69 
70 std::string TYBatiment::toString() const
71 {
72  return "TYBatiment";
73 }
74 
76 {
77  DOM_Element domNewElem = TYAcousticVolumeNode::toXML(domElement);
78  return domNewElem;
79 }
80 
82 {
84 
85  return 1;
86 }
87 
88 void TYBatiment::setDensiteSrcsH(double densite, bool recursif)
89 {
90  TYAcousticInterface::setDensiteSrcsH(densite, recursif);
91 
92  if (recursif)
93  {
94  for (int i = 0; i < getNbChild(); i++)
95  {
97  assert(pEtage);
98 
99  // Densite H de srcs ponct
100  pEtage->setDensiteSrcsH(getDensiteSrcsH(), recursif);
101  }
102  }
103 }
104 
105 void TYBatiment::setDensiteSrcsV(double densite, bool recursif)
106 {
107  TYAcousticInterface::setDensiteSrcsV(densite, recursif);
108 
109  if (recursif)
110  {
111  for (int i = 0; i < getNbChild(); i++)
112  {
114  assert(pEtage);
115 
116  // Densite V de srcs ponct
117  pEtage->setDensiteSrcsV(getDensiteSrcsV(), recursif);
118  }
119  }
120 }
121 
123 {
125 }
126 
128 {
130 }
131 
133 {
135 }
136 
138 {
140 }
141 
142 double TYBatiment::volume() const
143 {
145 }
146 
147 double TYBatiment::surface() const
148 {
150 }
151 
153 {
155 }
156 
158 {
160 }
161 
163 {
165 }
166 
168 {
170 }
171 
173 {
175 }
176 
177 int TYBatiment::intersects(const OSegment3D& seg, TYTabPoint& ptList) const
178 {
179  return TYAcousticVolumeNode::intersects(seg, ptList);
180 }
181 
182 int TYBatiment::isInside(const TYPoint& pt) const
183 {
185 }
186 
187 bool TYBatiment::updateAcoustic(const bool& force) // force = false
188 {
189  if (!getIsAcousticModified() && !force)
190  {
191  return true;
192  } // Le batiment est à jour
193 
194  unsigned int i = 0;
195  bool ret = true;
198 
199  remAllSrcs();
200 
202 
204  {
206  LW = getCurrentSpectre();
207  }
208  else // TY_PUISSANCE_CALCULEE
209  {
210  for (i = 0; i < _tabAcousticVol.size(); i++)
211  {
213  ret &= pEtage->updateAcoustic();
214  LW = LW.sum(pEtage->getCurrentSpectre().toGPhy());
215  }
216  }
217 
218  TYSpectre aTYSpectre(LW.toDB());
219  setRegime(aTYSpectre, -1, false);
220 
221  if (ret)
222  {
223  setIsAcousticModified(false);
224  } // L'acoustique est à jour
225 
226  return ret;
227 }
228 
230 {
231  LPTYElementArray childs;
232  getChilds(childs, true);
233  LPTYSpectre sp = new TYSpectre(-200.0);
235  LPTYAcousticSurface pSurf = NULL;
236  for (unsigned int i = 0; i < childs.size(); i++)
237  {
238  pSurf = dynamic_cast<TYAcousticSurface*>(childs[i]._pObj);
239  if (pSurf._pObj != nullptr)
240  {
241  // On s'assure que la surface appartient bien a l'etage et non a une machine a l'interieur
242  TYElement* pParent = pSurf->getParent();
243  while (pParent)
244  {
245  if (pParent->isA("TYMachine"))
246  {
247  break;
248  }
249  else if (pParent->isA("TYBatiment"))
250  {
251  *sp = sp->sumdB(*pSurf->getRealPowerSpectrum());
252  break;
253  }
254 
255  pParent = pParent->getParent();
256  }
257  }
258  }
259 
260  return sp;
261 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
Representation graphique d'un bâtiment (fichier header)
outil IHM pour un batiment (fichier header)
TY_EXT_GRAPHIC_INST(TYBatiment)
TY_EXTENSION_INST(TYBatiment)
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
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:345
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
virtual const char * getClassName() const
Definition: TYElement.h:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
bool isA(const char *className) const
Definition: TYElement.cpp:65
Class to define a segment.
Definition: 3d.h:1089
OSpectreAbstract & sum(const OSpectreAbstract &spectre) const
Arithmetic sum of two spectrums in one-third Octave.
Definition: spectre.cpp:219
OSpectreAbstract & toGPhy() const
Converts to physical quantity.
Definition: spectre.cpp:634
void setType(TYSpectreType type)
Set the spectrum type.
Definition: spectre.h:152
OSpectreAbstract & toDB() const
Converts to dB.
Definition: spectre.cpp:590
OSpectreAbstract & sumdB(const OSpectreAbstract &spectre) const
Energetic sum of two spectrums.
Definition: spectre.cpp:171
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
double getDensiteSrcsH() const
virtual void setDensiteSrcsH(double densite, bool recursif=true)
double getDensiteSrcsV() const
int _curRegime
Numero du regime de fonctionnement courant.
int _typeDistribution
Indique le type de distribution a utiliser. pour l'etat courant.
TYSpectre & getCurrentSpectre()
virtual void setDensiteSrcsV(double densite, bool recursif=true)
virtual LPTYSpectre getRealPowerSpectrum()
virtual TYTabVector normals() const
virtual int fromXML(DOM_Element domElement)
virtual TYPoint centreGravite() const
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=false)
virtual bool updateAcoustic(const bool &force=false)
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
TYTabAcousticVolumeGeoNode _tabAcousticVol
Tableau des AcousticVolumes.
virtual int isInside(const TYPoint &pt) const
virtual TYBox volEnglob() const
virtual TYTabPoint sommets() const
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual DOM_Element toXML(DOM_Element &domElement)
TYAcousticVolumeNode & operator=(const TYAcousticVolumeNode &other)
Operateur =.
virtual double surface() const
virtual TYTabLPPolygon faces() const
virtual double volume() const
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
virtual void setCurRegime(int regime)
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
virtual TYSourcePonctuelle srcPonctEquiv() const
virtual bool updateAcoustic(const bool &force=false)
virtual void setDensiteSrcsV(double densite, bool recursif=true)
Definition: TYBatiment.cpp:105
virtual ~TYBatiment()
Definition: TYBatiment.cpp:42
bool operator==(const TYBatiment &other) const
Operateur ==.
Definition: TYBatiment.cpp:53
virtual TYTabPoint sommets() const
Definition: TYBatiment.cpp:157
virtual bool setSrcsLw()
Definition: TYBatiment.cpp:137
virtual int fromXML(DOM_Element domElement)
Definition: TYBatiment.cpp:81
virtual void setDensiteSrcsH(double densite, bool recursif=true)
Definition: TYBatiment.cpp:88
bool operator!=(const TYBatiment &other) const
Operateur !=.
Definition: TYBatiment.cpp:65
virtual double surface() const
Definition: TYBatiment.cpp:147
virtual int isInside(const TYPoint &pt) const
Definition: TYBatiment.cpp:182
virtual double volume() const
Definition: TYBatiment.cpp:142
virtual std::string toString() const
Definition: TYBatiment.cpp:70
TYBatiment & operator=(const TYBatiment &other)
Operateur =.
Definition: TYBatiment.cpp:44
virtual TYTabLPPolygon faces() const
Definition: TYBatiment.cpp:162
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
Definition: TYBatiment.cpp:177
virtual LPTYSpectre getRealPowerSpectrum()
Definition: TYBatiment.cpp:229
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYBatiment.cpp:75
virtual TYBox volEnglob() const
Definition: TYBatiment.cpp:167
virtual void distriSrcs()
Definition: TYBatiment.cpp:132
virtual TYPoint centreGravite() const
Definition: TYBatiment.cpp:172
virtual bool updateAcoustic(const bool &force=false)
Definition: TYBatiment.cpp:187
virtual TYTabVector normals() const
Definition: TYBatiment.cpp:152
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
Definition: TYBatiment.cpp:122
virtual TYSourcePonctuelle srcPonctEquiv() const
Definition: TYBatiment.cpp:127
Definition: TYBox.h:34
TYElement * getParent() const
Definition: TYElement.h:699
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
bool getIsAcousticModified()
Definition: TYElement.h:718
virtual void setIsAcousticModified(bool isModified)
Definition: TYElement.cpp:248
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
static TYSpectre getEmptyLinSpectre(const double &valInit=1.0E-20)
Cree un spectre en lin.
Definition: TYSpectre.cpp:451
@ SPECTRE_TYPE_LW
Definition: spectre.h:30