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  // Set wall center at 1/2 height
1030  _tabMur[i]->getORepere3D()._origin._z = hauteur / 2.0;
1031  }
1032 
1033  updateSolPlafond();
1034  _volEnglob = volEnglob();
1037 }
1038 
1039 double TYEtage::getHauteur() const
1040 {
1041  double res = 0.0;
1042 
1043  if (_tabMur.size() > 0)
1044  {
1045  res = TYMur::safeDownCast(_tabMur[0]->getElement())->getSizeY();
1046  }
1047 
1048  return res;
1049 }
1050 
1052 {
1053  assert(pMachineGeoNode);
1054 
1055  TYMachine* pMachine = TYMachine::safeDownCast(pMachineGeoNode->getElement());
1056 
1057  assert(pMachine);
1058 
1059  pMachineGeoNode->setParent(this);
1060  pMachine->setParent(this);
1061 
1062  _tabMachine.push_back(pMachineGeoNode);
1063 
1064  // For all the 'Regimes' of the 'Etage'
1065  TYElement* pElement = (TYElement*)pMachine;
1066  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1067  {
1068  // Add machine into the associative table of the regime
1069  _tabRegimesMachines[i][pElement] = 0;
1070 
1071  // Set the 'Etat' of the machine active for this regime
1072  _tabEtatMachines[i][pElement] = true;
1073  }
1074 
1075  setIsGeometryModified(true);
1076 
1077  return true;
1078 }
1079 
1080 bool TYEtage::addMachine(LPTYMachine pMachine, const TYRepere& pos)
1081 {
1082  return addMachine(new TYMachineGeoNode(pos, (LPTYElement)pMachine));
1083 }
1084 
1086 {
1087  return addMachine(new TYMachineGeoNode((LPTYElement)pMachine));
1088 }
1089 
1090 bool TYEtage::remMachine(const LPTYMachineGeoNode pMachineGeoNode)
1091 {
1092  assert(pMachineGeoNode);
1093  bool ret = false;
1094  TYTabMachineGeoNode::iterator ite;
1095 
1096  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1097  {
1098  if ((*ite) == pMachineGeoNode)
1099  {
1100  _tabMachine.erase(ite);
1101  ret = true;
1102  break;
1103  }
1104  }
1105 
1106  // For all the regimes of the 'Etage'
1107  TYElement* pElement = pMachineGeoNode->getElement();
1108  TYMapPtrElementInt::iterator iter;
1109  TYMapPtrElementBool::iterator itb;
1110  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1111  {
1112  iter = _tabRegimesMachines[i].find(pElement);
1113  // Delete the machine from the associative table of the regime
1114  _tabRegimesMachines[i].erase(iter);
1115 
1116  itb = _tabEtatMachines[i].find(pElement);
1117  _tabEtatMachines[i].erase(itb);
1118  }
1119 
1120  setIsGeometryModified(true);
1121 
1122  return ret;
1123 }
1124 
1125 bool TYEtage::remMachine(const LPTYMachine pMachine)
1126 {
1127  assert(pMachine);
1128  bool ret = false;
1129  TYTabMachineGeoNode::iterator ite;
1130 
1131  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1132  {
1133  if (TYMachine::safeDownCast((*ite)->getElement()) == pMachine)
1134  {
1135  _tabMachine.erase(ite);
1136  ret = true;
1137  break;
1138  }
1139  }
1140 
1141  // For all the regimes of the 'Etage'
1142  TYElement* pElement = (TYElement*)pMachine;
1143  TYMapPtrElementInt::iterator iter;
1144  TYMapPtrElementBool::iterator itb;
1145  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1146  {
1147  iter = _tabRegimesMachines[i].find(pElement);
1148  // Delete the machine from the associative table of the regime
1149  _tabRegimesMachines[i].erase(iter);
1150 
1151  itb = _tabEtatMachines[i].find(pElement);
1152  _tabEtatMachines[i].erase(itb);
1153  }
1154 
1155  setIsGeometryModified(true);
1156 
1157  return ret;
1158 }
1159 
1160 bool TYEtage::remMachine(QString idMachine)
1161 {
1162  bool ret = false;
1163  TYTabMachineGeoNode::iterator ite;
1164 
1165  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1166  {
1167  if ((*ite)->getElement()->getID().toString() == idMachine)
1168  {
1169  _tabMachine.erase(ite);
1170  ret = true;
1171  break;
1172  }
1173  }
1174 
1175  // For all the regimes of the 'Etage'
1176  TYElement* pElement = (*ite)->getElement();
1177  TYMapPtrElementInt::iterator iter;
1178  TYMapPtrElementBool::iterator itb;
1179  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1180  {
1181  iter = _tabRegimesMachines[i].find(pElement);
1182  // Delete the machine from the associative table of the regime
1183  _tabRegimesMachines[i].erase(iter);
1184 
1185  itb = _tabEtatMachines[i].find(pElement);
1186  _tabEtatMachines[i].erase(itb);
1187  }
1188  setIsGeometryModified(true);
1189 
1190  return ret;
1191 }
1192 
1194 {
1195  unsigned int i = 0, j = 0;
1196 
1197  TYMapPtrElementInt::iterator iter;
1198  for (i = 0; i < _tabRegimesMachines.size(); i++)
1199  {
1200  for (j = 0; j < _tabMachine.size(); j++)
1201  {
1202  TYElement* pElement = _tabMachine[j]->getElement();
1203  iter = _tabRegimesMachines[i].find(pElement);
1204  _tabRegimesMachines[i].erase(iter);
1205  }
1206  }
1207 
1208  TYMapPtrElementBool::iterator itb;
1209  for (i = 0; i < _tabEtatMachines.size(); i++)
1210  {
1211  for (j = 0; j < _tabMachine.size(); j++)
1212  {
1213  TYElement* pElement = _tabMachine[j]->getElement();
1214  itb = _tabEtatMachines[i].find(pElement);
1215  _tabEtatMachines[i].erase(itb);
1216  }
1217  }
1218 
1219  _tabMachine.clear();
1220  setIsGeometryModified(true);
1221 }
1222 
1224 {
1225  assert(pMachine);
1226  TYTabMachineGeoNode::iterator ite;
1227 
1228  for (ite = _tabMachine.begin(); ite != _tabMachine.end(); ite++)
1229  {
1230  if (TYMachine::safeDownCast((*ite)->getElement()) == pMachine)
1231  {
1232  return (*ite);
1233  }
1234  }
1235 
1236  return NULL;
1237 }
1238 
1240 {
1241  assert(pSourceGeoNode);
1242  assert(pSourceGeoNode->getElement());
1243 
1244  if (this->isA("TYAcousticCylinder"))
1245  {
1246  return false;
1247  }
1248 
1249  pSourceGeoNode->setParent(this);
1250  pSourceGeoNode->getElement()->setParent(this);
1251 
1252  _tabSources.push_back(pSourceGeoNode);
1253 
1254  // For all the regimes of the 'Etage'
1255  TYElement* pElement = pSourceGeoNode->getElement();
1256  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1257  {
1258  // Add the machine into the associative table of the regime
1259  _tabRegimesMachines[i][pElement] = 0;
1260  // Set the 'Etat' of the machine active for this regime
1261  _tabEtatMachines[i][pElement] = true;
1262  }
1263  setIsGeometryModified(true);
1264 
1265  return true;
1266 }
1267 
1269 {
1270  return addSource(new TYUserSourcePonctuelleGeoNode(pos, (LPTYElement)pSource));
1271 }
1272 
1274 {
1275  return addSource(new TYUserSourcePonctuelleGeoNode((LPTYElement)pSource));
1276 }
1277 
1279 {
1280  assert(pSourceGeoNode);
1281 
1282  bool ret = false;
1283  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1284 
1285  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1286  {
1287  if ((*ite) == pSourceGeoNode)
1288  {
1289  _tabSources.erase(ite);
1290  ret = true;
1291  break;
1292  }
1293  }
1294 
1295  // For all the regimes of the 'Etage'
1296  TYElement* pElement = (*ite)->getElement();
1297  TYMapPtrElementInt::iterator iter;
1298  TYMapPtrElementBool::iterator itb;
1299  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1300  {
1301  iter = _tabRegimesMachines[i].find(pElement);
1302  // Delete the machine from the associative table of the regime
1303  _tabRegimesMachines[i].erase(iter);
1304 
1305  itb = _tabEtatMachines[i].find(pElement);
1306  _tabEtatMachines[i].erase(itb);
1307  }
1308  setIsGeometryModified(true);
1309 
1310  return ret;
1311 }
1312 
1314 {
1315  assert(pSource);
1316  bool ret = false;
1317  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1318 
1319  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1320  {
1321  if (TYUserSourcePonctuelle::safeDownCast((*ite)->getElement()) == pSource)
1322  {
1323  _tabSources.erase(ite);
1324  ret = true;
1325  break;
1326  }
1327  }
1328 
1329  // For all the regimes of the 'Etage'
1330  TYElement* pElement = (TYElement*)pSource;
1331  TYMapPtrElementInt::iterator iter;
1332  TYMapPtrElementBool::iterator itb;
1333  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1334  {
1335  iter = _tabRegimesMachines[i].find(pElement);
1336  // Delete the machine from the associative table of the regime
1337  _tabRegimesMachines[i].erase(iter);
1338 
1339  itb = _tabEtatMachines[i].find(pElement);
1340  _tabEtatMachines[i].erase(itb);
1341  }
1342 
1343  setIsGeometryModified(true);
1344 
1345  return ret;
1346 }
1347 
1348 bool TYEtage::remSource(QString idSource)
1349 {
1350  bool ret = false;
1351  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1352 
1353  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1354  {
1355  if (TYUserSourcePonctuelle::safeDownCast((*ite)->getElement())->getID().toString() == idSource)
1356  {
1357  _tabSources.erase(ite);
1358  ret = true;
1359  break;
1360  }
1361  }
1362 
1363  TYElement* pElement = (*ite)->getElement();
1364  TYMapPtrElementInt::iterator iter;
1365  TYMapPtrElementBool::iterator itb;
1366  for (unsigned int i = 0; i < _tabRegimes.size(); i++)
1367  {
1368  iter = _tabRegimesMachines[i].find(pElement);
1369  // Delete the source from the associative table of the regime
1370  _tabRegimesMachines[i].erase(iter);
1371 
1372  itb = _tabEtatMachines[i].find(pElement);
1373  _tabEtatMachines[i].erase(itb);
1374  }
1375 
1376  setIsGeometryModified(true);
1377 
1378  return ret;
1379 }
1380 
1382 {
1383  unsigned int i = 0, j = 0;
1384 
1385  TYMapPtrElementInt::iterator iter;
1386  for (i = 0; i < _tabRegimesMachines.size(); i++)
1387  {
1388  for (j = 0; j < _tabSources.size(); j++)
1389  {
1390  TYElement* pElement = _tabSources[j]->getElement();
1391  iter = _tabRegimesMachines[i].find(pElement);
1392  _tabRegimesMachines[i].erase(iter);
1393  }
1394  }
1395 
1396  TYMapPtrElementBool::iterator itb;
1397  for (i = 0; i < _tabEtatMachines.size(); i++)
1398  {
1399  for (j = 0; j < _tabSources.size(); j++)
1400  {
1401  TYElement* pElement = _tabSources[j]->getElement();
1402  itb = _tabEtatMachines[i].find(pElement);
1403  _tabEtatMachines[i].erase(itb);
1404  }
1405  }
1406 
1407  _tabSources.clear();
1408 
1409  setIsGeometryModified(true);
1410 }
1411 
1413 {
1414  assert(pSource);
1415  TYTabUserSourcePonctuelleGeoNode::iterator ite;
1416 
1417  for (ite = _tabSources.begin(); ite != _tabSources.end(); ite++)
1418  {
1419  if (TYUserSourcePonctuelle::safeDownCast((*ite)->getElement()) == pSource)
1420  {
1421  return (*ite);
1422  }
1423  }
1424 
1425  return NULL;
1426 }
1427 
1428 void TYEtage::setRegime(TYSpectre& Spectre, int regime /*=-1*/, bool recursif /*=true*/)
1429 {
1430  if (recursif)
1431  {
1432  for (unsigned int i = 0; i < _tabMur.size(); i++)
1433  {
1434  TYMur::safeDownCast(_tabMur[i]->getElement())->setRegime(Spectre, regime, recursif);
1435  }
1436  }
1437 
1438  TYAcousticVolume::setRegime(Spectre, regime, recursif);
1439 }
1440 
1441 bool TYEtage::remRegime(int regime)
1442 {
1443  for (unsigned int i = 0; i < _tabMur.size(); i++)
1444  {
1445  TYMur::safeDownCast(_tabMur[i]->getElement())->remRegime(regime);
1446  }
1447 
1448  _pSol->remRegime(regime);
1449  _pPlafond->remRegime(regime);
1450 
1451  // Delete the associative table 'Regime' / 'Regime Machine'
1452  _tabRegimesMachines.erase(_tabRegimesMachines.begin() + regime);
1453  _tabEtatMachines.erase(_tabEtatMachines.begin() + regime);
1454 
1455  return TYAcousticVolume::remRegime(regime);
1456 }
1457 
1458 void TYEtage::setCurRegime(int regime)
1459 {
1460  if (regime >= (int)_tabRegimesMachines.size())
1461  {
1462  return;
1463  }
1464  if (regime < 0)
1465  {
1466  regime = (int)_tabRegimes.size() - 1;
1467  }
1468 
1469  for (unsigned int i = 0; i < _tabMur.size(); i++)
1470  {
1471  TYMur::safeDownCast(_tabMur[i]->getElement())->setCurRegime(regime);
1472  }
1473 
1474  _pSol->setCurRegime(regime);
1475  _pPlafond->setCurRegime(regime);
1476 
1477  // Set the machines to the corresponding regime
1478  TYMapPtrElementInt::iterator iter;
1479  for (iter = _tabRegimesMachines[regime].begin(); iter != _tabRegimesMachines[regime].end(); iter++)
1480  {
1481  TYElement* pElement = (*iter).first;
1482  if (pElement->isA("TYMachine"))
1483  {
1484  LPTYMachine pMachine = TYMachine::safeDownCast(pElement);
1485  assert(pMachine);
1486  pMachine->setCurRegime((*iter).second);
1487  }
1488  else
1489  {
1491  assert(pSource);
1492  pSource->setCurrentRegime((*iter).second);
1493  }
1494  }
1495 
1496  // Set the machines in the corresponding 'Etat' ('rayonnant' / ' non rayonnant')
1497  TYMapPtrElementBool::iterator iter2;
1498  for (iter2 = _tabEtatMachines[regime].begin(); iter2 != _tabEtatMachines[regime].end(); iter2++)
1499  {
1500  TYElement* pElement = (*iter2).first;
1501  if (pElement->isA("TYMachine"))
1502  {
1503  LPTYMachine pMachine = TYMachine::safeDownCast(pElement);
1504  assert(pMachine);
1505  bool etat = (*iter2).second;
1506  pMachine->setIsRayonnant(etat);
1507  }
1508  else
1509  {
1511  assert(pSource);
1512  pSource->setIsRayonnant((*iter2).second);
1513  }
1514  }
1515 
1517 
1518  setIsAcousticModified(true);
1519 }
1520 
1522 {
1523  int value = TYAcousticInterface::addRegime(regime);
1524 
1525  TYMapPtrElementInt mapElmRegime = _tabRegimesMachines[0];
1526  _tabRegimesMachines.push_back(mapElmRegime);
1527 
1528  TYMapPtrElementBool mapElmBool = _tabEtatMachines[0];
1529  _tabEtatMachines.push_back(mapElmBool);
1530 
1531  // Creation of the new 'Regime' for all walls, as well as the floor and ceiling
1532  for (unsigned int i = 0; i < _tabMur.size(); i++)
1533  {
1534  TYMur::safeDownCast(_tabMur[i]->getElement())->addRegime();
1535  }
1536 
1537  _pSol->addRegime();
1538  _pPlafond->addRegime();
1539 
1540  return value;
1541 }
1542 
1544 {
1545  int value = TYAcousticInterface::addRegime();
1546 
1547  TYMapPtrElementInt mapElmRegime = _tabRegimesMachines[0];
1548  _tabRegimesMachines.push_back(mapElmRegime);
1549 
1550  TYMapPtrElementBool mapElmBool = _tabEtatMachines[0];
1551  _tabEtatMachines.push_back(mapElmBool);
1552 
1553  // Creation of the new 'Regime' for all walls, as well as the floor and ceiling
1554  for (unsigned int i = 0; i < _tabMur.size(); i++)
1555  {
1556  TYMur::safeDownCast(_tabMur[i]->getElement())->addRegime();
1557  }
1558 
1559  _pSol->addRegime();
1560  _pPlafond->addRegime();
1561 
1562  return value;
1563 }
1564 
1565 void TYEtage::setNextRegimeNb(const int& next)
1566 {
1567  _nextRegime = next;
1568 
1569  for (unsigned int i = 0; i < _tabMur.size(); i++)
1570  {
1571  TYMur::safeDownCast(_tabMur[i]->getElement())->setNextRegimeNb(next);
1572  }
1573 
1574  _pSol->setNextRegimeNb(next);
1575  _pPlafond->setNextRegimeNb(next);
1576 }
1577 
1578 void TYEtage::setRegimeName(const QString& name)
1579 {
1580  bool status = true;
1581  TYRegime& reg = getRegimeNb(_curRegime, status);
1582  if (status)
1583  {
1584  reg.setRegimeName(name);
1585  }
1586 
1587  for (unsigned int i = 0; i < _tabMur.size(); i++)
1588  {
1589  TYMur::safeDownCast(_tabMur[i]->getElement())->setRegimeName(name);
1590  }
1591 
1594 }
1595 
1597 {
1600 
1601  // We retrieve only the sources of the walls
1602  // The 'Etage' is considered as any acoustic volume
1603  for (unsigned int i = 0; i < _tabMur.size(); i++)
1604  {
1605  LPTYMur pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
1606  // Retreive all the sources of the child ...
1607  if (pMur->getIsRayonnant())
1608  {
1609  tabChild = pMur->getSrcs();
1610 
1611  // Matrix concatenation
1612  OMatrix matrix = _tabMur[i]->getMatrix();
1613  for (unsigned int j = 0; j < tabChild.size(); j++)
1614  {
1615  tabChild[j]->setMatrix(matrix * tabChild[j]->getMatrix());
1616  }
1617 
1618  //...and add into the table to be returned
1619  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
1620  }
1621  }
1622 
1623  tabChild = _pSol->getSrcs();
1624  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
1625 
1626  tabChild = _pPlafond->getSrcs();
1627  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
1628 
1629  return tab;
1630 }
1631 
1633 {
1634  return TYSourcePonctuelle();
1635 }
1636 
1637 void TYEtage::setDensiteSrcsH(double densite, bool recursif)
1638 {
1640 
1641  if (recursif)
1642  {
1643  for (unsigned int i = 0; i < _tabMur.size(); i++)
1644  {
1645  TYMur::safeDownCast(_tabMur[i]->getElement())->setDensiteSrcsH(getDensiteSrcsH());
1646  }
1647  // Floor is inactive
1649  }
1650 }
1651 
1652 void TYEtage::setDensiteSrcsV(double densite, bool recursif)
1653 {
1655 
1656  if (recursif)
1657  {
1658  for (unsigned int i = 0; i < _tabMur.size(); i++)
1659  {
1660  TYMur::safeDownCast(_tabMur[i]->getElement())->setDensiteSrcsV(getDensiteSrcsV());
1661  }
1662  // Floor is inactive
1664  }
1665 }
1666 
1668 {
1669  unsigned int i = 0;
1670 
1671  // First remove the present sources
1672  for (i = 0; i < _tabMur.size(); i++)
1673  {
1674  TYMur::safeDownCast(_tabMur[i]->getElement())->remAllSrcs();
1675  }
1676 
1677  _pSol->getSrcSurf()->remAllSrc();
1679 
1680  // Walls
1681  for (i = 0; i < _tabMur.size(); i++)
1682  {
1683  LPTYMur pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
1684  if (pMur->getIsRayonnant())
1685  {
1686  pMur->distriSrcs();
1687  }
1688  }
1689 
1690  // Floor
1691  if (_pSol->getIsRayonnant())
1692  {
1693  _pSol->distriSrcs();
1694  }
1695 
1696  // Ceiling
1697  if (_pPlafond->getIsRayonnant())
1698  {
1699  _pPlafond->distriSrcs();
1700  }
1701 }
1702 
1704 {
1705  bool ret = true;
1706 
1708  LWEtage.setType(SPECTRE_TYPE_LW);
1709 
1712 
1713  // FIRST HANDLE THE WALLS
1714 
1715  // For all the walls
1716  for (unsigned int i = 0; i < _tabMur.size(); i++)
1717  {
1718  // Wall matrix
1719  OMatrix matMur = _tabMur[i]->getMatrix();
1720 
1721  // Current wall
1722  LPTYMur pCurrentMur = TYMur::safeDownCast(_tabMur[i]->getElement());
1724 
1725  // If the wall is radiating, wa compute its power
1726  if (pCurrentMur->getIsRayonnant())
1727  {
1728  // Power spectrum affected to the wall
1729  double surfMur = pCurrentMur->activeSurface();
1730 
1731  // If "Puissance calculée", then the power of the wall is set to 0
1732  if (pCurrentMur->getTypeDistribution() == TY_PUISSANCE_IMPOSEE)
1733  {
1734  LWMur = pCurrentMur->getCurrentSpectre().toGPhy();
1735  }
1736 
1737  LWMur.setType(SPECTRE_TYPE_LW);
1738 
1739  // For all the faces of the wall
1740  TYTabAcousticSurfaceGeoNode tabAcousticSurf = pCurrentMur->getTabAcousticSurf();
1741 
1742  LPTYParoi pMurParoi = TYMur::safeDownCast(_tabMur[i]->getElement())->getParoi();
1743 
1744  // For all the surfaces making up the wall
1745  for (unsigned int j = 0; j < tabAcousticSurf.size(); j++)
1746  {
1747  LPTYAcousticSurfaceGeoNode pSurfaceNode = tabAcousticSurf[j];
1748  OMatrix matSurf = matMur * pSurfaceNode->getMatrix();
1749 
1750  LPTYAcousticSurface pCurrentSurf =
1752  assert(pCurrentSurf);
1753 
1754  if (pCurrentSurf->getIsSub() == true)
1755  {
1756  if (pCurrentSurf->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1757  {
1758  LWElt = getPuissanceRayonnee(pCurrentSurf, matSurf, pMurParoi);
1759  LWEtage = LWEtage.sum(LWElt);
1760  }
1761  else
1762  {
1763  LWEtage = LWEtage.sum(pCurrentSurf->getCurrentSpectre().toGPhy());
1764  }
1765  }
1766  else
1767  {
1768  if (pCurrentMur->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1769  {
1770  LWElt = getPuissanceRayonnee(pCurrentSurf, matSurf, pMurParoi);
1771  LWMur = LWMur.sum(LWElt);
1772  }
1773  else
1774  {
1775  double surfElt = pCurrentSurf->surface();
1776  LWElt = LWMur.mult(surfElt / surfMur);
1777  }
1778  }
1779 
1780  // FIX ANOMALY 28 - test of the power assignment type ('calculée' / 'imposée' ou
1781  // 'mesurée')
1782  if (pCurrentSurf->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1783  {
1784  TYSpectre aSpectre(LWElt.toDB());
1785  pCurrentSurf->setRegime(aSpectre, -1, false);
1786  }
1787 
1788  ret &= pCurrentSurf->setSrcsLw();
1789  }
1790 
1791  // FIX ANOMALY 28 - test of the power assignment type ('calculée' / 'imposée' ou
1792  // 'mesurée')
1793  if (pCurrentMur->getTypeDistribution() == TY_PUISSANCE_CALCULEE)
1794  {
1795  TYSpectre aSpectre(LWMur.toDB());
1796  pCurrentMur->setRegime(aSpectre, -1, false);
1797  }
1798  }
1799  else // The wall is not radiating, so it is assigned a zero power
1800  {
1801  LWMur.setType(SPECTRE_TYPE_LW);
1802  }
1803 
1804  LWEtage = LWEtage.sum(LWMur);
1805  }
1806 
1807  // HANDLE THE 'DALLES'
1808  if (_closed) // If it is a 'Batiment' and not a simple 'Ecran'
1809  {
1810  OMatrix matDalle;
1811  if (_pSol->getIsRayonnant())
1812  {
1814  {
1815  LPTYParoi pSolParoi = _pSol->getParoi();
1816  LWElt = getPuissanceRayonnee(_pSol, matDalle, pSolParoi);
1817  TYSpectre aTYSpectre(LWElt.toDB());
1818  _pSol->setRegime(aTYSpectre, -1, false);
1819  LWEtage = LWEtage.sum(LWElt);
1820  }
1821  else
1822  {
1823  LWEtage = LWEtage.sum(_pSol->getCurrentSpectre().toGPhy());
1824  }
1825 
1826  _pSol->setSrcsLw();
1827  }
1828 
1829  if (_pPlafond->getIsRayonnant())
1830  {
1832  {
1833  LPTYParoi pPlafondParoi = _pPlafond->getParoi();
1834  LWElt = getPuissanceRayonnee(_pPlafond, matDalle, pPlafondParoi);
1835  TYSpectre aTYSpectre(LWElt.toDB());
1836  _pPlafond->setRegime(aTYSpectre, -1, false);
1837  LWEtage = LWEtage.sum(LWElt);
1838  }
1839  else
1840  {
1841  LWEtage = LWEtage.sum(_pPlafond->getCurrentSpectre().toGPhy());
1842  }
1843 
1844  _pPlafond->setSrcsLw();
1845  }
1846  }
1847  TYSpectre aTYSpectre(LWEtage.toDB());
1848  this->setRegime(aTYSpectre, -1, false);
1849  return ret;
1850 }
1851 
1852 double TYEtage::volume() const
1853 {
1854  return _pSol->surface() * getHauteur();
1855 }
1856 
1857 double TYEtage::surface() const
1858 {
1859  double res = 0.0;
1860 
1861  for (unsigned int i = 0; i < _tabMur.size(); i++)
1862  {
1863  res += TYMur::safeDownCast(_tabMur[i]->getElement())->surface();
1864  }
1865 
1866  res += _pSol->surface();
1867  res += _pPlafond->surface();
1868 
1869  return res;
1870 }
1871 
1873 {
1874  TYTabVector tab;
1875 
1876  for (unsigned int i = 0; i < _tabMur.size(); i++)
1877  {
1878  OVector3D normale = TYMur::safeDownCast(_tabMur[i]->getElement())->normal();
1879  normale = _tabMur[i]->getMatrix() * normale;
1880  tab.push_back(normale);
1881  }
1882 
1883  tab.push_back(_pSol->normal());
1884  tab.push_back(_pPlafond->normal());
1885 
1886  return tab;
1887 }
1888 
1890 {
1891  TYTabPoint tab;
1892  TYPoint pt;
1893 
1894  for (unsigned int i = 0; i < _tabMur.size(); i++)
1895  {
1896  for (int j = 0; j < 4; j++)
1897  {
1898  // Retrieve the vertex
1899  pt = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->_pts[j];
1900 
1901  // We pass in the coordinate system of the 'Etage'
1902  pt = _tabMur[i]->getMatrix() * pt;
1903 
1904  // Add the vertex
1905  tab.push_back(pt);
1906  }
1907  }
1908 
1909  return tab;
1910 }
1911 
1913 {
1914  TYTabLPPolygon tab;
1915 
1916  for (unsigned int i = 0; i < _tabMur.size(); i++)
1917  {
1918  // Polygon representing the face
1919  TYPolygon* pPolygon = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->toPolygon();
1920 
1921  // Convert the polygon into the coordinate system of the 'Etage'
1922  OMatrix matrix = _tabMur[i]->getMatrix();
1923 
1924  pPolygon->transform(matrix);
1925 
1926  // Add the polygon
1927  tab.push_back(pPolygon);
1928  }
1929 
1930  tab.push_back(new TYPolygon(*_pSol->getPolygon()));
1931  tab.push_back(new TYPolygon(*_pPlafond->getPolygon()));
1932 
1933  return tab;
1934 }
1935 
1937 {
1939 }
1940 
1942 {
1943  TYPoint centre(0.0, 0.0, 0.0);
1944 
1945  // Points on the floor
1946  TYTabPoint pts = _pSol->getContour();
1947  size_t nbPts = pts.size();
1948 
1949  // We average in (X,Y) the points on the floor
1950  for (size_t i = 0; i < nbPts; i++)
1951  {
1952  centre._x += pts[i]._x;
1953  centre._y += pts[i]._y;
1954  }
1955 
1956  // Mean
1957  centre._x /= nbPts;
1958  centre._y /= nbPts;
1959 
1960  // The altitude is the mid-height of the 'Etage'
1961  centre._z = getHauteur() / 2.0;
1962 
1963  return centre;
1964 }
1965 
1966 int TYEtage::intersects(const OSegment3D& seg, TYTabPoint& ptList) const
1967 {
1968  return TYVolumeInterface::intersects(seg, ptList);
1969 }
1970 
1971 int TYEtage::isInside(const TYPoint& pt) const
1972 {
1973  int res = INTERS_NULLE;
1974  OPoint3D ptCopy(pt);
1975 
1976  // The test with the englobing volume allow to test if the point is situated between the planes of the
1977  // floor and the ceiling, thus avoiding useless computations
1978  if (_volEnglob.isInside(pt) == INTERS_NULLE)
1979  {
1980  return res;
1981  }
1982 
1983  TYTabPoint ptsSol = _pSol->getContour();
1984  size_t nbPts = ptsSol.size();
1985 
1986  if (_closed && (nbPts >= 3))
1987  {
1988  // Set everything on the floor
1989  ptCopy._z = 0.0;
1990 
1991  // We reduce to a plane (z=0) and test if the point is inside the polygon formed by the 'Etage'
1992  // contour
1993  OPoint3D* pts = new OPoint3D[nbPts];
1994 
1995  for (size_t i = 0; i < nbPts; i++)
1996  {
1997  // Creation of the polygon
1998  pts[i] = ptsSol[i];
1999 
2000  // ... everything on the floor
2001  pts[i]._z = 0.0;
2002  }
2003 
2004  OPoint3D ptMin, ptMax;
2005 
2006  OGeometrie::boundingBox(pts, static_cast<int>(nbPts), ptMin, ptMax);
2007 
2008  OBox box(ptMin, ptMax);
2009 
2010 #if TY_USE_IHM
2011  res = OGeometrie::pointInPolygonRayCasting(ptCopy, pts, static_cast<int>(nbPts));
2012 #else
2013  res = OGeometrie::pointInPolygonAngleSum(ptCopy, pts, nbPts);
2014 #endif
2015 
2016  delete[] pts;
2017  }
2018 
2019  return res;
2020 }
2021 
2022 void TYEtage::setacousticFacesPourCalcul(bool bPourCalculTrajet)
2023 {
2024  _bPourCalculTrajet = bPourCalculTrajet;
2025 }
2026 
2028 {
2030 
2031  // Add the walls 'Murs'
2032  for (unsigned int i = 0; i < _tabMur.size(); i++)
2033  {
2034  // Sub-wall (MurElement) for this wall and its matrix
2036  TYMur::safeDownCast(_tabMur[i]->getElement())->getTabAcousticSurf();
2037  OMatrix matrixMur = _tabMur[i]->getMatrix();
2038 
2039  unsigned int j = 0;
2040 
2041  // For each sub-wall
2042  for (j = 0; j < tabTmp.size(); j++)
2043  {
2044  // The sub-wall
2045  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tabTmp[j]->getElement());
2046 
2047  // If the 'Etage' is an 'Ecran' then take into account thickness of the 'Paroi'
2048  if (!_closed && TYMurElement::safeDownCast(pAccSurf))
2049  {
2050  // For this, build 2 new GeoNodes associated to this same face to represent the thickness
2051  LPTYAcousticSurfaceGeoNode pAccSurfGeoNode1 =
2052  new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf);
2053  LPTYAcousticSurfaceGeoNode pAccSurfGeoNode2 =
2054  new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf);
2055 
2056  // Retrieve the half-thickness of parent 'Mur'
2057  double epaisseur =
2058  TYMur::safeDownCast(_tabMur[i]->getElement())->getParoi()->getEpaisseur() / 2.0;
2059  if (_bPourCalculTrajet)
2060  {
2061  epaisseur = 0; // this way, we get the same number of points than for a real contour, but
2062  // having only the skeleton of the 'Ecran'
2063  }
2064 
2065  // Adding an offset in the z-direction only, as the faces (planes) are defined on the x and y
2066  // axes
2067  ORepere3D rep = tabTmp[j]->getORepere3D();
2068  rep._origin._z = +epaisseur;
2069  pAccSurfGeoNode1->setRepere(rep);
2070  rep._origin._z = -epaisseur;
2071  pAccSurfGeoNode2->setRepere(rep);
2072 
2073  // Concatenation of the matrix
2074  pAccSurfGeoNode1->setMatrix(matrixMur * pAccSurfGeoNode1->getMatrix());
2075  pAccSurfGeoNode2->setMatrix(matrixMur * pAccSurfGeoNode2->getMatrix());
2076 
2077  // Adding the faces
2078  tab.push_back(pAccSurfGeoNode1);
2079  tab.push_back(pAccSurfGeoNode2);
2080  }
2081  // Else simply adding the sub-wall
2082  else
2083  {
2084  // M = M(wall) . M(sub-wall)
2085  OMatrix matrix = matrixMur * tabTmp[j]->getMatrix();
2086 
2087  // Adding
2088  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf, matrix));
2089  }
2090  }
2091  }
2092 
2093  // Adding floor and ceiling if necessary
2094  if (_closed)
2095  {
2096  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement&)_pSol));
2097  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement&)_pPlafond));
2098  }
2099 
2100  return tab;
2101 }
2102 
2103 bool TYEtage::findAcousticSurface(const TYAcousticSurface* pAccSurf, OMatrix* pMatrix /*=0*/)
2104 {
2105  bool ret = false;
2106 
2107  for (unsigned int i = 0; (i < _tabMur.size()) && !ret; i++)
2108  {
2109  // Wall elements for this wall 'Mur'
2110  TYTabAcousticSurfaceGeoNode& tabTmp =
2111  TYMur::safeDownCast(_tabMur[i]._pObj->getElement())->getTabAcousticSurf();
2112 
2113  for (unsigned int j = 0; j < tabTmp.size(); j++)
2114  {
2115  if (TYAcousticSurface::safeDownCast(tabTmp[j]._pObj->getElement()) == pAccSurf)
2116  {
2117  if (pMatrix)
2118  {
2119  // Matrix update
2120  *pMatrix = *pMatrix * _tabMur[i]._pObj->getMatrix() * tabTmp[j]._pObj->getMatrix();
2121  }
2122 
2123  // Surface found
2124  break;
2125  }
2126  }
2127  }
2128 
2129  return ret;
2130 }
2131 
2133 {
2134  OSpectre absoElem;
2135  _absoSabine.setDefaultValue(0.0); // On reinitialise le spectre de Sabine
2136 
2137  size_t i = 0, j = 0;
2138  TYTabAcousticSurfaceGeoNode elemMur; // Elements making up the wall
2139  TYTabAcousticVolumeGeoNode elemMachine; // Elements making up the machine
2140  double surfElem = 0.0; // Elementary surface
2141  _surfAbsorbante = 0.0; // Initialisation of the surface
2142 
2143  _volumeLibre = this->volume(); // Retrieve the volume of the 'Etage'
2144 
2145  // Reading of the absorption of each face of the volume
2146  size_t nbFaces = this->getTabMur().size();
2147 
2148  for (i = 0; i < nbFaces; i++)
2149  {
2150  elemMur = TYMur::safeDownCast(_tabMur[i]->getElement())->getTabAcousticSurf();
2151 
2152  LPTYParoi pMurParoi = TYMur::safeDownCast(_tabMur[i]->getElement())->getParoi();
2153 
2154  for (j = 0; j < elemMur.size(); j++)
2155  {
2156  // A sub-face of a 'Mur' must be of type 'MurElement'
2157  LPTYMurElement pMurElt = TYMurElement::safeDownCast(elemMur[j]->getElement());
2158  assert(pMurElt);
2159 
2160  // Retreive the local features of the wall 'Mur'
2161  surfElem = pMurElt->surface();
2162 
2163  // Absorption of the 'Paroi' associated with the surface
2164  if (pMurElt->getIsSub())
2165  {
2166  // If the surface is a window 'Fenetre', then take its absorption
2167  absoElem = pMurElt->getParoi()->getMatFace1()->getSpectreAbso().mult(surfElem);
2168  }
2169  else
2170  {
2171  // Else take the material mading up the wall
2172  absoElem = pMurParoi->getMatFace1()->getSpectreAbso().mult(surfElem);
2173  }
2174 
2175  // Adding elementary alpha*S and elementary surfaces
2176  _absoSabine = _absoSabine.sum(absoElem);
2177  _surfAbsorbante = _surfAbsorbante + surfElem;
2178  }
2179  }
2180 
2181  // Taking into account floors and ceilings
2182 
2183  // Area occupied on the floor by the machines
2184  double aireTotMachinesSol = 0.0;
2185  for (i = 0; i < _facesMachineSol.size(); i++)
2186  {
2187  aireTotMachinesSol = aireTotMachinesSol +
2188  TYAcousticSurface::safeDownCast(_facesMachineSol[i]->getElement())->surface();
2189  }
2190 
2191  // Surface free floor = total surface of the floor - occupied surface by the machines
2192  surfElem = _pSol->surface() - aireTotMachinesSol;
2193  _surfAbsorbante = _surfAbsorbante + surfElem;
2194 
2195  absoElem = _pSol->getParoi()->getMatFace1()->getSpectreAbso().mult(surfElem);
2196  _absoSabine = _absoSabine.sum(absoElem);
2197 
2198  surfElem = _pPlafond->surface();
2199  _surfAbsorbante = _surfAbsorbante + surfElem;
2200 
2201  absoElem = _pPlafond->getParoi()->getMatFace1()->getSpectreAbso().mult(surfElem);
2202  _absoSabine = _absoSabine.sum(absoElem);
2203 
2204  // Taking into accound the absorption of each of the machines
2205  size_t nbMachines = this->getTabMachine().size();
2206  TYTabAcousticSurfaceGeoNode tabPtrSurf;
2207 
2208  for (i = 0; i < nbMachines; i++)
2209  {
2210  elemMachine = TYMachine::safeDownCast(this->getTabMachine()[i]->getElement())->getTabAcousticVol();
2211 
2212  for (j = 0; j < elemMachine.size(); j++)
2213  {
2214  LPTYAcousticVolume pElemMachine = TYAcousticVolume::safeDownCast(elemMachine[j]->getElement());
2215 
2216  surfElem = pElemMachine->surface();
2217 
2218  // Considering that the volumes of the machine are made up with an homogeneous material
2219  // If we'd wish to pass to one material by face, we should put the two following lines
2220  // into a loop processing each face
2221  absoElem = pElemMachine->getMateriau()->getSpectreAbso().mult(surfElem);
2222 
2223  _absoSabine = _absoSabine.sum(absoElem);
2224  double volElem = pElemMachine->volume();
2225  _surfAbsorbante = _surfAbsorbante + surfElem;
2226  _volumeLibre = _volumeLibre - volElem;
2227  }
2228  }
2229 
2230  // The faces of the machines set on the floor do not contribute to the absorption of the machines
2231  for (i = 0; i < _facesMachineSol.size(); i++)
2232  {
2234 
2235  surfElem = pSurface->surface();
2236  absoElem = pSurface->getMateriau()->getSpectreAbso().mult(surfElem);
2237 
2238  _surfAbsorbante = _surfAbsorbante - surfElem;
2239  _absoSabine = _absoSabine.subst(absoElem);
2240  }
2241 
2242  _absoSabine = _absoSabine.div(_surfAbsorbante); // Computing average alpha of the room
2243  _absoSabine = _absoSabine.sum(1.0E-6); // In case of alpha would be zero, adding epsilon to it
2244 }
2245 
2247 {
2248  _TR = TYSpectre::getEmptyLinSpectre(); // Represent a linear value wich is the time
2249 
2250  // Take into accound the atmospheric aborption
2251 
2252  // S * A
2254 
2255  // 0.16*V/(S * A)
2256  _TR = _TR.invMult(0.16 * _volumeLibre);
2257 
2258  _TR.setType(SPECTRE_TYPE_AUTRE); // unit = seconds
2259  _TR.setEtat(SPECTRE_ETAT_DB); // To avoid an unintended transformation
2260 }
2261 
2263 {
2264  int nbPts = static_cast<int>(_tabMur.size());
2265 
2266  TYTabPoint pointsSol;
2267  TYTabPoint pointsPlafond;
2268 
2269  // for (int i = 0; i < nbPts; i++)
2270  for (int i = nbPts - 1; i >= 0; --i)
2271  {
2272  // Creating the polygon for the floor
2273  TYPoint ptSol = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->_pts[3];
2274  // Passing in the coordinate system of the 'Etage'
2275  ptSol = _tabMur[i]->getMatrix() * ptSol;
2276  // Adding the point
2277  pointsSol.push_back(ptSol);
2278 
2279  // Creating the polygon for the ceiling
2280  TYPoint ptPlafond = TYMur::safeDownCast(_tabMur[i]->getElement())->getBoundingRect()->_pts[0];
2281  // Passing into the coordinate system of the 'Etage'
2282  ptPlafond = _tabMur[i]->getMatrix() * ptPlafond;
2283  // Adding the point
2284  pointsPlafond.push_back(ptPlafond);
2285  }
2286 
2287  // Reversing the points of the floor so that normals face outward
2288  TYTabPoint tabPtsTemp = pointsSol;
2289  pointsSol.clear();
2290  std::vector<TYPoint>::reverse_iterator it;
2291  for (it = tabPtsTemp.rbegin(); it != tabPtsTemp.rend(); it++)
2292  {
2293  pointsSol.push_back((*it));
2294  }
2295 
2296  _pSol->getPolygon()->setPoints(pointsSol);
2297  _pPlafond->getPolygon()->setPoints(pointsPlafond);
2298 
2299  setIsGeometryModified(true);
2300 }
2301 
2303 {
2306  AtmosphericConditions atmos(101325., 20., 70.);
2307 
2308  unsigned int i = 0, j = 0;
2309  double distance = NAN;
2310  OSegment3D SR; // Segment source receptor
2311  TYTabAcousticVolumeGeoNode tabVolumes;
2312  TYTabSourcePonctuelleGeoNode tabSources;
2313  OPoint3D posSource;
2314 
2315  // For all the machines
2316  for (i = 0; i < _tabMachine.size(); i++)
2317  {
2319 
2320  if (pVolNode && pVolNode->getIsRayonnant()) // If not radiating, do not take sources
2321  {
2322  TYTabSourcePonctuelleGeoNode tabSrcNode = pVolNode->getSrcs();
2323 
2324  for (j = 0; j < tabSrcNode.size(); j++)
2325  {
2326  // The source
2327  LPTYSourcePonctuelle pSrc = TYSourcePonctuelle::safeDownCast(tabSrcNode[j]->getElement());
2328 
2329  // Transformation matrix to the source coordinate system
2330  OMatrix matInv = tabSrcNode[j]->getMatrix().getInvert();
2331 
2332  // Point position in the source coorinate system
2333  OPoint3D posPtInSrcRep = matInv * unPoint;
2334 
2335  // Contribution of the source to the point
2336  SR = OSegment3D(posSource, posPtInSrcRep);
2337  distance = SR.longueur();
2338 
2339  // Assigning directivity to the source power
2340  sTemp = OSpectre::getEmptyLinSpectre(1.0); // pSrc->lwApparenteSrcDest(SR, atmos); // Q
2341  sTemp = sTemp.mult(pSrc->getSpectre()->toGPhy()); // W
2342  sTemp =
2343  sTemp.mult(atmos.compute_z() / (4 * M_PI * distance * distance)); // Q.W.rho.C / 4.pi.d²
2344 
2345  // Adding spectra
2346  s = s.sum(sTemp);
2347  }
2348  }
2349  }
2350 
2351  // For all the ponctual sources
2352  for (i = 0; i < _tabSources.size(); i++)
2353  {
2355 
2356  if (pSrc && pSrc->getIsRayonnant())
2357  {
2358  posSource = *pSrc->getPos();
2359  SR = OSegment3D(posSource, unPoint);
2360  distance = SR.longueur();
2361 
2362  // Assigning directivity to the source power
2364  1.); // pSrc->lwApparenteSrcDest(SR, atmos); // Directivity of the source Q
2365  sTemp = sTemp.mult(pSrc->getSpectre()->toGPhy()); // Power W
2366  sTemp = sTemp.mult(atmos.compute_z() / (4 * M_PI * distance * distance)); // Q.W.rho.C/(4.pi.d²)
2367 
2368  // Adding spectra
2369  s = s.sum(sTemp);
2370  }
2371  }
2372 
2373  s.setType(SPECTRE_TYPE_LP);
2374 
2375  return s;
2376 }
2378 {
2379  // We start by computing the average absorption coefficient of the room
2380  coeffSabine();
2381 
2382  // Computing TR
2384 
2385  // Computing the reverberated field
2387 }
2388 
2390 {
2391  unsigned int i = 0, j = 0;
2392  AtmosphericConditions atmos(101325., 20., 70.);
2393 
2394  // Room effect ((4.Rho.C / (alpha.S))-(4/S) - Tr.C.AbsoATm)
2395  _reverb = TYSpectre::getEmptyLinSpectre(4.0); // Spectrum initialised to value 4.0
2396 
2397  _reverb = _reverb.div(_absoSabine.mult(_surfAbsorbante)); // 4/(alpha.S)
2398  _reverb = _reverb.mult(atmos.compute_z()); // 4.Rho.C/(alpha.S)
2399 
2400  // reverberated field : W*(Room effect)
2402 
2403  // Pr = 4W*rho*c/a
2404  TYTabSourcePonctuelleGeoNode tabAllSources;
2405 
2406  // Retrieving all the source
2407  // of the machines
2408  for (i = 0; i < _tabMachine.size(); i++)
2409  {
2411  if (pVolNode && pVolNode->getIsRayonnant())
2412  {
2413  // The sources of this machine
2414  TYTabSourcePonctuelleGeoNode tabSrcMachine =
2415  TYMachine::safeDownCast(_tabMachine[i]->getElement())->getSrcs();
2416  tabAllSources.insert(tabAllSources.end(), tabSrcMachine.begin(), tabSrcMachine.end());
2417  }
2418  }
2419 
2420  for (i = 0; i < _tabSources.size(); i++)
2421  {
2423 
2424  // If it is radiating, we add the ponctual source
2425  if (pSrc && pSrc->getIsRayonnant())
2426  {
2427  tabAllSources.push_back(_tabSources[i]);
2428  }
2429  }
2430 
2431  // For each of these sources
2432  for (j = 0; j < tabAllSources.size(); j++)
2433  {
2434  // Adding spectra of all the sources
2435  sTemp = sTemp.sum(
2436  TYSourcePonctuelle::safeDownCast(tabAllSources[j]->getElement())->getSpectre()->toGPhy());
2437  }
2438 
2439  // Adding spectra
2440  _reverb = _reverb.mult(sTemp); // 4.W.Rho.C / (alpha.S)
2441 
2443 }
2444 
2446 {
2447  TYTabMurGeoNode tabMur = getTabMur();
2448 
2449  for (unsigned int i = 0; i < tabMur.size(); i++)
2450  {
2451  LPTYMur pMur = TYMur::safeDownCast(tabMur[i]->getElement());
2452  TYMur::safeDownCast(_tabMur[i]->getElement())->setParoi(_pParoi);
2453  }
2454 
2457 }
2458 
2460 {
2461  unsigned int i = 0;
2462 
2463  _facesMachineSol.clear();
2464 
2465  // Retrieving all the faces of the machines
2466  TYTabAcousticSurfaceGeoNode accFaces;
2467  for (i = 0; i < _tabMachine.size(); i++)
2468  {
2470  TYMachine::safeDownCast(_tabMachine[i]->getElement())->acousticFaces();
2471  OMatrix matrixMachine = _tabMachine[i]->getMatrix();
2472 
2473  for (unsigned int j = 0; j < tabTmp.size(); j++)
2474  {
2475  // Passing into the coordinate system of this 'Etage'
2476  OMatrix matrix = matrixMachine * tabTmp[j]->getMatrix();
2477  tabTmp[j]->setMatrix(matrix);
2478 
2479  accFaces.push_back(tabTmp[j]);
2480  }
2481  }
2482 
2483  // Searching for the faces of this 'Etage' which are set on the floor
2484  OPlan planSol = _pSol->plan();
2485  double distance = 0.0;
2486 
2487  for (i = 0; i < accFaces.size(); i++)
2488  {
2489  // The face
2490  LPTYAcousticSurfaceGeoNode pFaceGeoNode = accFaces[i];
2491 
2492  // Contour of the face
2493  LPTYAcousticSurface pSurface = TYAcousticSurface::safeDownCast(accFaces[i]->getElement());
2494  TYTabPoint contour = pSurface->getContour();
2495  if (contour.size() < 3)
2496  {
2497  continue;
2498  }
2499 
2500  OMatrix matrixFace = accFaces[i]->getMatrix();
2501 
2502  // A point on the plane of the face in the coordinate system of the 'Etage'
2503  OPoint3D ptPlan = matrixFace * OVector3D(contour[0]);
2504  // The normal to the face in the coordinate system of the 'Etage'
2505  OVector3D vecPlan = OVector3D(matrixFace * OPoint3D(0.0, 0.0, 0.0), matrixFace * pSurface->normal());
2506  vecPlan.normalize();
2507  // The plane of the face in the coordinate system of the 'Etage'
2508  OPlan planFace(ptPlan, vecPlan);
2509 
2510  // Distance betaween 2 floors if they are parallel
2511  if (planFace.distancePlanParallel(planSol, distance))
2512  {
2513  // If the face is set on the floor (with a tolerance)
2514  if (ABS(distance) <= TYSEUILCONFONDUS)
2515  {
2516  // We "deactivate" this face of the machine
2517  pSurface->setDensiteSrcs(0.0);
2518 
2519  // We preserve the faces touching the floor
2520  _facesMachineSol.push_back(accFaces[i]);
2521  }
2522  }
2523  }
2524 }
2525 
2526 bool TYEtage::updateAcoustic(const bool& force) // force=false
2527 {
2528  unsigned int i = 0;
2529  bool ret = true;
2530 
2531  // If not radiating, we do not block the calculation
2532  // (this situation may be intentional, but no acoustic distribution is performed in this case)
2533  if (!_isRayonnant)
2534  {
2535  return true;
2536  }
2537 
2538  // We start by adjusting the height of the sources
2539  updateZSource();
2540 
2541  // updateAcoustic of the machines in the 'Batiment' if any
2542  if ((_tabMachine.size() != 0) || (_tabSources.size() != 0))
2543  {
2545 
2546  // Machines
2547  for (i = 0; i < _tabMachine.size(); i++)
2548  {
2549  ret &= TYMachine::safeDownCast(_tabMachine[i]->getElement())->updateAcoustic();
2550  }
2551  }
2552 
2554  distriSrcs();
2555  ret &= setSrcsLw();
2556 
2557  return ret;
2558 }
2559 
2561 {
2562  // Remove the sources on the walls
2563  for (unsigned int i = 0; i < _tabMur.size(); i++)
2564  {
2565  TYAcousticRectangleNode::safeDownCast(_tabMur[i]->getElement())->remAllSrcs();
2566  }
2567 
2568  // Remove the sources on the floor and ceiling
2569  _pSol->remAllSrcs();
2570  _pPlafond->remAllSrcs();
2571 }
2572 
2574 {
2575  unsigned int i = 0;
2576  double surface = 0.0;
2577 
2578  for (i = 0; i < _tabMur.size(); i++)
2579  {
2580  LPTYMur pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
2581 
2582  surface += pMur->activeSurface();
2583  }
2584 
2585  return surface;
2586 }
2587 
2588 TYSpectre TYEtage::setGlobalLW(const TYSpectre& spectre, const double& surfGlobale, const int& regime /*=-1*/)
2589 {
2590  /* If the 'Etage' is set to "Puissance imposée", we return it; if the 'Etage' is set to "Puissance
2591  * calculée", its power depends on the sources it contains and has been calculated previously by an
2592  * updateAcoustic (this is the opposite of the machines).*/
2593  return getCurrentSpectre().toGPhy(); // Returns the obtained spectrum
2594 }
2595 
2597  const LPTYParoi pMurParoi)
2598 {
2599  TYSpectre spectreEltMur = TYSpectre::getEmptyLinSpectre();
2601  OSpectre spectreAtt;
2602  OPoint3D posSrc;
2603  AtmosphericConditions atmos(101325., 20., 70.);
2604 
2605  // A sub-face of wall must be of type MurElement
2606  LPTYMurElement pMurElt = TYMurElement::safeDownCast(pCurrentSurf);
2607 
2608  if (pMurElt) // Process floor and ceiling case
2609  {
2610  if (pMurElt->getIsSub())
2611  {
2612  // If the 'Paroi' is a window 'Fenetre'
2613  spectreAtt = pMurElt->getParoi()->getMatStruct()->getSpectreTransm();
2614  }
2615  else
2616  {
2617  // Otherwise, it is the 'Paroi' associated with the 'Mur'
2618  spectreAtt = pMurParoi->getMatStruct()->getSpectreTransm();
2619  }
2620  }
2621  else // Case of floor and ceiling
2622  {
2623  // Otherwise, it is the 'Paroi' associated with the 'Mur'
2624  spectreAtt = pMurParoi->getMatStruct()->getSpectreTransm();
2625  }
2626 
2627  TYTabSourcePonctuelleGeoNode tabSources = pCurrentSurf->getSrcs();
2628  double surf = pCurrentSurf->surface() / tabSources.size();
2629 
2630  // For all the ponctual sources of the face
2631  for (unsigned int k = 0; k < tabSources.size(); k++)
2632  {
2633  LPTYSourcePonctuelle pSource = TYSourcePonctuelle::safeDownCast(tabSources[k]->getElement());
2634 
2635  // Position of the source in the coordinate system of the 'Etage'
2636  posSrc = matMur * *(pSource->getPos());
2637 
2638  s = _reverb.div(4.0); // Correction reverberated field (pressure), reverberated intensity.
2639 
2640  s = s.sum(champDirect(posSrc));
2641 
2642  s = s.mult(surf / atmos.compute_z()); // W = P² * S / (rho.C)
2643  // s = s.sum(_reverb);// P² = directField + reverberatedField
2644 
2645  // s = s.div(4.0); // DT 20100106 as the test case transparent 'Paroi' did not match
2646 
2647  s = s.div((spectreAtt).toGPhy()); // See whether the spectrum must be converted in physical value
2648 
2649  spectreEltMur = spectreEltMur.sum(s);
2650  }
2651 
2652  spectreEltMur.setType(SPECTRE_TYPE_LW);
2653  return spectreEltMur;
2654 }
2655 
2656 void TYEtage::setParoi(const LPTYParoi pParoi)
2657 {
2658  assert(pParoi);
2659  assert(_pParoi);
2660 
2661  *_pParoi = *pParoi;
2662 }
2663 
2665 {
2666  unsigned int i = 0;
2667  for (i = 0; i < _tabSources.size(); i++)
2668  {
2670  double h = pSource->getHauteur();
2671  pSource->getPos()->_z = h;
2672  _tabSources[i]->setIsGeometryModified(true);
2673  }
2674 
2675  for (i = 0; i < _tabMachine.size(); i++)
2676  {
2677  double h = _tabMachine[i]->getHauteur();
2678  _tabMachine[i]->getORepere3D()._origin._z = h;
2679  }
2680 
2681  setIsGeometryModified(true);
2682 }
2683 
2685 {
2686  size_t i = 0;
2687  size_t nbFaces = this->getTabMur().size();
2688 
2689  LPTYMur pMur = NULL;
2690 
2691  // Propagating to the walls 'Murs'
2692  for (i = 0; i < nbFaces; i++)
2693  {
2694  pMur = TYMur::safeDownCast(_tabMur[i]->getElement());
2695 
2696  if (pMur)
2697  {
2698  pMur->propagateAtt(pAtt);
2699  }
2700  }
2701 
2702  // Propagating to the floor and ceiling
2703  _pSol->propagateAtt(pAtt);
2704  _pPlafond->propagateAtt(pAtt);
2705 
2707 }
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:642
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:1130
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:965
static bool getRegenerateID()
Definition: TYElement.h:926
static TYUUID fromString(QString id)
Definition: TYElement.cpp:621
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:542
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:785
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYElement.h:530
static void setRegenerateID(const bool &bRegenerate)
Definition: TYElement.h:922
void setParent(TYElement *pParent)
Definition: TYElement.h:699
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:2445
virtual TYTabPoint sommets() const
Definition: TYEtage.cpp:1889
void updateSolPlafond()
Definition: TYEtage.cpp:2262
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:1458
virtual double volume() const
Definition: TYEtage.cpp:1852
LPTYDalle _pSol
Dalle pour le sol.
Definition: TYEtage.h:575
virtual void distriSrcs()
Definition: TYEtage.cpp:1667
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYEtage.cpp:150
void setacousticFacesPourCalcul(bool bPourCalculTrajet)
Definition: TYEtage.cpp:2022
virtual TYSourcePonctuelle srcPonctEquiv() const
Definition: TYEtage.cpp:1632
virtual void setNextRegimeNb(const int &next)
Definition: TYEtage.cpp:1565
void calculTempsReverb()
Definition: TYEtage.cpp:2246
virtual void setDensiteSrcsV(double densite, bool recursif=true)
Definition: TYEtage.cpp:1652
LPTYMachineGeoNode findMachine(const LPTYMachine pMachine)
Definition: TYEtage.cpp:1223
void calculChampReverbere()
Definition: TYEtage.cpp:2377
virtual void setDensiteSrcsH(double densite, bool recursif=true)
Definition: TYEtage.cpp:1637
virtual TYPoint centreGravite() const
Definition: TYEtage.cpp:1941
TYTabMachineGeoNode & getTabMachine()
Definition: TYEtage.h:281
virtual int isInside(const TYPoint &pt) const
Definition: TYEtage.cpp:1971
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:1966
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:2027
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:1703
virtual bool findAcousticSurface(const TYAcousticSurface *pAccSurf, OMatrix *pMatrix=0)
Definition: TYEtage.cpp:2103
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:2596
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:1441
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:1872
virtual void remAllSrcs()
Definition: TYEtage.cpp:2560
void coeffSabine()
Definition: TYEtage.cpp:2132
double getHauteur() const
Definition: TYEtage.cpp:1039
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=true)
Definition: TYEtage.cpp:1428
OSpectre champDirect(const OPoint3D &unPoint)
Definition: TYEtage.cpp:2302
bool remSource(const LPTYUserSourcePonctuelleGeoNode pSourceGeoNode)
Definition: TYEtage.cpp:1278
bool addSource(LPTYUserSourcePonctuelleGeoNode pSourceGeoNode)
Definition: TYEtage.cpp:1239
virtual double surface() const
Definition: TYEtage.cpp:1857
void setParoi(const LPTYParoi pParoi)
Definition: TYEtage.cpp:2656
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:1578
LPTYUserSourcePonctuelleGeoNode findSource(const LPTYUserSourcePonctuelle pSource)
Definition: TYEtage.cpp:1412
virtual void propagateAtt(LPTYAttenuateur pAtt)
Definition: TYEtage.cpp:2684
void calculChampRevSabine()
spectre de pression acoustique après fonction
Definition: TYEtage.cpp:2389
virtual TYTabLPPolygon faces() const
Definition: TYEtage.cpp:1912
void remAllMachine()
Definition: TYEtage.cpp:1193
bool addMachine(LPTYMachineGeoNode pMachineGeoNode)
Definition: TYEtage.cpp:1051
virtual TYSpectre setGlobalLW(const TYSpectre &spectre, const double &surfGlobale, const int &regime=-1)
Definition: TYEtage.cpp:2588
void updateZSource()
Definition: TYEtage.cpp:2664
virtual bool updateAcoustic(const bool &force=false)
Definition: TYEtage.cpp:2526
void setHauteur(double hauteur)
Definition: TYEtage.cpp:1015
void remAllSources()
Definition: TYEtage.cpp:1381
tabMapPtrElementBool _tabEtatMachines
Gestion des etats des machines.
Definition: TYEtage.h:614
bool remMachine(const LPTYMachineGeoNode pMachineGeoNode)
Definition: TYEtage.cpp:1090
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:1936
virtual double activeSurface() const
Definition: TYEtage.cpp:2573
bool _bPourCalculTrajet
Definition: TYEtage.h:618
void findFaceMachineSol()
Definition: TYEtage.cpp:2459
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
Definition: TYEtage.cpp:1596
virtual int addRegime()
Definition: TYEtage.cpp:1543
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