Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticVolume.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 #if TY_USE_IHM
18 #endif
20 #include "TYAcousticVolume.h"
21 
23 
24 TYAcousticVolume::TYAcousticVolume() : _forceNormales(false)
25 {
27 
29  _pMateriau->setParent(this);
30 }
31 
33 {
34  *this = other;
35 }
36 
38 
40 {
41  if (this != &other)
42  {
43  TYElement::operator=(other);
46  _pMateriau = other._pMateriau;
48  }
49  return *this;
50 }
51 
53 {
54  if (this != &other)
55  {
56  if (TYElement::operator!=(other))
57  {
58  return false;
59  }
60  if (TYColorInterface::operator!=(other))
61  {
62  return false;
63  }
64  if (TYAcousticInterface::operator!=(other))
65  {
66  return false;
67  }
68  if (_pMateriau != other._pMateriau)
69  {
70  return false;
71  }
72  if (_forceNormales != other._forceNormales)
73  {
74  return false;
75  }
76  }
77  return true;
78 }
79 
81 {
82  return !operator==(other);
83 }
84 
85 bool TYAcousticVolume::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
86 {
87  if (!TYElement::deepCopy(pOther, copyId))
88  {
89  return false;
90  }
91 
92  TYAcousticVolume* pVol = (TYAcousticVolume*)pOther;
93 
94  TYColorInterface::deepCopy(pVol, copyId);
95  TYAcousticInterface::deepCopy(pVol, copyId);
96  _pMateriau->deepCopy(pVol->_pMateriau, copyId);
98 
99  return true;
100 }
101 
102 std::string TYAcousticVolume::toString() const
103 {
104  return "TYAcousticVolume";
105 }
106 
108 {
109  DOM_Element domNewElem = TYElement::toXML(domElement);
110  TYColorInterface::toXML(domNewElem);
111  TYAcousticInterface::toXML(domNewElem);
112 
113  if (_pMateriau != NULL)
114  {
115  _pMateriau->toXML(domNewElem);
116  }
117 
118  TYXMLTools::addElementBoolValue(domNewElem, "forceNormales", _forceNormales);
119 
120  return domNewElem;
121 }
122 
124 {
125  bool normOk(false);
126  TYElement::fromXML(domElement);
127  TYColorInterface::fromXML(domElement);
128  TYAcousticInterface::fromXML(domElement);
129 
130  TYUUID currentId = this->getID();
131  if (TYElement::testId(currentId, this))
132  {
133  this->regenerateID();
134  }
135 
136  if (_pMateriau == NULL)
137  {
139  }
140 
141  // bool isSubOk = false;
142  bool matOk = false;
143  DOM_Element elemCur;
144 
145  QDomNodeList childs = domElement.childNodes();
146  for (unsigned int i = 0; i < childs.length(); i++)
147  {
148  elemCur = childs.item(i).toElement();
149  if (!matOk)
150  {
151  matOk = _pMateriau->callFromXMLIfEqual(elemCur);
152  }
153 
154  if (!normOk)
155  {
156  TYXMLTools::getElementBoolValue(elemCur, "forceNormales", _forceNormales, normOk);
157  }
158  }
159 
160  if (!matOk)
161  {
162  _pMateriau = NULL;
163  }
164 
165  return 1;
166 }
167 
169 {
171 
172  if (_pParent)
173  {
174  _pParent->setIsAcousticModified(isModified);
175  }
176 }
177 
179 {
181 }
182 
184 {
185  size_t nbRegimes = _tabRegimes.size();
186  LPTYElementArray childs;
187  getChilds(childs, false);
188 
189  LPTYGeometryNode pNode = NULL;
190  LPTYAcousticSurfaceNode pSurfNode = NULL;
191  for (size_t i = 0; i < childs.size(); i++)
192  {
193  pNode = TYGeometryNode::safeDownCast(childs[i]);
194  if (pNode == NULL)
195  {
196  continue;
197  }
198 
199  pSurfNode = TYAcousticSurfaceNode::safeDownCast(pNode->getElement());
200  if (pSurfNode)
201  {
202  if (pSurfNode->getNbRegimes() > nbRegimes)
203  {
204  pSurfNode->setNbRegimes(static_cast<int>(nbRegimes));
205  }
206 
207  pSurfNode->correctNbRegimes();
208  }
209  }
210 }
211 
213 {
214  setIsAcousticModified(true);
215 
217 }
218 
220 {
222 }
223 
225 {
226  return TYSourcePonctuelle();
227 }
228 
230 
232 
234 {
235  return false;
236 }
237 
238 bool TYAcousticVolume::updateAcoustic(const bool& force) // force = false
239 {
240  return true;
241 }
242 
244 {
245  return 0.0;
246 }
247 
249 {
250  return 0.0;
251 }
252 
254 {
255  return 0.0;
256 }
257 
259 {
260  return 0.0;
261 }
262 
264 {
265  return TYTabVector();
266 }
267 
269 {
270  return TYTabPoint();
271 }
272 
274 {
275  return TYTabLPPolygon();
276 }
277 
279 {
280  return TYBox();
281 }
282 
284 {
285  return TYPoint();
286 }
287 
288 int TYAcousticVolume::intersects(const TYSegment& seg, TYTabPoint& ptList) const
289 {
290  return INTERS_NULLE;
291 }
292 
294 {
295  return INTERS_NULLE;
296 }
297 
299 {
301 }
302 
304 {
305  return false;
306 }
307 
308 TYSpectre TYAcousticVolume::setGlobalLW(const TYSpectre& spectre, const double& surfGlobale,
309  const int& regime /*=-1*/)
310 {
311  TYSpectre LWv;
312 
314  {
315  double surfOfVol = activeSurface();
316  LWv =
317  spectre.toGPhy().mult(surfOfVol / surfGlobale).toDB(); // Spectre pondere de la surface du volume
318 
319  setRegime(LWv, regime, false);
320  }
321 
322  return getCurrentSpectre().toGPhy(); // On retourne le spectre obtenu
323 }
324 
326 {
327  TYTabLPAcousticSurface tabSubFaces;
328  return tabSubFaces;
329 }
330 
332 {
333  _pMateriau = pMat;
334 
335  if (_pMateriau)
336  {
337  _pMateriau->setParent(this);
338  }
339 
340  setIsGeometryModified(true);
341 }
342 
343 void TYAcousticVolume::setIsRayonnant(bool rayonnant, bool recursif)
344 {
346 }
348 {
349  bool status = true;
350  TYRegime& reg = getRegimeNb(_curRegime, status);
351  if (status)
352  {
353  reg.setRegimeName(name);
354  }
355 }
356 
358 {
360  for (unsigned int i = 0; i < tabSurf.size(); i++)
361  {
362  TYAcousticSurface* pSurf = TYAcousticSurface::safeDownCast(tabSurf[i]->getElement());
363  pSurf->inverseNormale();
364  }
365 }
#define INTERS_NULLE
No intersection.
Definition: 3d.h:35
QDomElement DOM_Element
Definition: QT2DOM.h:30
std::vector< LPTYAcousticSurface > TYTabLPAcousticSurface
Tableau de TYAcousticSurfaces.
std::vector< LPTYAcousticSurfaceGeoNode > TYTabAcousticSurfaceGeoNode
Collection de noeuds geometriques de type TYAcousticSurface.
outil IHM pour un volume acoustique (fichier header)
TY_EXTENSION_INST(TYAcousticVolume)
class OGenID TYUUID
Definition: TYDefines.h:59
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
const char * name
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
The 4x4 matrix class.
Definition: 3d.h:625
virtual const char * getClassName() const
Definition: TYElement.h:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
OSpectreAbstract & toGPhy() const
Converts to physical quantity.
Definition: spectre.cpp:634
OSpectreAbstract & toDB() const
Converts to dB.
Definition: spectre.cpp:590
OSpectreAbstract & mult(const OSpectreAbstract &spectre) const
Multiplication of two spectrums.
Definition: spectre.cpp:243
TYRegime & getRegimeNb(const int &nb, bool &status)
size_t getNbRegimes() const
int _curRegime
Numero du regime de fonctionnement courant.
int _typeDistribution
Indique le type de distribution a utiliser. pour l'etat courant.
TYSpectre & getCurrentSpectre()
TYTabRegimes _tabRegimes
Tableau des regimes de fonctionnement.
DOM_Element toXML(DOM_Element &domElement)
TYAcousticInterface & operator=(const TYAcousticInterface &other)
void setNbRegimes(unsigned int nb)
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=false)
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
int fromXML(DOM_Element domElement)
void deepCopy(const TYAcousticInterface *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual void propagateRegime()
virtual void propagateAtt(LPTYAttenuateur pAtt)
virtual TYTabLPAcousticSurface getSubFace()
virtual void setRegimeName(const QString &name)
virtual TYPoint centreGravite() const
virtual int isInside(const TYPoint &pt) const
virtual TYTabAcousticSurfaceGeoNode acousticFaces()
virtual void remAllSrcs()
bool operator!=(const TYAcousticVolume &other) const
Operateur !=.
LPTYMateriauConstruction _pMateriau
Materiau de contruction pour les faces de ce Volume.
virtual void propagateRegime()
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual bool findAcousticSurface(const TYAcousticSurface *pAccSurf, OMatrix *pMatrix=0)
virtual int intersects(const TYSegment &seg, TYTabPoint &ptList) const
TYAcousticVolume & operator=(const TYAcousticVolume &other)
Operateur =.
virtual double activeSurface() const
virtual double surface() const
virtual DOM_Element toXML(DOM_Element &domElement)
virtual TYSourcePonctuelle srcPonctEquiv() const
virtual TYTabLPPolygon faces() const
virtual void distriSrcs()
virtual int fromXML(DOM_Element domElement)
virtual TYSpectre setGlobalLW(const TYSpectre &spectre, const double &surfGlobale, const int &regime=-1)
virtual std::string toString() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual double volume() const
virtual void propagateAtt(LPTYAttenuateur pAtt)
virtual void correctNbRegimes()
virtual void setIsAcousticModified(bool isModified)
virtual TYTabPoint sommets() const
virtual TYBox volEnglob() const
bool operator==(const TYAcousticVolume &other) const
Operateur ==.
bool _forceNormales
Persistence du forcage des normales.
virtual bool setSrcsLw()
virtual TYTabVector normals() const
void setMateriau(LPTYMateriauConstruction pMat)
virtual ~TYAcousticVolume()
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
virtual void inverseNormales()
virtual bool updateAcoustic(const bool &force=false)
Definition: TYBox.h:34
int fromXML(DOM_Element domElement)
TYColorInterface & operator=(const TYColorInterface &other)
void deepCopy(const TYColorInterface *pOther, bool copyId=true, bool pUseCopyTag=false)
DOM_Element toXML(DOM_Element &domElement)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:307
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:368
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:265
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:544
static bool testId(const TYUUID &id, const TYElement *pElem)
Definition: TYElement.cpp:216
void regenerateID()
Definition: TYElement.cpp:243
const TYUUID & getID() const
Definition: TYElement.cpp:176
TYElement * _pParent
Reference sur l'element parent.
Definition: TYElement.h:969
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYElement.h:532
void setParent(TYElement *pParent)
Definition: TYElement.h:692
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:381
virtual void setIsAcousticModified(bool isModified)
Definition: TYElement.cpp:248
virtual void setIsGeometryModified(bool isModified)
Definition: TYElement.cpp:253
TYElement * getElement() const
virtual DOM_Element toXML(DOM_Element &domElement)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
void setRegimeName(const QString &nom)
Definition: TYRegime.h:78
virtual void inverseNormale()
static bool getElementBoolValue(DOM_Element parentElem, DOMString nodeName, bool &nodeValue)
Definition: TYXMLTools.cpp:179
static void addElementBoolValue(DOM_Element &parentElem, DOMString nodeName, bool nodeValue)
Definition: TYXMLTools.cpp:77