Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYEtage.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #include <vector>
17 
18 #include "Tympan/core/defines.h"
19 #include "Tympan/core/logging.h"
22 
24 #if TY_USE_IHM
27 #endif
28 #include "TYEtage.h"
29 
30 #include <math.h>
31 
34 
35 TYEtage::TYEtage() : _closed(false), _surfAbsorbante(0.0), _volumeLibre(0.0)
36 {
38 
39  _bPourCalculTrajet = false;
40 #if TY_USE_IHM
41  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "UseNewAlgoGeom"))
42  {
43  _bPourCalculTrajet = TYPreferenceManager::getBool(TYDIRPREFERENCEMANAGER, "UseNewAlgoGeom");
44  }
45  else
46  {
47  TYPreferenceManager::setBool(TYDIRPREFERENCEMANAGER, "UseNewAlgoGeom", _bPourCalculTrajet);
48  }
49 #endif
50 
51  _pSol = new TYDalle();
52  _pSol->setParent(this);
53 
54  // Floor does not radiate by default
55  _pSol->setDensiteSrcs(0.0);
56  _pSol->setIsRayonnant(false, false);
57 
58  _pParoi = new TYParoi();
59 
60  _pPlafond = new TYDalle();
61  _pPlafond->setParent(this);
62 
64 
65  // Add an entry in the table associating the regimes
66  TYMapPtrElementInt mapElmRegime;
67  _tabRegimesMachines.push_back(mapElmRegime);
68 
69  TYMapPtrElementBool mapElmEtat;
70  _tabEtatMachines.push_back(mapElmEtat);
71 
72  _volEnglob = volEnglob(); // (re)calculate the enclosing volume
73 }
74 
76 
78 {
79  *this = other;
80 }
81 
83 {
86  _closed = other._closed;
87  _pParoi = other._pParoi;
88  _tabMur = other._tabMur;
89  _pSol = other._pSol;
90  _pPlafond = other._pPlafond;
91  _tabSources = other._tabSources;
92  _tabMachine = other._tabMachine;
93  _volEnglob = other._volEnglob;
94 
97 
98  return *this;
99 }
100 
101 bool TYEtage::operator==(const TYEtage& other) const
102 {
103  if (this != &other)
104  {
105  if (TYAcousticVolume::operator!=(other))
106  {
107  return false;
108  }
109  if (_bPourCalculTrajet != (other._bPourCalculTrajet))
110  {
111  return false;
112  }
113  if (_closed != other._closed)
114  {
115  return false;
116  }
117  if (_pParoi != other._pParoi)
118  {
119  return false;
120  }
121  if (!(_tabMur == other._tabMur))
122  {
123  return false;
124  }
125  if (_pSol != other._pSol)
126  {
127  return false;
128  }
129  if (_pPlafond != other._pPlafond)
130  {
131  return false;
132  }
133  if (_tabSources != other._tabSources)
134  {
135  return false;
136  }
137  if (_tabMachine != other._tabMachine)
138  {
139  return false;
140  }
141  }
142  return true;
143 }
144 
145 bool TYEtage::operator!=(const TYEtage& other) const
146 {
147  return !operator==(other);
148 }
149 
150 bool TYEtage::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
151 {
152  if (!TYAcousticVolume::deepCopy(pOther, copyId))
153  {
154  return false;
155  }
156 
157  TYEtage* pOtherEtage = (TYEtage*)pOther;
158 
159  _bPourCalculTrajet = pOtherEtage->_bPourCalculTrajet;
160  _closed = pOtherEtage->_closed;
161 
162  _pParoi->deepCopy(pOtherEtage->_pParoi, copyId);
163 
164  _pSol->deepCopy(pOtherEtage->_pSol, copyId);
165  _pSol->setParent(this);
166  _pPlafond->deepCopy(pOtherEtage->_pPlafond, copyId);
167  _pPlafond->setParent(this);
168 
169  _tabMur.clear();
170 
171  // This map will allow to retrieve the copied machine or ponctual source
172  // from the original one
173  std::map<TYElement*, TYElement*> elementOriginToDest;
174 
175  unsigned int i = 0;
176  for (i = 0; i < pOtherEtage->_tabMur.size(); i++)
177  {
178  LPTYMurGeoNode pMurGeoNode = new TYMurGeoNode(NULL, this);
179  pMurGeoNode->deepCopy(pOtherEtage->_tabMur[i], copyId);
180  pMurGeoNode->getElement()->setParent(this);
181  pMurGeoNode->setParent(this);
182  _tabMur.push_back(pMurGeoNode);
183  }
184 
185  _tabSources.clear();
186  LPTYUserSourcePonctuelle userSourcePontuelleOrigin = nullptr;
187  LPTYUserSourcePonctuelle userSourcePontuelleDest = nullptr;
188  for (i = 0; i < pOtherEtage->_tabSources.size(); i++)
189  {
191  pSourceGeoNode->deepCopy(pOtherEtage->_tabSources[i], copyId);
192  pSourceGeoNode->getElement()->setParent(this);
193  pSourceGeoNode->setParent(this);
194  userSourcePontuelleOrigin =
195  TYUserSourcePonctuelle::safeDownCast(pOtherEtage->_tabSources[i]->getElement());
196  userSourcePontuelleDest = TYUserSourcePonctuelle::safeDownCast(pSourceGeoNode->getElement());
197 
198  elementOriginToDest[userSourcePontuelleOrigin] = userSourcePontuelleDest;
199  _tabSources.push_back(pSourceGeoNode);
200  }
201 
202  _tabMachine.clear();
203  LPTYMachine machineOrigin;
204  LPTYMachine machineDest;
205  for (i = 0; i < pOtherEtage->_tabMachine.size(); i++)
206  {
207  LPTYMachineGeoNode pMachineGeoNode = new TYMachineGeoNode(new TYMachine);
208  pMachineGeoNode->deepCopy(pOtherEtage->_tabMachine[i], copyId);
209  pMachineGeoNode->getElement()->setParent(this);
210  pMachineGeoNode->setParent(this);
211  machineOrigin = TYMachine::safeDownCast(pOtherEtage->_tabMachine[i]->getElement());
212  machineDest = TYMachine::safeDownCast(pMachineGeoNode->getElement());
213  elementOriginToDest[machineOrigin] = machineDest;
214  _tabMachine.push_back(pMachineGeoNode);
215  }
216 
217  // Build Regime and Etat tables
218  int vectorIndex = 0;
219  LPTYElement elementOrigin;
220  LPTYElement elementDest;
221  TYMapPtrElementInt mapSources;
222  TYMapPtrElementBool mapEtats;
223  _tabRegimesMachines.clear();
224  _tabEtatMachines.clear();
225 
226  for (const auto& myMap : pOtherEtage->_tabRegimesMachines)
227  {
228  for (const auto& pair : myMap)
229  {
230  elementOrigin = pair.first;
231  int value = pair.second;
232  if (elementOrigin)
233  {
234  elementDest = elementOriginToDest[elementOrigin];
235  mapSources[elementDest] = value;
236  }
237  }
238  vectorIndex++;
239  }
240  _tabRegimesMachines.push_back(mapSources);
241 
242  vectorIndex = 0;
243  for (const auto& myMap : pOtherEtage->_tabEtatMachines)
244  {
245  for (const auto& pair : myMap)
246  {
247  elementOrigin = pair.first;
248  bool value = pair.second;
249 
250  if (elementOrigin)
251  {
252  elementDest = elementOriginToDest[elementOrigin];
253  mapEtats[elementDest] = value;
254  }
255  }
256  vectorIndex++;
257  }
258  _tabEtatMachines.push_back(mapEtats);
259 
260  _volEnglob = volEnglob();
263 
264  return true;
265 }
266 
267 std::string TYEtage::toString() const
268 {
269  return "TYEtage";
270 }
271 
273 {
274  unsigned int i = 0;
275 
276  DOM_Element domNewElem = TYAcousticVolume::toXML(domElement);
277 
278  TYXMLTools::addElementIntValue(domNewElem, "closed", _closed);
279 
280  // Save the default wall of the building
281  _pParoi->toXML(domNewElem);
282 
283  // Save the walls
284  DOM_Document domDoc = domElement.ownerDocument();
285  DOM_Element listMurNode = domDoc.createElement("ListMur");
286  domNewElem.appendChild(listMurNode);
287  for (i = 0; i < _tabMur.size(); i++)
288  {
289  // Add the wall
290  _tabMur[i]->toXML(listMurNode);
291  }
292 
293  _pSol->toXML(domNewElem);
294  _pPlafond->toXML(domNewElem);
295 
296  // Save the machines
297  DOM_Element listMachineNode = domDoc.createElement("ListMachine");
298  domNewElem.appendChild(listMachineNode);
299  for (i = 0; i < _tabMachine.size(); i++)
300  {
301  // Add machine if it is valid (i.e. contains volumes)
303 
304  if (pNode && pNode->getNbChild() > 0)
305  {
306  _tabMachine[i]->toXML(listMachineNode);
307  }
308  }
309 
310  DOM_Element listSourceNode = domDoc.createElement("ListSource");
311  domNewElem.appendChild(listSourceNode);
312  for (i = 0; i < _tabSources.size(); i++)
313  {
314  // Add the source
315  _tabSources[i]->toXML(listSourceNode);
316  }
317 
318  // Save the 'Etat' of the machines
319  DOM_Element listEtatNode = domDoc.createElement("TabEtatElement");
320  domNewElem.appendChild(listEtatNode);
321 
322  // Pour tous les regimes
323  for (i = 0; i < _tabRegimes.size(); i++)
324  {
325  if (_tabEtatMachines.size() == 0)
326  {
327  break;
328  }
329 
330  DOM_Element tmpNode = domDoc.createElement("Regime");
331  listEtatNode.appendChild(tmpNode);
332 
333  tmpNode.setAttribute("num", intToStr(i).data());
334 
335  TYMapPtrElementBool::iterator iter;
336  for (iter = _tabEtatMachines[i].begin(); iter != _tabEtatMachines[i].end(); iter++)
337  {
338  DOM_Element itemNode = domDoc.createElement("Element");
339  tmpNode.appendChild(itemNode);
340  itemNode.setAttribute("accVolNodeId", (*iter).first->getID().toString());
341  itemNode.setAttribute("state", intToStr((*iter).second).c_str());
342  }
343  }
344 
345  // Save 'Regime' of the machines
346  DOM_Element listRegimeNode = domDoc.createElement("TabRegimeElement");
347  domNewElem.appendChild(listRegimeNode);
348 
349  // For all 'Regimes'
350  for (i = 0; i < _tabRegimes.size(); i++)
351  {
352  if (_tabRegimesMachines.size() == 0)
353  {
354  break;
355  }
356 
357  DOM_Element tmpNode = domDoc.createElement("Regime");
358  listRegimeNode.appendChild(tmpNode);
359 
360  tmpNode.setAttribute("num", intToStr(i).data());
361 
362  TYMapPtrElementInt::iterator iter;
363  for (iter = _tabRegimesMachines[i].begin(); iter != _tabRegimesMachines[i].end(); iter++)
364  {
365  DOM_Element itemNode = domDoc.createElement("Element");
366  tmpNode.appendChild(itemNode);
367  itemNode.setAttribute("accVolNodeId", (*iter).first->getID().toString());
368  itemNode.setAttribute("regime", intToStr((*iter).second).c_str());
369  }
370  }
371 
372  return domNewElem;
373 }
374 
376 {
377  TYAcousticVolume::fromXML(domElement);
378 
379  // Reset
380  _tabMur.clear();
381  _tabSources.clear();
382  _tabMachine.clear();
383  _tabRegimesMachines.clear();
384  _tabEtatMachines.clear();
385 
386  bool closedOk = false;
387  bool solFound = false;
388  bool plafondFound = false;
389  bool tabEtatElemFound = false;
390  bool tabRegimeElemFound = false;
391 
392  LPTYMurGeoNode pMurGeoNode = new TYMurGeoNode(new TYMur, this);
394  LPTYMachineGeoNode pMachineGeoNode = new TYMachineGeoNode(new TYMachine, this);
395  int retVal = -1;
396  unsigned int i = 0, j = 0;
397  DOM_Element elemCur;
398 
399  // Create a list of duplicates and a flag to detect duplicate (fix bug 0006019)
400  std::map<TYUUID, TYUUID> mapDoublons;
401  // Flag of existence of duplicate
402  bool bDoublon = false;
403 
404  QDomNodeList childs = domElement.childNodes();
405  for (i = 0; i < childs.length(); i++)
406  {
407  elemCur = childs.item(i).toElement();
408  TYXMLTools::getElementBoolValue(elemCur, "closed", _closed, closedOk);
409 
410  _pParoi->callFromXMLIfEqual(elemCur);
411 
412  if (elemCur.nodeName() == "ListMur")
413  {
414  DOM_Element elemCur2;
415  QDomNodeList childs2 = elemCur.childNodes();
416 
417  for (j = 0; j < childs2.length(); j++)
418  {
419  elemCur2 = childs2.item(j).toElement();
420  if (pMurGeoNode->callFromXMLIfEqual(elemCur2, &retVal))
421  {
422  if (retVal == 1)
423  {
424  _tabMur.push_back(pMurGeoNode);
425  pMurGeoNode = new TYMurGeoNode(NULL, this);
426  }
427  }
428  }
429  }
430 
431  if (!solFound)
432  {
433  solFound = _pSol->callFromXMLIfEqual(elemCur);
434  }
435  else if (!plafondFound)
436  {
437  plafondFound = _pPlafond->callFromXMLIfEqual(elemCur);
438  }
439 
440  if (elemCur.nodeName() == "ListMachine")
441  {
442  DOM_Element elemCur2;
443  QDomNodeList childs2 = elemCur.childNodes();
444 
445  // Case of 'Batiment' holding machines, in order to preserve the link between 'Regime' 'Batiment'
446  // and 'Regime' 'Machine'
447  bool bBak = TYElement::getRegenerateID();
449 
450  for (j = 0; j < childs2.length(); j++)
451  {
452  elemCur2 = childs2.item(j).toElement();
453 
454  if (pMachineGeoNode->callFromXMLIfEqual(elemCur2, &retVal))
455  {
456  if (retVal == 1)
457  {
458  // Check the possible existence of a duplicate Id
459  TYElement* pElem = pMachineGeoNode->getElement();
460  TYUUID idOld = pElem->getID();
461  if (TYElement::testId(idOld, pElem))
462  {
463  // Change the Id of the element
464  pElem->regenerateID();
465  TYUUID idNew = pElem->getID();
466  // Add to the list of duplicates
467  mapDoublons[idOld] = idNew;
468  // Duplicate detected
469  bDoublon = true;
470  }
471  _tabMachine.push_back(pMachineGeoNode);
472  pMachineGeoNode = new TYMachineGeoNode(NULL, this);
473  }
474  }
475  }
476 
477  // Restoration of the previous state of ID regeneration
479  }
480 
481  if (elemCur.nodeName() == "ListSource")
482  {
483  DOM_Element elemCur2;
484  QDomNodeList childs2 = elemCur.childNodes();
485 
486  // Case of 'Batiment' holding machines, in order to preserve the link between 'Regime' 'Batiment'
487  // and 'Regime' 'Machine'
488  bool bBak = TYElement::getRegenerateID();
490 
491  for (j = 0; j < childs2.length(); j++)
492  {
493  elemCur2 = childs2.item(j).toElement();
494 
495  if (pSourceGeoNode->callFromXMLIfEqual(elemCur2, &retVal))
496  {
497  if (retVal == 1)
498  {
499  // If file 3.1, need to convert TYSourcePonctuelle into TYUserSourcePonctuelle
500  if (pSourceGeoNode->getElement()->isA("TYSourcePonctuelle"))
501  {
502  TYSourcePonctuelle* pSP =
503  TYSourcePonctuelle::safeDownCast(pSourceGeoNode->getElement());
505  pSourceGeoNode->setElement((TYElement*)pUSP);
506  }
507 
508  // Check the possible existence of a duplicate Id
509  TYElement* pElem = pSourceGeoNode->getElement();
510  TYUUID idOld = pElem->getID();
511  if (TYElement::testId(idOld, pElem))
512  {
513  // Change the Id of the element
514  pElem->regenerateID();
515  TYUUID idNew = pElem->getID();
516  // Add to the list of duplicates
517  mapDoublons[idOld] = idNew;
518  // Duplicate detected
519  bDoublon = true;
520  }
521 
522  pSourceGeoNode->getElement()->setParent(this);
523  _tabSources.push_back(pSourceGeoNode);
524  pSourceGeoNode = new TYUserSourcePonctuelleGeoNode(NULL, this);
525  }
526  }
527  }
528 
529  // Restoration of the previous state of ID regeneration
531  }
532 
533  if (elemCur.nodeName() == "TabEtatElement")
534  {
535  tabEtatElemFound = true;
536  DOM_Element elemCur3;
537  QDomNodeList childs3 = elemCur.childNodes();
538  // Loop on the 'Regimes' of the 'Etage'
539  for (j = 0; j < childs3.length(); j++)
540  {
541  elemCur3 = childs3.item(j).toElement();
542  int regimeEtage = 0;
543  bool regimeMachineOk = false;
544 
545  if (elemCur3.nodeName() == "Regime")
546  {
547  TYMapPtrElementBool mapEtatRegime;
548 
549  // Read again the number of the 'Regime'
550  TYXMLTools::getElementIntValue(elemCur3, "num", regimeEtage, regimeMachineOk);
551 
552  DOM_Element elemCur4;
553 
554  QDomNodeList childs4 = elemCur3.childNodes();
555 
556  // Loop on all the elements
557  for (unsigned int k = 0; k < childs4.length(); k++)
558  {
559  // bool idOk = false;
560  // bool elemOk = false;
561  QString id, oldId;
562  bool etat = false;
563  elemCur4 = childs4.item(k).toElement();
564 
565  if (elemCur4.nodeName() == "Element")
566  {
567  id = TYXMLTools::getElementAttributeToString(elemCur4, "accVolNodeId");
568  oldId = id;
569  etat = TYXMLTools::getElementAttributeToInt(elemCur4, "state");
570  }
571 
572  // Get a pointer on the element
573  if (bDoublon) // Substitution in case of a detected duplicate
574  {
575  TYUUID id2 = TYElement::fromString(id);
576  id2 = mapDoublons[id2];
577  id = TYElement::toString(id2);
578  }
579 
580  TYElement* pElement = TYElement::getInstance(id); // Try with the id
581 
582  if (!pElement)
583  {
584  pElement = TYElement::getInstance(oldId);
585  } // If it works try with old one
586 
587  // Add the element to the table of 'Etats'
588  if (pElement)
589  {
590  mapEtatRegime[pElement] = etat;
591  }
592  }
593 
594  // Add map of the 'Etats' in the table of the 'Etage'
595  _tabEtatMachines.push_back(mapEtatRegime);
596  }
597  }
598  }
599 
600  if (elemCur.nodeName() == "TabRegimeElement")
601  {
602  tabRegimeElemFound = true;
603 
604  DOM_Element elemCur3;
605 
606  QDomNodeList childs3 = elemCur.childNodes();
607 
608  // Loop on the 'Regimes' of the 'Etage'
609  for (j = 0; j < childs3.length(); j++)
610  {
611  elemCur3 = childs3.item(j).toElement();
612  int regimeEtage = 0;
613  bool regimeMachineOk = false;
614  if (elemCur3.nodeName() == "Regime")
615  {
616  TYMapPtrElementInt mapRegimeMachine;
617 
618  // Read again the number of the 'Regime'
619  TYXMLTools::getElementIntValue(elemCur3, "num", regimeEtage, regimeMachineOk);
620 
621  DOM_Element elemCur4;
622 
623  QDomNodeList childs4 = elemCur3.childNodes();
624  // Loop on all the elements
625  for (unsigned int k = 0; k < childs4.length(); k++)
626  {
627  elemCur4 = childs4.item(k).toElement();
628  // bool idOk = false;
629  // bool elemOk = false;
630  QString id, oldId;
631  int regimeMachine = 0;
632 
633  if (elemCur4.nodeName() == "Element")
634  {
635  id = TYXMLTools::getElementAttributeToString(elemCur4, "accVolNodeId");
636  oldId = id;
637  regimeMachine = TYXMLTools::getElementAttributeToInt(elemCur4, "regime");
638  }
639 
640  // Get a pointer on the element
641  if (bDoublon) // Substitution in case of a detected duplicate
642  {
643  TYUUID id2 = TYElement::fromString(id);
644  id2 = mapDoublons[id2];
645  id = TYElement::toString(id2);
646  }
647 
648  TYElement* pElement = TYElement::getInstance(id);
649 
650  if (!pElement)
651  {
652  pElement = TYElement::getInstance(oldId);
653  } // If it does not work, try the old one
654 
655  // Add the element to the table of the 'Etats'
656  if (pElement)
657  {
658  mapRegimeMachine[pElement] = regimeMachine;
659  }
660  }
661 
662  // Add the map of the 'Etats' to the table of the 'Etage'
663  _tabRegimesMachines.push_back(mapRegimeMachine);
664  }
665  }
666  }
667  }
668 
669  if (!(tabEtatElemFound && tabRegimeElemFound)) // Case old file format
670  {
671  // We start by clearing both arrays in case only one of them was found.
672  _tabRegimesMachines.clear();
673  _tabEtatMachines.clear();
674 
675  // Creation d'un map des etats et d'un map des regimes des machines
676  // Create a map of the 'Etats' and a map of the 'Regimes' of the 'Machines'
677  TYMapPtrElementBool mapEtatRegime;
678  TYMapPtrElementInt mapRegimeMachine;
679  _tabRegimesMachines.push_back(mapRegimeMachine);
680  _tabEtatMachines.push_back(mapEtatRegime);
681 
682  // Sources (and machines) will be reaffected automatically by function
683  // verifTabRegimeSources()
684  }
685 
687  _volEnglob = volEnglob();
690 
691  if (_forceNormales)
692  {
693  inverseNormales();
694  }
695 
697 
698  return 1;
699 }
700 
702 {
703  bool bFound = false;
704 
705  for (unsigned int i = 0; i < getNbRegimes(); i++)
706  {
707  TYMapPtrElementBool& mapEtatRegime = _tabEtatMachines[i];
708  TYMapPtrElementInt& mapRegimeMachine = _tabRegimesMachines[i];
709 
710  for (unsigned int j = 0; j < _tabSources.size(); j++) // For all the sources
711  {
712  bFound = false;
713  TYElement* pElement = _tabSources[j]->getElement();
714  TYSource* pSource = dynamic_cast<TYSource*>(pElement);
715  if (pSource == nullptr)
716  {
717  continue;
718  }
719 
720  std::map<TYElement*, bool>::iterator itEtat;
721 
722  for (itEtat = mapEtatRegime.begin(); itEtat != mapEtatRegime.end(); itEtat++)
723  {
724  if (itEtat->first == pElement)
725  {
726  bFound = true;
727  break;
728  }
729  }
730 
731  if (!bFound)
732  {
733  mapEtatRegime[pElement] = false;
734  mapRegimeMachine[pElement] = 0;
735  }
736  }
737 
738  for (unsigned int j = 0; j < _tabMachine.size(); j++) // For all the machines
739  {
740  bFound = false;
741  TYElement* pElement = _tabMachine[j]->getElement();
742  if (!pElement->isA("TYMachine"))
743  {
744  continue;
745  }
746 
747  std::map<TYElement*, bool>::iterator itEtat;
748 
749  for (itEtat = mapEtatRegime.begin(); itEtat != mapEtatRegime.end(); itEtat++)
750  {
751  if (itEtat->first == pElement)
752  {
753  bFound = true;
754  break;
755  }
756  }
757 
758  if (!bFound)
759  {
760  mapEtatRegime[pElement] = false;
761  mapRegimeMachine[pElement] = 0;
762  }
763  }
764  }
765 }
766 
767 void TYEtage::exportCSV(std::ofstream& ofs)
768 {
769  // Export name of the object
770  ofs << _name.toStdString() << '\n';
771 
772  // Export acoustic data
774 
775  for (unsigned int i = 0; i < _tabMur.size(); i++)
776  {
777  TYMur* pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
778  pMur->exportCSV(ofs);
779  }
780 
781  // Export floor and ceiling
782  _pSol->exportCSV(ofs);
783  _pPlafond->exportCSV(ofs);
784 
785  ofs << '\n';
786 }
787 
788 void TYEtage::getChilds(LPTYElementArray& childs, bool recursif /*=true*/)
789 {
790  TYAcousticVolume::getChilds(childs, recursif);
791 
792  unsigned int i = 0;
793 
794  for (i = 0; i < _tabMur.size(); i++)
795  {
796  childs.push_back(_tabMur[i]->getElement());
797  }
798 
799  childs.push_back(_pSol);
800  childs.push_back(_pPlafond);
801 
802  if (recursif)
803  {
804  for (i = 0; i < _tabMur.size(); i++)
805  {
806  _tabMur[i]->getChilds(childs, recursif);
807  }
808 
809  _pSol->getChilds(childs, recursif);
810  _pPlafond->getChilds(childs, recursif);
811 
812  for (i = 0; i < _tabMachine.size(); i++)
813  {
814  _tabMachine[i]->getChilds(childs, recursif);
815  }
816 
817  for (i = 0; i < _tabSources.size(); i++)
818  {
819  _tabSources[i]->getChilds(childs, recursif);
820  }
821  }
822 }
823 
825 {
826  assert(pMur);
827 
828  pMur->setParent(this);
829  pMur->setParoi(_pParoi);
830 
831  _tabMur.push_back(new TYMurGeoNode((LPTYElement)pMur));
832 
834  _volEnglob = volEnglob();
837 
838  return true;
839 }
840 
841 bool TYEtage::remMur(const LPTYMur pMur)
842 {
843  assert(pMur);
844  bool ret = false;
845  TYTabMurGeoNode::iterator ite;
846 
847  for (ite = _tabMur.begin(); ite != _tabMur.end(); ite++)
848  {
849  if (TYMur::safeDownCast((*ite)->getElement()) == pMur)
850  {
851  _tabMur.erase(ite);
852  ret = true;
853  break;
854  }
855  }
856 
858  _volEnglob = volEnglob();
861 
862  return ret;
863 }
864 
865 bool TYEtage::remMur(QString idMur)
866 {
867  bool ret = false;
868  TYTabMurGeoNode::iterator ite;
869 
870  for (ite = _tabMur.begin(); ite != _tabMur.end(); ite++)
871  {
872  if ((*ite)->getElement()->getID().toString() == idMur)
873  {
874  _tabMur.erase(ite);
875  ret = true;
876  break;
877  }
878  }
879 
881  _volEnglob = volEnglob();
884 
885  return ret;
886 }
887 
889 {
890  _tabMur.clear();
892  _volEnglob = volEnglob();
895 }
896 
897 bool TYEtage::setMurs(const TYTabPoint& tabPts, double hauteur /*=2.0*/, bool close /*=true*/)
898 {
899  TYPoint pt0, pt1;
900  size_t count = tabPts.size();
901  ORepere3D repMur;
902 
903  if ((count == 0) || (hauteur <= 0.0))
904  {
905  return false;
906  }
907 
908  // Reset
909  _tabMur.clear();
910 
911  // If there are at least 2 'Murs', then the 'Etage' cannot be closed
912  if (tabPts.size() > 1)
913  {
914  // Preserve 'Etat'
915  _closed = close;
916  }
917  else
918  {
919  _closed = false;
920  }
921 
922  // We test if first and last point coincide with a tolerance
923  if (tabPts[0].isEqual(tabPts[count - 1]))
924  {
925  // We do not reconsider the last point in the iteration
926  count -= 1;
927  }
928  else if (!_closed)
929  {
930  // Stop before closing walls
931  count -= 1;
932  }
933 
934  // A face for each pair of consecutive points
935  for (int i = 0; i < count; i++)
936  {
937  pt1 = tabPts[i];
938  pt0 = tabPts[(i + 1) % tabPts.size()];
939 
940  // Vector for "length" of the face
941  OVector3D vec01(pt0, pt1);
942 
943  // The wall for this face
944  LPTYMur pMur = new TYMur();
945 
946  pMur->setParent(this);
947  // Wall dimensions
948  pMur->setSize(vec01.norme(), hauteur);
949 
950  // Wall position
951  repMur._origin = OVector3D(pt0) + (vec01 * 0.5);
952  repMur._origin._z = hauteur / 2.0;
953 
954  // Wall orientation
955  vec01.normalize();
956  repMur._vecI = vec01;
957  repMur._vecJ = OVector3D(0.0, 0.0, 1.0);
958  repMur._vecK = vec01.cross(repMur._vecJ);
959 
960  LPTYMurGeoNode pMurGeoNode = new TYMurGeoNode();
961  pMurGeoNode->setRepere(repMur);
962  pMurGeoNode->setElement((LPTYElement)pMur);
963  _tabMur.push_back(pMurGeoNode);
964  }
965 
967  _volEnglob = volEnglob();
970 
971  return true;
972 }
973 
975 {
976  TYTabPoint res;
977  size_t nbPts = _tabMur.size();
978  size_t i = 0;
979 
980  if (!nbPts)
981  {
982  return res;
983  }
984 
985  res.reserve(nbPts);
986 
987  for (i = 0; i < nbPts; i++)
988  {
989  // We retrieve the point
990  TYPoint pt = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->_pts[2];
991 
992  // We pass in the coordinate system of the 'Etage'
993  pt = _tabMur[i]->getMatrix() * pt;
994 
995  // Add the point
996  res.push_back(pt);
997  }
998 
999  // If the 'Etage' is not closed (Ecran), we add last point manually
1000  if (!_closed)
1001  {
1002  // We retrieve the point
1003  TYPoint pt = TYMur::safeDownCast(_tabMur[i - 1]->getElement())->getBoundingRect()->_pts[3];
1004 
1005  // We pass in the coordinate system of the 'Etage'
1006  pt = _tabMur[i - 1]->getMatrix() * pt;
1007 
1008  // Add the point
1009  res.push_back(pt);
1010  }
1011 
1012  return res;
1013 }
1014 
1015 void TYEtage::setHauteur(double hauteur)
1016 {
1017  size_t nbPts = _tabMur.size();
1018 
1019  if (nbPts <= 0)
1020  {
1021  return;
1022  }
1023 
1024  for (size_t i = 0; i < nbPts; i++)
1025  {
1026  // Apply new height
1027  TYMur::safeDownCast(_tabMur[i]->getElement())->setSizeY(hauteur);
1028 
1029  ORepere3D repere3D = _tabMur[i]->getORepere3D();
1030  // Set wall center at 1/2 height
1031  repere3D._origin._z = hauteur / 2.0;
1032  _tabMur[i]->setRepere(repere3D);
1033  }
1034 
1035  updateSolPlafond();
1036  _volEnglob = volEnglob();
1039 }
1040 
1041 double TYEtage::getHauteur() const
1042 {
1043  double res = 0.0;
1044 
1045  if (_tabMur.size() > 0)
1046  {
1047  res = TYMur::safeDownCast(_tabMur[0]->getElement())->getSizeY();
1048  }
1049 
1050  return res;
1051 }
1052 
1054 {
1055  assert(pMachineGeoNode);
1056 
1057  TYMachine* pMachine = TYMachine::safeDownCast(pMachineGeoNode->getElement());
1058 
1059  assert(pMachine);
1060 
1061  pMachineGeoNode->setParent(this);
1062  pMachine->setParent(this);
1063 
1064  _tabMachine.push_back(pMachineGeoNode);
1065 
1066  // For all the 'Regimes' of the 'Etage'
1067  TYElement* pElement = (TYElement*)pMachine;
1068  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1069  {
1070  // Add machine into the associative table of the regime
1071  _tabRegimesMachines[i][pElement] = 0;
1072 
1073  // Set the 'Etat' of the machine active for this regime
1074  _tabEtatMachines[i][pElement] = true;
1075  }
1076 
1077  setIsGeometryModified(true);
1078 
1079  return true;
1080 }
1081 
1082 bool TYEtage::addMachine(LPTYMachine pMachine, const TYRepere& pos)
1083 {
1084  return addMachine(new TYMachineGeoNode(pos, (LPTYElement)pMachine));
1085 }
1086 
1088 {
1089  return addMachine(new TYMachineGeoNode((LPTYElement)pMachine));
1090 }
1091 
1092 bool TYEtage::remMachine(const LPTYMachineGeoNode pMachineGeoNode)
1093 {
1094  assert(pMachineGeoNode);
1095  bool ret = false;
1096  TYTabMachineGeoNode::iterator ite;
1097 
1098  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1099  {
1100  if ((*ite) == pMachineGeoNode)
1101  {
1102  _tabMachine.erase(ite);
1103  ret = true;
1104  break;
1105  }
1106  }
1107 
1108  // For all the regimes of the 'Etage'
1109  TYElement* pElement = pMachineGeoNode->getElement();
1110  TYMapPtrElementInt::iterator iter;
1111  TYMapPtrElementBool::iterator itb;
1112  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1113  {
1114  iter = _tabRegimesMachines[i].find(pElement);
1115  // Delete the machine from the associative table of the regime
1116  _tabRegimesMachines[i].erase(iter);
1117 
1118  itb = _tabEtatMachines[i].find(pElement);
1119  _tabEtatMachines[i].erase(itb);
1120  }
1121 
1122  setIsGeometryModified(true);
1123 
1124  return ret;
1125 }
1126 
1127 bool TYEtage::remMachine(const LPTYMachine pMachine)
1128 {
1129  assert(pMachine);
1130  bool ret = false;
1131  TYTabMachineGeoNode::iterator ite;
1132 
1133  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1134  {
1135  if (TYMachine::safeDownCast((*ite)->getElement()) == pMachine)
1136  {
1137  _tabMachine.erase(ite);
1138  ret = true;
1139  break;
1140  }
1141  }
1142 
1143  // For all the regimes of the 'Etage'
1144  TYElement* pElement = (TYElement*)pMachine;
1145  TYMapPtrElementInt::iterator iter;
1146  TYMapPtrElementBool::iterator itb;
1147  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1148  {
1149  iter = _tabRegimesMachines[i].find(pElement);
1150  // Delete the machine from the associative table of the regime
1151  _tabRegimesMachines[i].erase(iter);
1152 
1153  itb = _tabEtatMachines[i].find(pElement);
1154  _tabEtatMachines[i].erase(itb);
1155  }
1156 
1157  setIsGeometryModified(true);
1158 
1159  return ret;
1160 }
1161 
1162 bool TYEtage::remMachine(QString idMachine)
1163 {
1164  bool ret = false;
1165  TYTabMachineGeoNode::iterator ite;
1166 
1167  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1168  {
1169  if ((*ite)->getElement()->getID().toString() == idMachine)
1170  {
1171  _tabMachine.erase(ite);
1172  ret = true;
1173  break;
1174  }
1175  }
1176 
1177  // For all the regimes of the 'Etage'
1178  TYElement* pElement = (*ite)->getElement();
1179  TYMapPtrElementInt::iterator iter;
1180  TYMapPtrElementBool::iterator itb;
1181  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1182  {
1183  iter = _tabRegimesMachines[i].find(pElement);
1184  // Delete the machine from the associative table of the regime
1185  _tabRegimesMachines[i].erase(iter);
1186 
1187  itb = _tabEtatMachines[i].find(pElement);
1188  _tabEtatMachines[i].erase(itb);
1189  }
1190  setIsGeometryModified(true);
1191 
1192  return ret;
1193 }
1194 
1196 {
1197  unsigned int i = 0, j = 0;
1198 
1199  TYMapPtrElementInt::iterator iter;
1200  for (i = 0; i < _tabRegimesMachines.size(); i++)
1201  {
1202  for (j = 0; j < _tabMachine.size(); j++)
1203  {
1204  TYElement* pElement = _tabMachine[j]->getElement();
1205  iter = _tabRegimesMachines[i].find(pElement);
1206  _tabRegimesMachines[i].erase(iter);
1207  }
1208  }
1209 
1210  TYMapPtrElementBool::iterator itb;
1211  for (i = 0; i < _tabEtatMachines.size(); i++)
1212  {
1213  for (j = 0; j < _tabMachine.size(); j++)
1214  {
1215  TYElement* pElement = _tabMachine[j]->getElement();
1216  itb = _tabEtatMachines[i].find(pElement);
1217  _tabEtatMachines[i].erase(itb);
1218  }
1219  }
1220 
1221  _tabMachine.clear();
1222  setIsGeometryModified(true);
1223 }
1224 
1226 {
1227  assert(pMachine);
1228  TYTabMachineGeoNode::iterator ite;
1229 
1230  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1231  {
1232  if (TYMachine::safeDownCast((*ite)->getElement()) == pMachine)
1233  {
1234  return (*ite);
1235  }
1236  }
1237 
1238  return NULL;
1239 }
1240 
1242 {
1243  assert(pSourceGeoNode);
1244  assert(pSourceGeoNode->getElement());
1245 
1246  if (this->isA("TYAcousticCylinder"))
1247  {
1248  return false;
1249  }
1250 
1251  pSourceGeoNode->setParent(this);
1252  pSourceGeoNode->getElement()->setParent(this);
1253 
1254  _tabSources.push_back(pSourceGeoNode);
1255 
1256  // For all the regimes of the 'Etage'
1257  TYElement* pElement = pSourceGeoNode->getElement();
1258  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1259  {
1260  // Add the machine into the associative table of the regime
1261  _tabRegimesMachines[i][pElement] = 0;
1262  // Set the 'Etat' of the machine active for this regime
1263  _tabEtatMachines[i][pElement] = true;
1264  }
1265  setIsGeometryModified(true);
1266 
1267  return true;
1268 }
1269 
1271 {
1272  return addSource(new TYUserSourcePonctuelleGeoNode(pos, (LPTYElement)pSource));
1273 }
1274 
1276 {
1277  return addSource(new TYUserSourcePonctuelleGeoNode((LPTYElement)pSource));
1278 }
1279 
1281 {
1282  assert(pSourceGeoNode);
1283 
1284  bool ret = false;
1285  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1286 
1287  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1288  {
1289  if ((*ite) == pSourceGeoNode)
1290  {
1291  _tabSources.erase(ite);
1292  ret = true;
1293  break;
1294  }
1295  }
1296 
1297  // For all the regimes of the 'Etage'
1298  TYElement* pElement = (*ite)->getElement();
1299  TYMapPtrElementInt::iterator iter;
1300  TYMapPtrElementBool::iterator itb;
1301  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1302  {
1303  iter = _tabRegimesMachines[i].find(pElement);
1304  // Delete the machine from the associative table of the regime
1305  _tabRegimesMachines[i].erase(iter);
1306 
1307  itb = _tabEtatMachines[i].find(pElement);
1308  _tabEtatMachines[i].erase(itb);
1309  }
1310  setIsGeometryModified(true);
1311 
1312  return ret;
1313 }
1314 
1316 {
1317  assert(pSource);
1318  bool ret = false;
1319  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1320 
1321  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1322  {
1323  if (TYUserSourcePonctuelle::safeDownCast((*ite)->getElement()) == pSource)
1324  {
1325  _tabSources.erase(ite);
1326  ret = true;
1327  break;
1328  }
1329  }
1330 
1331  // For all the regimes of the 'Etage'
1332  TYElement* pElement = (TYElement*)pSource;
1333  TYMapPtrElementInt::iterator iter;
1334  TYMapPtrElementBool::iterator itb;
1335  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1336  {
1337  iter = _tabRegimesMachines[i].find(pElement);
1338  // Delete the machine from the associative table of the regime
1339  _tabRegimesMachines[i].erase(iter);
1340 
1341  itb = _tabEtatMachines[i].find(pElement);
1342  _tabEtatMachines[i].erase(itb);
1343  }
1344 
1345  setIsGeometryModified(true);
1346 
1347  return ret;
1348 }
1349 
1350 bool TYEtage::remSource(QString idSource)
1351 {
1352  bool ret = false;
1353  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1354 
1355  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1356  {
1357  if (TYUserSourcePonctuelle::safeDownCast((*ite)->getElement())->getID().toString() == idSource)
1358  {
1359  _tabSources.erase(ite);
1360  ret = true;
1361  break;
1362  }
1363  }
1364 
1365  TYElement* pElement = (*ite)->getElement();
1366  TYMapPtrElementInt::iterator iter;
1367  TYMapPtrElementBool::iterator itb;
1368  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1369  {
1370  iter = _tabRegimesMachines[i].find(pElement);
1371  // Delete the source from the associative table of the regime
1372  _tabRegimesMachines[i].erase(iter);
1373 
1374  itb = _tabEtatMachines[i].find(pElement);
1375  _tabEtatMachines[i].erase(itb);
1376  }
1377 
1378  setIsGeometryModified(true);
1379 
1380  return ret;
1381 }
1382 
1384 {
1385  unsigned int i = 0, j = 0;
1386 
1387  TYMapPtrElementInt::iterator iter;
1388  for (i = 0; i < _tabRegimesMachines.size(); i++)
1389  {
1390  for (j = 0; j < _tabSources.size(); j++)
1391  {
1392  TYElement* pElement = _tabSources[j]->getElement();
1393  iter = _tabRegimesMachines[i].find(pElement);
1394  _tabRegimesMachines[i].erase(iter);
1395  }
1396  }
1397 
1398  TYMapPtrElementBool::iterator itb;
1399  for (i = 0; i < _tabEtatMachines.size(); i++)
1400  {
1401  for (j = 0; j < _tabSources.size(); j++)
1402  {
1403  TYElement* pElement = _tabSources[j]->getElement();
1404  itb = _tabEtatMachines[i].find(pElement);
1405  _tabEtatMachines[i].erase(itb);
1406  }
1407  }
1408 
1409  _tabSources.clear();
1410 
1411  setIsGeometryModified(true);
1412 }
1413 
1415 {
1416  assert(pSource);
1417  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1418 
1419  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1420  {
1421  if (TYUserSourcePonctuelle::safeDownCast((*ite)->getElement()) == pSource)
1422  {
1423  return (*ite);
1424  }
1425  }
1426 
1427  return NULL;
1428 }
1429 
1430 void TYEtage::setRegime(TYSpectre& Spectre, int regime /*=-1*/, bool recursif /*=true*/)
1431 {
1432  if (recursif)
1433  {
1434  for (unsigned int i = 0; i < _tabMur.size(); i++)
1435  {
1436  TYMur::safeDownCast(_tabMur[i]->getElement())->setRegime(Spectre, regime, recursif);
1437  }
1438  }
1439 
1440  TYAcousticVolume::setRegime(Spectre, regime, recursif);
1441 }
1442 
1443 bool TYEtage::remRegime(int regime)
1444 {
1445  for (unsigned int i = 0; i < _tabMur.size(); i++)
1446  {
1447  TYMur::safeDownCast(_tabMur[i]->getElement())->remRegime(regime);
1448  }
1449 
1450  _pSol->remRegime(regime);
1451  _pPlafond->remRegime(regime);
1452 
1453  // Delete the associative table 'Regime' / 'Regime Machine'
1454  _tabRegimesMachines.erase(_tabRegimesMachines.begin() + regime);
1455  _tabEtatMachines.erase(_tabEtatMachines.begin() + regime);
1456 
1457  return TYAcousticVolume::remRegime(regime);
1458 }
1459 
1460 void TYEtage::setCurRegime(int regime)
1461 {
1462  if (regime >= (int)_tabRegimesMachines.size())
1463  {
1464  return;
1465  }
1466  if (regime < 0)
1467  {
1468  regime = (int)_tabRegimes.size() - 1;
1469  }
1470 
1471  for (unsigned int i = 0; i < _tabMur.size(); i++)
1472  {
1473  TYMur::safeDownCast(_tabMur[i]->getElement())->setCurRegime(regime);
1474  }
1475 
1476  _pSol->setCurRegime(regime);
1477  _pPlafond->setCurRegime(regime);
1478 
1479  // Set the machines to the corresponding regime
1480  TYMapPtrElementInt::iterator iter;
1481  for (iter = _tabRegimesMachines[regime].begin(); iter != _tabRegimesMachines[regime].end(); iter++)
1482  {
1483  TYElement* pElement = (*iter).first;
1484  if (pElement->isA("TYMachine"))
1485  {
1486  LPTYMachine pMachine = TYMachine::safeDownCast(pElement);
1487  assert(pMachine);
1488  pMachine->setCurRegime((*iter).second);
1489  }
1490  else
1491  {
1493  assert(pSource);
1494  pSource->setCurrentRegime((*iter).second);
1495  }
1496  }
1497 
1498  // Set the machines in the corresponding 'Etat' ('rayonnant' / ' non rayonnant')
1499  TYMapPtrElementBool::iterator iter2;
1500  for (iter2 = _tabEtatMachines[regime].begin(); iter2 != _tabEtatMachines[regime].end(); iter2++)
1501  {
1502  TYElement* pElement = (*iter2).first;
1503  if (pElement->isA("TYMachine"))
1504  {
1505  LPTYMachine pMachine = TYMachine::safeDownCast(pElement);
1506  assert(pMachine);
1507  bool etat = (*iter2).second;
1508  pMachine->setIsRayonnant(etat);
1509  }
1510  else
1511  {
1513  assert(pSource);
1514  pSource->setIsRayonnant((*iter2).second);
1515  }
1516  }
1517 
1519 
1520  setIsAcousticModified(true);
1521 }
1522 
1524 {
1525  int value = TYAcousticInterface::addRegime(regime);
1526 
1527  TYMapPtrElementInt mapElmRegime = _tabRegimesMachines[0];
1528  _tabRegimesMachines.push_back(mapElmRegime);
1529 
1530  TYMapPtrElementBool mapElmBool = _tabEtatMachines[0];
1531  _tabEtatMachines.push_back(mapElmBool);
1532 
1533  // Creation of the new 'Regime' for all walls, as well as the floor and ceiling
1534  for (unsigned int i = 0; i < _tabMur.size(); i++)
1535  {
1536  TYMur::safeDownCast(_tabMur[i]->getElement())->addRegime();
1537  }
1538 
1539  _pSol->addRegime();
1540  _pPlafond->addRegime();
1541 
1542  return value;
1543 }
1544 
1546 {
1547  int value = TYAcousticInterface::addRegime();
1548 
1549  TYMapPtrElementInt mapElmRegime = _tabRegimesMachines[0];
1550  _tabRegimesMachines.push_back(mapElmRegime);
1551 
1552  TYMapPtrElementBool mapElmBool = _tabEtatMachines[0];
1553  _tabEtatMachines.push_back(mapElmBool);
1554 
1555  // Creation of the new 'Regime' for all walls, as well as the floor and ceiling
1556  for (unsigned int i = 0; i < _tabMur.size(); i++)
1557  {
1558  TYMur::safeDownCast(_tabMur[i]->getElement())->addRegime();
1559  }
1560 
1561  _pSol->addRegime();
1562  _pPlafond->addRegime();
1563 
1564  return value;
1565 }
1566 
1567 void TYEtage::setNextRegimeNb(const int& next)
1568 {
1569  _nextRegime = next;
1570 
1571  for (unsigned int i = 0; i < _tabMur.size(); i++)
1572  {
1573  TYMur::safeDownCast(_tabMur[i]->getElement())->setNextRegimeNb(next);
1574  }
1575 
1576  _pSol->setNextRegimeNb(next);
1577  _pPlafond->setNextRegimeNb(next);
1578 }
1579 
1580 void TYEtage::setRegimeName(const QString& name)
1581 {
1582  bool status = true;
1583  TYRegime& reg = getRegimeNb(_curRegime, status);
1584  if (status)
1585  {
1586  reg.setRegimeName(name);
1587  }
1588 
1589  for (unsigned int i = 0; i < _tabMur.size(); i++)
1590  {
1591  TYMur::safeDownCast(_tabMur[i]->getElement())->setRegimeName(name);
1592  }
1593 
1596 }
1597 
1599 {
1602 
1603  // We retrieve only the sources of the walls
1604  // The 'Etage' is considered as any acoustic volume
1605  for (unsigned int i = 0; i < _tabMur.size(); i++)
1606  {
1607  LPTYMur pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
1608  // Retreive all the sources of the child ...
1609  if (pMur->getIsRayonnant())
1610  {
1611  tabChild = pMur->getSrcs();
1612 
1613  // Matrix concatenation
1614  OMatrix matrix = _tabMur[i]->getMatrix();
1615  for (unsigned int j = 0; j < tabChild.size(); j++)
1616  {
1617  tabChild[j]->setMatrix(matrix * tabChild[j]->getMatrix());
1618  }
1619 
1620  //...and add into the table to be returned
1621  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
1622  }
1623  }
1624 
1625  tabChild = _pSol->getSrcs();
1626  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
1627 
1628  tabChild = _pPlafond->getSrcs();
1629  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
1630 
1631  return tab;
1632 }
1633 
1635 {
1636  return TYSourcePonctuelle();
1637 }
1638 
1639 void TYEtage::setDensiteSrcsH(double densite, bool recursif)
1640 {
1642 
1643  if (recursif)
1644  {
1645  for (unsigned int i = 0; i < _tabMur.size(); i++)
1646  {
1647  TYMur::safeDownCast(_tabMur[i]->getElement())->setDensiteSrcsH(getDensiteSrcsH());
1648  }
1649  // Floor is inactive
1651  }
1652 }
1653 
1654 void TYEtage::setDensiteSrcsV(double densite, bool recursif)
1655 {
1657 
1658  if (recursif)
1659  {
1660  for (unsigned int i = 0; i < _tabMur.size(); i++)
1661  {
1662  TYMur::safeDownCast(_tabMur[i]->getElement())->setDensiteSrcsV(getDensiteSrcsV());
1663  }
1664  // Floor is inactive
1666  }
1667 }
1668 
1670 {
1671  unsigned int i = 0;
1672 
1673  // First remove the present sources
1674  for (i = 0; i < _tabMur.size(); i++)
1675  {
1676  TYMur::safeDownCast(_tabMur[i]->getElement())->remAllSrcs();
1677  }
1678 
1679  _pSol->getSrcSurf()->remAllSrc();
1681 
1682  // Walls
1683  for (i = 0; i < _tabMur.size(); i++)
1684  {
1685  LPTYMur pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
1686  if (pMur->getIsRayonnant())
1687  {
1688  pMur->distriSrcs();
1689  }
1690  }
1691 
1692  // Floor
1693  if (_pSol->getIsRayonnant())
1694  {
1695  _pSol->distriSrcs();
1696  }
1697 
1698  // Ceiling
1699  if (_pPlafond->getIsRayonnant())
1700  {
1701  _pPlafond->distriSrcs();
1702  }
1703 }
1704 
1706 {
1707  bool ret = true;
1708 
1710  LWEtage.setType(SPECTRE_TYPE_LW);
1711 
1714 
1715  // FIRST HANDLE THE WALLS
1716 
1717  // For all the walls
1718  for (unsigned int i = 0; i < _tabMur.size(); i++)
1719  {
1720  // Wall matrix
1721  OMatrix matMur = _tabMur[i]->getMatrix();
1722 
1723  // Current wall
1724  LPTYMur pCurrentMur = TYMur::safeDownCast(_tabMur[i]->getElement());
1726 
1727  // If the wall is radiating, wa compute its power
1728  if (pCurrentMur->getIsRayonnant())
1729  {
1730  // Power spectrum affected to the wall
1731  double surfMur = pCurrentMur->activeSurface();
1732 
1733  // If "Puissance calculée", then the power of the wall is set to 0
1734  if (pCurrentMur->getTypeDistribution() == TY_PUISSANCE_IMPOSEE)
1735  {
1736  LWMur = pCurrentMur->getCurrentSpectre().toGPhy();
1737  }
1738 
1739  LWMur.setType(SPECTRE_TYPE_LW);
1740 
1741  // For all the faces of the wall
1742  TYTabAcousticSurfaceGeoNode tabAcousticSurf = pCurrentMur->getTabAcousticSurf();
1743 
1744  LPTYParoi pMurParoi = TYMur::safeDownCast(_tabMur[i]->getElement())->getParoi();
1745 
1746  // For all the surfaces making up the wall
1747  for (unsigned int j = 0; j < tabAcousticSurf.size(); j++)
1748  {
1749  LPTYAcousticSurfaceGeoNode pSurfaceNode = tabAcousticSurf[j];
1750  OMatrix matSurf = matMur * pSurfaceNode->getMatrix();
1751 
1752  LPTYAcousticSurface pCurrentSurf =
1754  assert(pCurrentSurf);
1755 
1756  if (pCurrentSurf->getIsSub() == true)
1757  {
1758  if (pCurrentSurf->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1759  {
1760  LWElt = getPuissanceRayonnee(pCurrentSurf, matSurf, pMurParoi);
1761  LWEtage = LWEtage.sum(LWElt);
1762  }
1763  else
1764  {
1765  LWEtage = LWEtage.sum(pCurrentSurf->getCurrentSpectre().toGPhy());
1766  }
1767  }
1768  else
1769  {
1770  if (pCurrentMur->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1771  {
1772  LWElt = getPuissanceRayonnee(pCurrentSurf, matSurf, pMurParoi);
1773  LWMur = LWMur.sum(LWElt);
1774  }
1775  else
1776  {
1777  double surfElt = pCurrentSurf->surface();
1778  LWElt = LWMur.mult(surfElt / surfMur);
1779  }
1780  }
1781 
1782  // FIX ANOMALY 28 - test of the power assignment type ('calculée' / 'imposée' ou
1783  // 'mesurée')
1784  if (pCurrentSurf->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1785  {
1786  TYSpectre aSpectre(LWElt.toDB());
1787  pCurrentSurf->setRegime(aSpectre, -1, false);
1788  }
1789 
1790  ret &= pCurrentSurf->setSrcsLw();
1791  }
1792 
1793  // FIX ANOMALY 28 - test of the power assignment type ('calculée' / 'imposée' ou
1794  // 'mesurée')
1795  if (pCurrentMur->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1796  {
1797  TYSpectre aSpectre(LWMur.toDB());
1798  pCurrentMur->setRegime(aSpectre, -1, false);
1799  }
1800  }
1801  else // The wall is not radiating, so it is assigned a zero power
1802  {
1803  LWMur.setType(SPECTRE_TYPE_LW);
1804  }
1805 
1806  LWEtage = LWEtage.sum(LWMur);
1807  }
1808 
1809  // HANDLE THE 'DALLES'
1810  if (_closed) // If it is a 'Batiment' and not a simple 'Ecran'
1811  {
1812  OMatrix matDalle;
1813  if (_pSol->getIsRayonnant())
1814  {
1816  {
1817  LPTYParoi pSolParoi = _pSol->getParoi();
1818  LWElt = getPuissanceRayonnee(_pSol, matDalle, pSolParoi);
1819  TYSpectre aTYSpectre(LWElt.toDB());
1820  _pSol->setRegime(aTYSpectre, -1, false);
1821  LWEtage = LWEtage.sum(LWElt);
1822  }
1823  else
1824  {
1825  LWEtage = LWEtage.sum(_pSol->getCurrentSpectre().toGPhy());
1826  }
1827 
1828  _pSol->setSrcsLw();
1829  }
1830 
1831  if (_pPlafond->getIsRayonnant())
1832  {
1834  {
1835  LPTYParoi pPlafondParoi = _pPlafond->getParoi();
1836  LWElt = getPuissanceRayonnee(_pPlafond, matDalle, pPlafondParoi);
1837  TYSpectre aTYSpectre(LWElt.toDB());
1838  _pPlafond->setRegime(aTYSpectre, -1, false);
1839  LWEtage = LWEtage.sum(LWElt);
1840  }
1841  else
1842  {
1843  LWEtage = LWEtage.sum(_pPlafond->getCurrentSpectre().toGPhy());
1844  }
1845 
1846  _pPlafond->setSrcsLw();
1847  }
1848  }
1849  TYSpectre aTYSpectre(LWEtage.toDB());
1850  this->setRegime(aTYSpectre, -1, false);
1851  return ret;
1852 }
1853 
1854 double TYEtage::volume() const
1855 {
1856  return _pSol->surface() * getHauteur();
1857 }
1858 
1859 double TYEtage::surface() const
1860 {
1861  double res = 0.0;
1862 
1863  for (unsigned int i = 0; i < _tabMur.size(); i++)
1864  {
1865  res += TYMur::safeDownCast(_tabMur[i]->getElement())->surface();
1866  }
1867 
1868  res += _pSol->surface();
1869  res += _pPlafond->surface();
1870 
1871  return res;
1872 }
1873 
1875 {
1876  TYTabVector tab;
1877 
1878  for (unsigned int i = 0; i < _tabMur.size(); i++)
1879  {
1880  OVector3D normale = TYMur::safeDownCast(_tabMur[i]->getElement())->normal();
1881  normale = _tabMur[i]->getMatrix() * normale;
1882  tab.push_back(normale);
1883  }
1884 
1885  tab.push_back(_pSol->normal());
1886  tab.push_back(_pPlafond->normal());
1887 
1888  return tab;
1889 }
1890 
1892 {
1893  TYTabPoint tab;
1894  TYPoint pt;
1895 
1896  for (unsigned int i = 0; i < _tabMur.size(); i++)
1897  {
1898  for (int j = 0; j < 4; j++)
1899  {
1900  // Retrieve the vertex
1901  pt = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->_pts[j];
1902 
1903  // We pass in the coordinate system of the 'Etage'
1904  pt = _tabMur[i]->getMatrix() * pt;
1905 
1906  // Add the vertex
1907  tab.push_back(pt);
1908  }
1909  }
1910 
1911  return tab;
1912 }
1913 
1915 {
1916  TYTabLPPolygon tab;
1917 
1918  for (unsigned int i = 0; i < _tabMur.size(); i++)
1919  {
1920  // Polygon representing the face
1921  TYPolygon* pPolygon = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->toPolygon();
1922 
1923  // Convert the polygon into the coordinate system of the 'Etage'
1924  OMatrix matrix = _tabMur[i]->getMatrix();
1925 
1926  pPolygon->transform(matrix);
1927 
1928  // Add the polygon
1929  tab.push_back(pPolygon);
1930  }
1931 
1932  tab.push_back(new TYPolygon(*_pSol->getPolygon()));
1933  tab.push_back(new TYPolygon(*_pPlafond->getPolygon()));
1934 
1935  return tab;
1936 }
1937 
1939 {
1941 }
1942 
1944 {
1945  TYPoint centre(0.0, 0.0, 0.0);
1946 
1947  // Points on the floor
1948  TYTabPoint pts = _pSol->getContour();
1949  size_t nbPts = pts.size();
1950 
1951  // We average in (X,Y) the points on the floor
1952  for (size_t i = 0; i < nbPts; i++)
1953  {
1954  centre._x += pts[i]._x;
1955  centre._y += pts[i]._y;
1956  }
1957 
1958  // Mean
1959  centre._x /= nbPts;
1960  centre._y /= nbPts;
1961 
1962  // The altitude is the mid-height of the 'Etage'
1963  centre._z = getHauteur() / 2.0;
1964 
1965  return centre;
1966 }
1967 
1968 int TYEtage::intersects(const OSegment3D& seg, TYTabPoint& ptList) const
1969 {
1970  return TYVolumeInterface::intersects(seg, ptList);
1971 }
1972 
1973 int TYEtage::isInside(const TYPoint& pt) const
1974 {
1975  int res = INTERS_NULLE;
1976  OPoint3D ptCopy(pt);
1977 
1978  // The test with the englobing volume allow to test if the point is situated between the planes of the
1979  // floor and the ceiling, thus avoiding useless computations
1980  if (_volEnglob.isInside(pt) == INTERS_NULLE)
1981  {
1982  return res;
1983  }
1984 
1985  TYTabPoint ptsSol = _pSol->getContour();
1986  size_t nbPts = ptsSol.size();
1987 
1988  if (_closed && (nbPts >= 3))
1989  {
1990  // Set everything on the floor
1991  ptCopy._z = 0.0;
1992 
1993  // We reduce to a plane (z=0) and test if the point is inside the polygon formed by the 'Etage'
1994  // contour
1995  OPoint3D* pts = new OPoint3D[nbPts];
1996 
1997  for (size_t i = 0; i < nbPts; i++)
1998  {
1999  // Creation of the polygon
2000  pts[i] = ptsSol[i];
2001 
2002  // ... everything on the floor
2003  pts[i]._z = 0.0;
2004  }
2005 
2006  OPoint3D ptMin, ptMax;
2007 
2008  OGeometrie::boundingBox(pts, static_cast<int>(nbPts), ptMin, ptMax);
2009 
2010  OBox box(ptMin, ptMax);
2011 
2012 #if TY_USE_IHM
2013  res = OGeometrie::pointInPolygonRayCasting(ptCopy, pts, static_cast<int>(nbPts));
2014 #else
2015  res = OGeometrie::pointInPolygonAngleSum(ptCopy, pts, nbPts);
2016 #endif
2017 
2018  delete[] pts;
2019  }
2020 
2021  return res;
2022 }
2023 
2024 void TYEtage::setacousticFacesPourCalcul(bool bPourCalculTrajet)
2025 {
2026  _bPourCalculTrajet = bPourCalculTrajet;
2027 }
2028 
2030 {
2032 
2033  // Add the walls 'Murs'
2034  for (unsigned int i = 0; i < _tabMur.size(); i++)
2035  {
2036  // Sub-wall (MurElement) for this wall and its matrix
2038  TYMur::safeDownCast(_tabMur[i]->getElement())->getTabAcousticSurf();
2039  OMatrix matrixMur = _tabMur[i]->getMatrix();
2040 
2041  unsigned int j = 0;
2042 
2043  // For each sub-wall
2044  for (j = 0; j < tabTmp.size(); j++)
2045  {
2046  // The sub-wall
2047  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tabTmp[j]->getElement());
2048 
2049  // If the 'Etage' is an 'Ecran' then take into account thickness of the 'Paroi'
2050  if (!_closed && TYMurElement::safeDownCast(pAccSurf))
2051  {
2052  // For this, build 2 new GeoNodes associated to this same face to represent the thickness
2053  LPTYAcousticSurfaceGeoNode pAccSurfGeoNode1 =
2054  new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf);
2055  LPTYAcousticSurfaceGeoNode pAccSurfGeoNode2 =
2056  new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf);
2057 
2058  // Retrieve the half-thickness of parent 'Mur'
2059  double epaisseur =
2060  TYMur::safeDownCast(_tabMur[i]->getElement())->getParoi()->getEpaisseur() / 2.0;
2061  if (_bPourCalculTrajet)
2062  {
2063  epaisseur = 0; // this way, we get the same number of points than for a real contour, but
2064  // having only the skeleton of the 'Ecran'
2065  }
2066 
2067  // Adding an offset in the z-direction only, as the faces (planes) are defined on the x and y
2068  // axes
2069  ORepere3D rep = tabTmp[j]->getORepere3D();
2070  rep._origin._z = +epaisseur;
2071  pAccSurfGeoNode1->setRepere(rep);
2072  rep._origin._z = -epaisseur;
2073  pAccSurfGeoNode2->setRepere(rep);
2074 
2075  // Concatenation of the matrix
2076  pAccSurfGeoNode1->setMatrix(matrixMur * pAccSurfGeoNode1->getMatrix());
2077  pAccSurfGeoNode2->setMatrix(matrixMur * pAccSurfGeoNode2->getMatrix());
2078 
2079  // Adding the faces
2080  tab.push_back(pAccSurfGeoNode1);
2081  tab.push_back(pAccSurfGeoNode2);
2082  }
2083  // Else simply adding the sub-wall
2084  else
2085  {
2086  // M = M(wall) . M(sub-wall)
2087  OMatrix matrix = matrixMur * tabTmp[j]->getMatrix();
2088 
2089  // Adding
2090  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf, matrix));
2091  }
2092  }
2093  }
2094 
2095  // Adding floor and ceiling if necessary
2096  if (_closed)
2097  {
2098  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement&)_pSol));
2099  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement&)_pPlafond));
2100  }
2101 
2102  return tab;
2103 }
2104 
2105 bool TYEtage::findAcousticSurface(const TYAcousticSurface* pAccSurf, OMatrix* pMatrix /*=0*/)
2106 {
2107  bool ret = false;
2108 
2109  for (unsigned int i = 0; (i < _tabMur.size()) && !ret; i++)
2110  {
2111  // Wall elements for this wall 'Mur'
2112  TYTabAcousticSurfaceGeoNode& tabTmp =
2113  TYMur::safeDownCast(_tabMur[i]._pObj->getElement())->getTabAcousticSurf();
2114 
2115  for (unsigned int j = 0; j < tabTmp.size(); j++)
2116  {
2117  if (TYAcousticSurface::safeDownCast(tabTmp[j]._pObj->getElement()) == pAccSurf)
2118  {
2119  if (pMatrix)
2120  {
2121  // Matrix update
2122  *pMatrix = *pMatrix * _tabMur[i]._pObj->getMatrix() * tabTmp[j]._pObj->getMatrix();
2123  }
2124 
2125  // Surface found
2126  break;
2127  }
2128  }
2129  }
2130 
2131  return ret;
2132 }
2133 
2135 {
2136  OSpectre absoElem;
2137  _absoSabine.setDefaultValue(0.0); // On reinitialise le spectre de Sabine
2138 
2139  size_t i = 0, j = 0;
2140  TYTabAcousticSurfaceGeoNode elemMur; // Elements making up the wall
2141  TYTabAcousticVolumeGeoNode elemMachine; // Elements making up the machine
2142  double surfElem = 0.0; // Elementary surface
2143  _surfAbsorbante = 0.0; // Initialisation of the surface
2144 
2145  _volumeLibre = this->volume(); // Retrieve the volume of the 'Etage'
2146 
2147  // Reading of the absorption of each face of the volume
2148  size_t nbFaces = this->getTabMur().size();
2149 
2150  for (i = 0; i < nbFaces; i++)
2151  {
2152  elemMur = TYMur::safeDownCast(_tabMur[i]->getElement())->getTabAcousticSurf();
2153 
2154  LPTYParoi pMurParoi = TYMur::safeDownCast(_tabMur[i]->getElement())->getParoi();
2155 
2156  for (j = 0; j < elemMur.size(); j++)
2157  {
2158  // A sub-face of a 'Mur' must be of type 'MurElement'
2159  LPTYMurElement pMurElt = TYMurElement::safeDownCast(elemMur[j]->getElement());
2160  assert(pMurElt);
2161 
2162  // Retreive the local features of the wall 'Mur'
2163  surfElem = pMurElt->surface();
2164 
2165  // Absorption of the 'Paroi' associated with the surface
2166  if (pMurElt->getIsSub())
2167  {
2168  // If the surface is a window 'Fenetre', then take its absorption
2169  absoElem = pMurElt->getParoi()->getMatFace1()->getSpectreAbso().mult(surfElem);
2170  }
2171  else
2172  {
2173  // Else take the material mading up the wall
2174  absoElem = pMurParoi->getMatFace1()->getSpectreAbso().mult(surfElem);
2175  }
2176 
2177  // Adding elementary alpha*S and elementary surfaces
2178  _absoSabine = _absoSabine.sum(absoElem);
2179  _surfAbsorbante = _surfAbsorbante + surfElem;
2180  }
2181  }
2182 
2183  // Taking into account floors and ceilings
2184 
2185  // Area occupied on the floor by the machines
2186  double aireTotMachinesSol = 0.0;
2187  for (i = 0; i < _facesMachineSol.size(); i++)
2188  {
2189  aireTotMachinesSol = aireTotMachinesSol +
2190  TYAcousticSurface::safeDownCast(_facesMachineSol[i]->getElement())->surface();
2191  }
2192 
2193  // Surface free floor = total surface of the floor - occupied surface by the machines
2194  surfElem = _pSol->surface() - aireTotMachinesSol;
2195  _surfAbsorbante = _surfAbsorbante + surfElem;
2196 
2197  absoElem = _pSol->getParoi()->getMatFace1()->getSpectreAbso().mult(surfElem);
2198  _absoSabine = _absoSabine.sum(absoElem);
2199 
2200  surfElem = _pPlafond->surface();
2201  _surfAbsorbante = _surfAbsorbante + surfElem;
2202 
2203  absoElem = _pPlafond->getParoi()->getMatFace1()->getSpectreAbso().mult(surfElem);
2204  _absoSabine = _absoSabine.sum(absoElem);
2205 
2206  // Taking into accound the absorption of each of the machines
2207  size_t nbMachines = this->getTabMachine().size();
2208  TYTabAcousticSurfaceGeoNode tabPtrSurf;
2209 
2210  for (i = 0; i < nbMachines; i++)
2211  {
2212  elemMachine = TYMachine::safeDownCast(this->getTabMachine()[i]->getElement())->getTabAcousticVol();
2213 
2214  for (j = 0; j < elemMachine.size(); j++)
2215  {
2216  LPTYAcousticVolume pElemMachine = TYAcousticVolume::safeDownCast(elemMachine[j]->getElement());
2217 
2218  surfElem = pElemMachine->surface();
2219 
2220  // Considering that the volumes of the machine are made up with an homogeneous material
2221  // If we'd wish to pass to one material by face, we should put the two following lines
2222  // into a loop processing each face
2223  absoElem = pElemMachine->getMateriau()->getSpectreAbso().mult(surfElem);
2224 
2225  _absoSabine = _absoSabine.sum(absoElem);
2226  double volElem = pElemMachine->volume();
2227  _surfAbsorbante = _surfAbsorbante + surfElem;
2228  _volumeLibre = _volumeLibre - volElem;
2229  }
2230  }
2231 
2232  // The faces of the machines set on the floor do not contribute to the absorption of the machines
2233  for (i = 0; i < _facesMachineSol.size(); i++)
2234  {
2236 
2237  surfElem = pSurface->surface();
2238  absoElem = pSurface->getMateriau()->getSpectreAbso().mult(surfElem);
2239 
2240  _surfAbsorbante = _surfAbsorbante - surfElem;
2241  _absoSabine = _absoSabine.subst(absoElem);
2242  }
2243 
2244  _absoSabine = _absoSabine.div(_surfAbsorbante); // Computing average alpha of the room
2245  _absoSabine = _absoSabine.sum(1.0E-6); // In case of alpha would be zero, adding epsilon to it
2246 }
2247 
2249 {
2250  _TR = TYSpectre::getEmptyLinSpectre(); // Represent a linear value wich is the time
2251 
2252  // Take into accound the atmospheric aborption
2253 
2254  // S * A
2256 
2257  // 0.16*V/(S * A)
2258  _TR = _TR.invMult(0.16 * _volumeLibre);
2259 
2260  _TR.setType(SPECTRE_TYPE_AUTRE); // unit = seconds
2261  _TR.setEtat(SPECTRE_ETAT_DB); // To avoid an unintended transformation
2262 }
2263 
2265 {
2266  int nbPts = static_cast<int>(_tabMur.size());
2267 
2268  TYTabPoint pointsSol;
2269  TYTabPoint pointsPlafond;
2270 
2271  // for (int i = 0; i < nbPts; i++)
2272  for (int i = nbPts - 1; i >= 0; --i)
2273  {
2274  // Creating the polygon for the floor
2275  TYPoint ptSol = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->_pts[3];
2276  // Passing in the coordinate system of the 'Etage'
2277  ptSol = _tabMur[i]->getMatrix() * ptSol;
2278  // Adding the point
2279  pointsSol.push_back(ptSol);
2280 
2281  // Creating the polygon for the ceiling
2282  TYPoint ptPlafond = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->_pts[0];
2283  // Passing into the coordinate system of the 'Etage'
2284  ptPlafond = _tabMur[i]->getMatrix() * ptPlafond;
2285  // Adding the point
2286  pointsPlafond.push_back(ptPlafond);
2287  }
2288 
2289  // Reversing the points of the floor so that normals face outward
2290  TYTabPoint tabPtsTemp = pointsSol;
2291  pointsSol.clear();
2292  std::vector<TYPoint>::reverse_iterator it;
2293  for (it = tabPtsTemp.rbegin(); it != tabPtsTemp.rend(); it++)
2294  {
2295  pointsSol.push_back((*it));
2296  }
2297 
2298  _pSol->getPolygon()->setPoints(pointsSol);
2299  _pPlafond->getPolygon()->setPoints(pointsPlafond);
2300 
2301  setIsGeometryModified(true);
2302 }
2303 
2305 {
2308  AtmosphericConditions atmos(101325., 20., 70.);
2309 
2310  unsigned int i = 0, j = 0;
2311  double distance = NAN;
2312  OSegment3D SR; // Segment source receptor
2313  TYTabAcousticVolumeGeoNode tabVolumes;
2314  TYTabSourcePonctuelleGeoNode tabSources;
2315  OPoint3D posSource;
2316 
2317  // For all the machines
2318  for (i = 0; i < _tabMachine.size(); i++)
2319  {
2321 
2322  if (pVolNode && pVolNode->getIsRayonnant()) // If not radiating, do not take sources
2323  {
2324  TYTabSourcePonctuelleGeoNode tabSrcNode = pVolNode->getSrcs();
2325 
2326  for (j = 0; j < tabSrcNode.size(); j++)
2327  {
2328  // The source
2329  LPTYSourcePonctuelle pSrc = TYSourcePonctuelle::safeDownCast(tabSrcNode[j]->getElement());
2330 
2331  // Transformation matrix to the source coordinate system
2332  OMatrix matInv = tabSrcNode[j]->getMatrix().getInvert();
2333 
2334  // Point position in the source coorinate system
2335  OPoint3D posPtInSrcRep = matInv * unPoint;
2336 
2337  // Contribution of the source to the point
2338  SR = OSegment3D(posSource, posPtInSrcRep);
2339  distance = SR.longueur();
2340 
2341  // Assigning directivity to the source power
2342  sTemp = OSpectre::getEmptyLinSpectre(1.0); // pSrc->lwApparenteSrcDest(SR, atmos); // Q
2343  sTemp = sTemp.mult(pSrc->getSpectre()->toGPhy()); // W
2344  sTemp =
2345  sTemp.mult(atmos.compute_z() / (4 * M_PI * distance * distance)); // Q.W.rho.C / 4.pi.d²
2346 
2347  // Adding spectra
2348  s = s.sum(sTemp);
2349  }
2350  }
2351  }
2352 
2353  // For all the ponctual sources
2354  for (i = 0; i < _tabSources.size(); i++)
2355  {
2357 
2358  if (pSrc && pSrc->getIsRayonnant())
2359  {
2360  posSource = *pSrc->getPos();
2361  SR = OSegment3D(posSource, unPoint);
2362  distance = SR.longueur();
2363 
2364  // Assigning directivity to the source power
2366  1.); // pSrc->lwApparenteSrcDest(SR, atmos); // Directivity of the source Q
2367  sTemp = sTemp.mult(pSrc->getSpectre()->toGPhy()); // Power W
2368  sTemp = sTemp.mult(atmos.compute_z() / (4 * M_PI * distance * distance)); // Q.W.rho.C/(4.pi.d²)
2369 
2370  // Adding spectra
2371  s = s.sum(sTemp);
2372  }
2373  }
2374 
2375  s.setType(SPECTRE_TYPE_LP);
2376 
2377  return s;
2378 }
2380 {
2381  // We start by computing the average absorption coefficient of the room
2382  coeffSabine();
2383 
2384  // Computing TR
2386 
2387  // Computing the reverberated field
2389 }
2390 
2392 {
2393  unsigned int i = 0, j = 0;
2394  AtmosphericConditions atmos(101325., 20., 70.);
2395 
2396  // Room effect ((4.Rho.C / (alpha.S))-(4/S) - Tr.C.AbsoATm)
2397  _reverb = TYSpectre::getEmptyLinSpectre(4.0); // Spectrum initialised to value 4.0
2398 
2399  _reverb = _reverb.div(_absoSabine.mult(_surfAbsorbante)); // 4/(alpha.S)
2400  _reverb = _reverb.mult(atmos.compute_z()); // 4.Rho.C/(alpha.S)
2401 
2402  // reverberated field : W*(Room effect)
2404 
2405  // Pr = 4W*rho*c/a
2406  TYTabSourcePonctuelleGeoNode tabAllSources;
2407 
2408  // Retrieving all the source
2409  // of the machines
2410  for (i = 0; i < _tabMachine.size(); i++)
2411  {
2413  if (pVolNode && pVolNode->getIsRayonnant())
2414  {
2415  // The sources of this machine
2416  TYTabSourcePonctuelleGeoNode tabSrcMachine =
2417  TYMachine::safeDownCast(_tabMachine[i]->getElement())->getSrcs();
2418  tabAllSources.insert(tabAllSources.end(), tabSrcMachine.begin(), tabSrcMachine.end());
2419  }
2420  }
2421 
2422  for (i = 0; i < _tabSources.size(); i++)
2423  {
2425 
2426  // If it is radiating, we add the ponctual source
2427  if (pSrc && pSrc->getIsRayonnant())
2428  {
2429  tabAllSources.push_back(_tabSources[i]);
2430  }
2431  }
2432 
2433  // For each of these sources
2434  for (j = 0; j < tabAllSources.size(); j++)
2435  {
2436  // Adding spectra of all the sources
2437  sTemp = sTemp.sum(
2438  TYSourcePonctuelle::safeDownCast(tabAllSources[j]->getElement())->getSpectre()->toGPhy());
2439  }
2440 
2441  // Adding spectra
2442  _reverb = _reverb.mult(sTemp); // 4.W.Rho.C / (alpha.S)
2443 
2445 }
2446 
2448 {
2449  TYTabMurGeoNode tabMur = getTabMur();
2450 
2451  for (unsigned int i = 0; i < tabMur.size(); i++)
2452  {
2453  LPTYMur pMur = TYMur::safeDownCast(tabMur[i]->getElement());
2454  TYMur::safeDownCast(_tabMur[i]->getElement())->setParoi(_pParoi);
2455  }
2456 
2459 }
2460 
2462 {
2463  unsigned int i = 0;
2464 
2465  _facesMachineSol.clear();
2466 
2467  // Retrieving all the faces of the machines
2468  TYTabAcousticSurfaceGeoNode accFaces;
2469  for (i = 0; i < _tabMachine.size(); i++)
2470  {
2472  TYMachine::safeDownCast(_tabMachine[i]->getElement())->acousticFaces();
2473  OMatrix matrixMachine = _tabMachine[i]->getMatrix();
2474 
2475  for (unsigned int j = 0; j < tabTmp.size(); j++)
2476  {
2477  // Passing into the coordinate system of this 'Etage'
2478  OMatrix matrix = matrixMachine * tabTmp[j]->getMatrix();
2479  tabTmp[j]->setMatrix(matrix);
2480 
2481  accFaces.push_back(tabTmp[j]);
2482  }
2483  }
2484 
2485  // Searching for the faces of this 'Etage' which are set on the floor
2486  OPlan planSol = _pSol->plan();
2487  double distance = 0.0;
2488 
2489  for (i = 0; i < accFaces.size(); i++)
2490  {
2491  // The face
2492  LPTYAcousticSurfaceGeoNode pFaceGeoNode = accFaces[i];
2493 
2494  // Contour of the face
2495  LPTYAcousticSurface pSurface = TYAcousticSurface::safeDownCast(accFaces[i]->getElement());
2496  TYTabPoint contour = pSurface->getContour();
2497  if (contour.size() < 3)
2498  {
2499  continue;
2500  }
2501 
2502  OMatrix matrixFace = accFaces[i]->getMatrix();
2503 
2504  // A point on the plane of the face in the coordinate system of the 'Etage'
2505  OPoint3D ptPlan = matrixFace * OVector3D(contour[0]);
2506  // The normal to the face in the coordinate system of the 'Etage'
2507  OVector3D vecPlan = OVector3D(matrixFace * OPoint3D(0.0, 0.0, 0.0), matrixFace * pSurface->normal());
2508  vecPlan.normalize();
2509  // The plane of the face in the coordinate system of the 'Etage'
2510  OPlan planFace(ptPlan, vecPlan);
2511 
2512  // Distance betaween 2 floors if they are parallel
2513  if (planFace.distancePlanParallel(planSol, distance))
2514  {
2515  // If the face is set on the floor (with a tolerance)
2516  if (ABS(distance) <= TYSEUILCONFONDUS)
2517  {
2518  // We "deactivate" this face of the machine
2519  pSurface->setDensiteSrcs(0.0);
2520 
2521  // We preserve the faces touching the floor
2522  _facesMachineSol.push_back(accFaces[i]);
2523  }
2524  }
2525  }
2526 }
2527 
2528 bool TYEtage::updateAcoustic(const bool& force) // force=false
2529 {
2530  unsigned int i = 0;
2531  bool ret = true;
2532 
2533  // If not radiating, we do not block the calculation
2534  // (this situation may be intentional, but no acoustic distribution is performed in this case)
2535  if (!_isRayonnant)
2536  {
2537  return true;
2538  }
2539 
2540  // We start by adjusting the height of the sources
2541  updateZSource();
2542 
2543  // updateAcoustic of the machines in the 'Batiment' if any
2544  if ((_tabMachine.size() != 0) || (_tabSources.size() != 0))
2545  {
2547 
2548  // Machines
2549  for (i = 0; i < _tabMachine.size(); i++)
2550  {
2551  ret &= TYMachine::safeDownCast(_tabMachine[i]->getElement())->updateAcoustic();
2552  }
2553  }
2554 
2556  distriSrcs();
2557  ret &= setSrcsLw();
2558 
2559  return ret;
2560 }
2561 
2563 {
2564  // Remove the sources on the walls
2565  for (unsigned int i = 0; i < _tabMur.size(); i++)
2566  {
2567  TYAcousticRectangleNode::safeDownCast(_tabMur[i]->getElement())->remAllSrcs();
2568  }
2569 
2570  // Remove the sources on the floor and ceiling
2571  _pSol->remAllSrcs();
2572  _pPlafond->remAllSrcs();
2573 }
2574 
2576 {
2577  unsigned int i = 0;
2578  double surface = 0.0;
2579 
2580  for (i = 0; i < _tabMur.size(); i++)
2581  {
2582  LPTYMur pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
2583 
2584  surface += pMur->activeSurface();
2585  }
2586 
2587  return surface;
2588 }
2589 
2590 TYSpectre TYEtage::setGlobalLW(const TYSpectre& spectre, const double& surfGlobale, const int& regime /*=-1*/)
2591 {
2592  /* If the 'Etage' is set to "Puissance imposée", we return it; if the 'Etage' is set to "Puissance
2593  * calculée", its power depends on the sources it contains and has been calculated previously by an
2594  * updateAcoustic (this is the opposite of the machines).*/
2595  return getCurrentSpectre().toGPhy(); // Returns the obtained spectrum
2596 }
2597 
2599  const LPTYParoi pMurParoi)
2600 {
2601  TYSpectre spectreEltMur = TYSpectre::getEmptyLinSpectre();
2603  OSpectre spectreAtt;
2604  OPoint3D posSrc;
2605  AtmosphericConditions atmos(101325., 20., 70.);
2606 
2607  // A sub-face of wall must be of type MurElement
2608  LPTYMurElement pMurElt = TYMurElement::safeDownCast(pCurrentSurf);
2609 
2610  if (pMurElt) // Process floor and ceiling case
2611  {
2612  if (pMurElt->getIsSub())
2613  {
2614  // If the 'Paroi' is a window 'Fenetre'
2615  spectreAtt = pMurElt->getParoi()->getMatStruct()->getSpectreTransm();
2616  }
2617  else
2618  {
2619  // Otherwise, it is the 'Paroi' associated with the 'Mur'
2620  spectreAtt = pMurParoi->getMatStruct()->getSpectreTransm();
2621  }
2622  }
2623  else // Case of floor and ceiling
2624  {
2625  // Otherwise, it is the 'Paroi' associated with the 'Mur'
2626  spectreAtt = pMurParoi->getMatStruct()->getSpectreTransm();
2627  }
2628 
2629  TYTabSourcePonctuelleGeoNode tabSources = pCurrentSurf->getSrcs();
2630  double surf = pCurrentSurf->surface() / tabSources.size();
2631 
2632  // For all the ponctual sources of the face
2633  for (unsigned int k = 0; k < tabSources.size(); k++)
2634  {
2635  LPTYSourcePonctuelle pSource = TYSourcePonctuelle::safeDownCast(tabSources[k]->getElement());
2636 
2637  // Position of the source in the coordinate system of the 'Etage'
2638  posSrc = matMur * *(pSource->getPos());
2639 
2640  s = _reverb.div(4.0); // Correction reverberated field (pressure), reverberated intensity.
2641 
2642  s = s.sum(champDirect(posSrc));
2643 
2644  s = s.mult(surf / atmos.compute_z()); // W = P² * S / (rho.C)
2645  // s = s.sum(_reverb);// P² = directField + reverberatedField
2646 
2647  // s = s.div(4.0); // DT 20100106 as the test case transparent 'Paroi' did not match
2648 
2649  s = s.div((spectreAtt).toGPhy()); // See whether the spectrum must be converted in physical value
2650 
2651  spectreEltMur = spectreEltMur.sum(s);
2652  }
2653 
2654  spectreEltMur.setType(SPECTRE_TYPE_LW);
2655  return spectreEltMur;
2656 }
2657 
2658 void TYEtage::setParoi(const LPTYParoi pParoi)
2659 {
2660  assert(pParoi);
2661  assert(_pParoi);
2662 
2663  *_pParoi = *pParoi;
2664 }
2665 
2667 {
2668  unsigned int i = 0;
2669  for (i = 0; i < _tabSources.size(); i++)
2670  {
2672  double h = pSource->getHauteur();
2673  pSource->getPos()->_z = h;
2674  _tabSources[i]->setIsGeometryModified(true);
2675  }
2676 
2677  for (i = 0; i < _tabMachine.size(); i++)
2678  {
2679  double h = _tabMachine[i]->getHauteur();
2680  ORepere3D repere3D = _tabMachine[i]->getORepere3D();
2681  repere3D._origin._z = h;
2682  _tabMachine[i]->setRepere(repere3D);
2683  }
2684 
2685  setIsGeometryModified(true);
2686 }
2687 
2689 {
2690  size_t i = 0;
2691  size_t nbFaces = this->getTabMur().size();
2692 
2693  LPTYMur pMur = NULL;
2694 
2695  // Propagating to the walls 'Murs'
2696  for (i = 0; i < nbFaces; i++)
2697  {
2698  pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
2699 
2700  if (pMur)
2701  {
2702  pMur->propagateAtt(pAtt);
2703  }
2704  }
2705 
2706  // Propagating to the floor and ceiling
2707  _pSol->propagateAtt(pAtt);
2708  _pPlafond->propagateAtt(pAtt);
2709 
2711 }
All base classes related to 3D manipulation.
#define TYSEUILCONFONDUS
Definition: 3d.h:47
double ABS(double a)
Return the absolute value.
Definition: 3d.h:67
#define INTERS_NULLE
No intersection.
Definition: 3d.h:35
NxReal s
Definition: NxVec3.cpp:317
QDomDocument DOM_Document
Definition: QT2DOM.h:33
QDomElement DOM_Element
Definition: QT2DOM.h:30
std::vector< LPTYAcousticFaceSetGeoNode > TYTabAcousticVolumeGeoNode
Collection de noeuds geometriques de type TYAcousticFaceSet.
TYGeometryNode TYAcousticSurfaceGeoNode
Noeud geometrique de type TYAcousticSurface.
std::vector< LPTYAcousticSurfaceGeoNode > TYTabAcousticSurfaceGeoNode
Collection de noeuds geometriques de type TYAcousticSurface.
class OGenID TYUUID
Definition: TYDefines.h:59
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
std::map< TYElement *, bool > TYMapPtrElementBool
Etat d'utilisation des elements (utilise par les calculs)
Definition: TYDefines.h:376
std::vector< OVector3D > TYTabVector
Collection de OVector3D.
Definition: TYDefines.h:398
std::map< TYElement *, int > TYMapPtrElementInt
Tableau associatif des elements et d'un entier (utilise pour gerer les regimes)
Definition: TYDefines.h:379
std::vector< LPTYPolygon > TYTabLPPolygon
Collection de pointeurs de TYPolygon.
Definition: TYDefines.h:349
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:344
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
Representation graphique d'un etage (fichier header)
outil IHM pour un etage (fichier header)
TY_EXTENSION_INST(TYEtage)
TY_EXT_GRAPHIC_INST(TYEtage)
TYGeometryNode TYMachineGeoNode
Noeud geometrique de type TYMachine.
Definition: TYMachine.h:164
std::vector< LPTYMurGeoNode > TYTabMurGeoNode
Collection de noeuds geometriques de type TYMur.
Definition: TYMur.h:167
TYGeometryNode TYMurGeoNode
Noeud geometrique de type TYMur.
Definition: TYMur.h:163
int id
const char * name
TYGeometryNode TYSourcePonctuelleGeoNode
Noeud geometrique de type TYSourcePonctuelle.
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
TYGeometryNode TYUserSourcePonctuelleGeoNode
Noeud geometrique de type TYSourcePonctuelle.
Class for the definition of atmospheric conditions.
double compute_z()
compute impedance
The box class.
Definition: 3d.h:1346
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
static void boundingBox(OPoint3D *pts, int nbPts, OPoint3D &ptMin, OPoint3D &ptMax)
Computes the simple bounding box for a volume using min-max method.
Definition: 3d.cpp:1109
static bool pointInPolygonAngleSum(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using angle sum algorithm.
Definition: 3d.cpp:1016
static bool pointInPolygonRayCasting(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using ray casting algorithm.
Definition: 3d.cpp:1046
The 4x4 matrix class.
Definition: 3d.h:625
OMatrix getInvert(int *ok=0) const
Return the inverse matrix of this matrix.
Definition: 3d.cpp:813
Plan defined by its equation : ax+by+cz+d=0.
Definition: plan.h:31
bool distancePlanParallel(const OPlan &plan, double &distance)
Calculate the distance between this plan and another parallel plane.
Definition: plan.cpp:409
The 3D point class.
Definition: 3d.h:487
virtual const char * getClassName() const
Definition: TYElement.h:248
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
bool isA(const char *className) const
Definition: TYElement.cpp:65
3D frame with a point and 3 vectors.
Definition: 3d.h:1263
OVector3D _vecK
Vector K for the Z axis.
Definition: 3d.h:1337
OVector3D _vecJ
Vector J for the Y axis.
Definition: 3d.h:1335
OVector3D _vecI
Vector I for the X axis.
Definition: 3d.h:1333
OPoint3D _origin
The origin point.
Definition: 3d.h:1331
Class to define a segment.
Definition: 3d.h:1141
virtual double longueur() const
Return the segment length.
Definition: 3d.cpp:1238
OSpectreAbstract & sum(const OSpectreAbstract &spectre) const
Arithmetic sum of two spectrums in one-third Octave.
Definition: spectre.cpp:224
OSpectreAbstract & subst(const OSpectreAbstract &spectre) const
Arithmetic subtraction of two spectrums in one-third Octave.
Definition: spectre.cpp:321
OSpectreAbstract & toGPhy() const
Converts to physical quantity.
Definition: spectre.cpp:641
OSpectreAbstract & invMult(const double &coefficient=1.0) const
Division of a double constant by this spectrum.
Definition: spectre.cpp:350
void setEtat(TYSpectreEtat etat)
Force the spectrum state (to use carefully ...)
Definition: spectre.h:169
void setType(TYSpectreType type)
Set the spectrum type.
Definition: spectre.h:153
OSpectreAbstract & div(const OSpectreAbstract &spectre) const
Division of two spectrums.
Definition: spectre.cpp:278
void setDefaultValue(const double &valeur=TY_SPECTRE_DEFAULT_VALUE)
Definition: spectre.cpp:202
OSpectreAbstract & toDB() const
Converts to dB.
Definition: spectre.cpp:595
OSpectreAbstract & mult(const OSpectreAbstract &spectre) const
Multiplication of two spectrums.
Definition: spectre.cpp:248
static OSpectre getEmptyLinSpectre(const double &valInit=1.0E-20)
Create a physical quantity spectrum.
Definition: spectre.cpp:1129
The 3D vector class.
Definition: 3d.h:298
double norme() const
Computes the length of this vector.
Definition: 3d.cpp:215
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
OVector3D cross(const OVector3D &vector) const
Cross product.
Definition: 3d.cpp:196
Spectrum class.
Definition: Spectre.h:25
double getDensiteSrcsH() const
virtual void setDensiteSrcsH(double densite, bool recursif=true)
virtual void setNextRegimeNb(const int &next)
TYRegime & getRegimeNb(const int &nb, bool &status)
size_t getNbRegimes() const
double getDensiteSrcsV() const
int _curRegime
Numero du regime de fonctionnement courant.
TYSpectre & getCurrentSpectre()
virtual int addRegime(const TYRegime &regime)
TYTabRegimes _tabRegimes
Tableau des regimes de fonctionnement.
virtual void setDensiteSrcsV(double densite, bool recursif=true)
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=false)
virtual void setCurRegime(int regimeNumber)
int _nextRegime
Numero d'ordre du regime suivant.
virtual void setDensiteSrcs(double densite, bool recursif=true)
virtual bool remRegime(int regime)
virtual void setRegimeName(const QString &name)
bool _isRayonnant
Etat courant de l'element (rayonnant ou non rayonnant)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual bool setSrcsLw()
virtual void distriSrcs()
virtual TYTabPoint getContour(int n=-1) const
virtual OPlan plan() const
virtual double surface() const
virtual LPTYPolygon getPolygon()
virtual OVector3D normal() const
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
virtual void setDensiteSrcsV(double densite, bool recursif=true)
virtual void remAllSrcs()
virtual void setCurRegime(int regime)
virtual double surface() const
virtual void propagateAtt(LPTYAttenuateur pAtt)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
LPTYSourceSurfacic getSrcSurf()
virtual void setDensiteSrcsH(double densite, bool recursif=true)
virtual LPTYMateriauConstruction getMateriau() const
virtual bool setSrcsLw()
virtual TYTabPoint getContour(int n=-1) const
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
Get/set de l'etat rayonnant ou pas.
virtual OVector3D normal() const
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual void setCurRegime(int regime)
TYAcousticVolume & operator=(const TYAcousticVolume &other)
Operateur =.
virtual DOM_Element toXML(DOM_Element &domElement)
virtual int fromXML(DOM_Element domElement)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual void propagateAtt(LPTYAttenuateur pAtt)
virtual void setIsAcousticModified(bool isModified)
bool _forceNormales
Persistence du forcage des normales.
virtual void inverseNormales()
Definition: TYBox.h:34
int isInside(const TYPoint &pt) const
Definition: TYBox.cpp:236
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYDalle.cpp:97
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYDalle.cpp:118
LPTYParoi getParoi()
Definition: TYDalle.h:84
void setParoi(const LPTYParoi pParoi)
Definition: TYDalle.cpp:148
QString _name
Nom courant de l'element.
Definition: TYElement.h:956
static bool getRegenerateID()
Definition: TYElement.h:917
static TYUUID fromString(QString id)
Definition: TYElement.cpp:624
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:545
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
virtual std::string toString() const
Definition: TYElement.h:776
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYElement.h:530
static void setRegenerateID(const bool &bRegenerate)
Definition: TYElement.h:913
void setParent(TYElement *pParent)
Definition: TYElement.h:690
static TYElement * getInstance(TYUUID uuid)
Definition: TYElement.cpp:158
virtual void setIsGeometryModified(bool isModified)
Definition: TYElement.cpp:253
virtual int fromXML(DOM_Element domElement)
Definition: TYEtage.cpp:375
virtual std::string toString() const
Definition: TYEtage.cpp:267
virtual ~TYEtage()
Definition: TYEtage.cpp:75
bool _closed
Indique si les murs constituant l'etage sont fermes.
Definition: TYEtage.h:590
void updateParoi()
Definition: TYEtage.cpp:2447
virtual TYTabPoint sommets() const
Definition: TYEtage.cpp:1891
void updateSolPlafond()
Definition: TYEtage.cpp:2264
TYEtage()
Definition: TYEtage.cpp:35
OSpectre _absoSabine
Spectre du coefficient de Sabine de l'etage.
Definition: TYEtage.h:602
bool operator==(const TYEtage &other) const
Definition: TYEtage.cpp:101
virtual void setCurRegime(int regime)
Definition: TYEtage.cpp:1460
virtual double volume() const
Definition: TYEtage.cpp:1854
LPTYDalle _pSol
Dalle pour le sol.
Definition: TYEtage.h:575
virtual void distriSrcs()
Definition: TYEtage.cpp:1669
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYEtage.cpp:150
void setacousticFacesPourCalcul(bool bPourCalculTrajet)
Definition: TYEtage.cpp:2024
virtual TYSourcePonctuelle srcPonctEquiv() const
Definition: TYEtage.cpp:1634
virtual void setNextRegimeNb(const int &next)
Definition: TYEtage.cpp:1567
void calculTempsReverb()
Definition: TYEtage.cpp:2248
virtual void setDensiteSrcsV(double densite, bool recursif=true)
Definition: TYEtage.cpp:1654
LPTYMachineGeoNode findMachine(const LPTYMachine pMachine)
Definition: TYEtage.cpp:1225
void calculChampReverbere()
Definition: TYEtage.cpp:2379
virtual void setDensiteSrcsH(double densite, bool recursif=true)
Definition: TYEtage.cpp:1639
virtual TYPoint centreGravite() const
Definition: TYEtage.cpp:1943
TYTabMachineGeoNode & getTabMachine()
Definition: TYEtage.h:281
virtual int isInside(const TYPoint &pt) const
Definition: TYEtage.cpp:1973
LPTYDalle _pPlafond
Dalle pour le plafond.
Definition: TYEtage.h:578
TYTabPoint getContour() const
Definition: TYEtage.cpp:974
LPTYParoi _pParoi
Paroi par defaut de l'etage.
Definition: TYEtage.h:587
bool remMur(const LPTYMur pMur)
Definition: TYEtage.cpp:841
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
Definition: TYEtage.cpp:1968
bool operator!=(const TYEtage &other) const
Definition: TYEtage.cpp:145
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
Definition: TYEtage.cpp:767
double _surfAbsorbante
Surface d'absorption de la salle (comprend la suface des machines)
Definition: TYEtage.h:596
tabMapPtrElementRegime _tabRegimesMachines
Gestion des regimes des machines.
Definition: TYEtage.h:611
virtual TYTabAcousticSurfaceGeoNode acousticFaces()
Definition: TYEtage.cpp:2029
double _volumeLibre
Volume libre de la salle (volume de la salle vide - volume des machines)
Definition: TYEtage.h:599
virtual bool setSrcsLw()
Definition: TYEtage.cpp:1705
virtual bool findAcousticSurface(const TYAcousticSurface *pAccSurf, OMatrix *pMatrix=0)
Definition: TYEtage.cpp:2105
TYTabMurGeoNode & getTabMur()
Definition: TYEtage.h:143
bool addMur(LPTYMur pMur)
Definition: TYEtage.cpp:824
TYSpectre getPuissanceRayonnee(LPTYAcousticSurface pSurface, const OMatrix matMur, const LPTYParoi pMurParoi)
Definition: TYEtage.cpp:2598
TYTabMurGeoNode _tabMur
Liste des murs.
Definition: TYEtage.h:572
TYTabUserSourcePonctuelleGeoNode _tabSources
Liste des sources ponctuelles.
Definition: TYEtage.h:584
virtual bool remRegime(int regime)
Definition: TYEtage.cpp:1443
TYTabAcousticSurfaceGeoNode _facesMachineSol
Collection des faces des machines collees au sol.
Definition: TYEtage.h:620
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYEtage.cpp:272
TYSpectre _TR
Spectre de TR.
Definition: TYEtage.h:605
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYEtage.cpp:788
virtual TYTabVector normals() const
Definition: TYEtage.cpp:1874
virtual void remAllSrcs()
Definition: TYEtage.cpp:2562
void coeffSabine()
Definition: TYEtage.cpp:2134
double getHauteur() const
Definition: TYEtage.cpp:1041
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=true)
Definition: TYEtage.cpp:1430
OSpectre champDirect(const OPoint3D &unPoint)
Definition: TYEtage.cpp:2304
bool remSource(const LPTYUserSourcePonctuelleGeoNode pSourceGeoNode)
Definition: TYEtage.cpp:1280
bool addSource(LPTYUserSourcePonctuelleGeoNode pSourceGeoNode)
Definition: TYEtage.cpp:1241
virtual double surface() const
Definition: TYEtage.cpp:1859
void setParoi(const LPTYParoi pParoi)
Definition: TYEtage.cpp:2658
TYTabMachineGeoNode _tabMachine
Liste des sources.
Definition: TYEtage.h:581
void verifTabRegimeSources()
Definition: TYEtage.cpp:701
TYEtage & operator=(const TYEtage &other)
Definition: TYEtage.cpp:82
TYSpectre _reverb
Spectre du champ reverbere.
Definition: TYEtage.h:608
virtual void setRegimeName(const QString &name)
Definition: TYEtage.cpp:1580
LPTYUserSourcePonctuelleGeoNode findSource(const LPTYUserSourcePonctuelle pSource)
Definition: TYEtage.cpp:1414
virtual void propagateAtt(LPTYAttenuateur pAtt)
Definition: TYEtage.cpp:2688
void calculChampRevSabine()
spectre de pression acoustique après fonction
Definition: TYEtage.cpp:2391
virtual TYTabLPPolygon faces() const
Definition: TYEtage.cpp:1914
void remAllMachine()
Definition: TYEtage.cpp:1195
bool addMachine(LPTYMachineGeoNode pMachineGeoNode)
Definition: TYEtage.cpp:1053
virtual TYSpectre setGlobalLW(const TYSpectre &spectre, const double &surfGlobale, const int &regime=-1)
Definition: TYEtage.cpp:2590
void updateZSource()
Definition: TYEtage.cpp:2666
virtual bool updateAcoustic(const bool &force=false)
Definition: TYEtage.cpp:2528
void setHauteur(double hauteur)
Definition: TYEtage.cpp:1015
void remAllSources()
Definition: TYEtage.cpp:1383
tabMapPtrElementBool _tabEtatMachines
Gestion des etats des machines.
Definition: TYEtage.h:614
bool remMachine(const LPTYMachineGeoNode pMachineGeoNode)
Definition: TYEtage.cpp:1092
void remMurs()
Definition: TYEtage.cpp:888
bool setMurs(const TYTabPoint &tabPts, double hauteur=2.0, bool close=true)
Definition: TYEtage.cpp:897
virtual TYBox volEnglob() const
Definition: TYEtage.cpp:1938
virtual double activeSurface() const
Definition: TYEtage.cpp:2575
bool _bPourCalculTrajet
Definition: TYEtage.h:618
void findFaceMachineSol()
Definition: TYEtage.cpp:2461
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
Definition: TYEtage.cpp:1598
virtual int addRegime()
Definition: TYEtage.cpp:1545
void setMatrix(const OMatrix &matrix)
TYElement * getElement() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
OMatrix getMatrix() const
void setRepere(const ORepere3D &repere)
Definition: TYMur.h:36
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYParoi.cpp:119
TYMateriauConstruction * getMatStruct()
Definition: TYParoi.h:93
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYParoi.cpp:96
TYMateriauConstruction * getMatFace1()
Definition: TYParoi.h:118
void transform(const OMatrix &matrix)
Definition: TYPolygon.cpp:417
void setPoints(const TYTabPoint &pts)
Definition: TYPolygon.cpp:389
void setRegimeName(const QString &nom)
Definition: TYRegime.h:78
virtual TYSpectre * getSpectre(int regime=-1) const
Definition: TYSource.h:76
static TYSpectre getEmptyLinSpectre(const double &valInit=1.0E-20)
Cree un spectre en lin.
Definition: TYSpectre.cpp:451
virtual TYSpectre * getSpectre(int regime=-1) const
void setCurrentRegime(const int &regimeNumber)
void setIsRayonnant(const bool &rayonnant)
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
virtual TYBox volEnglob() const
void calculRayonSphere(const TYBox &volEnglob)
virtual void calculCentreGravite()
static int getElementAttributeToInt(DOM_Element parentElem, DOMString attName, bool *ok=NULL)
Definition: TYXMLTools.cpp:293
static bool getElementBoolValue(DOM_Element parentElem, DOMString nodeName, bool &nodeValue)
Definition: TYXMLTools.cpp:179
static QString getElementAttributeToString(DOM_Element parentElem, DOMString attName)
Definition: TYXMLTools.cpp:276
static void addElementIntValue(DOM_Element &parentElem, DOMString nodeName, int nodeValue)
Definition: TYXMLTools.cpp:72
static bool getElementIntValue(DOM_Element parentElem, DOMString nodeName, int &nodeValue)
Definition: TYXMLTools.cpp:129
#define M_PI
Pi.
Definition: color.cpp:25
std::string intToStr(int val)
Definition: macros.h:158
@ SPECTRE_ETAT_DB
Definition: spectre.h:45
@ SPECTRE_TYPE_LW
Definition: spectre.h:30
@ SPECTRE_TYPE_LP
Definition: spectre.h:31
@ SPECTRE_TYPE_AUTRE
Definition: spectre.h:32