Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticBox.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 "Tympan/core/logging.h"
18 #if TY_USE_IHM
22 #endif
23 #include "TYAcousticBox.h"
24 
27 
29 {
31 
32  float r = 46.0f, g = 4.0f, b = 184.0f;
33 
34 #if TY_USE_IHM
35  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColorR"))
36  {
37  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColor", r, g, b);
38  }
39  else
40  {
41  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColor", r, g, b);
42  }
43 
44 #endif // TY_USE_IHM
45 
46  OColor color;
47  color.r = r / 255;
48  color.g = g / 255;
49  color.b = b / 255;
50 
51  setColor(color);
52 
53  unsigned int i = 0;
54  for (i = 0; i < 6; i++)
55  {
58  _faces[i] = pAcRectNode;
59  _faces[i]->setParent(this);
60  _faces[i]->getElement()->setParent(this);
61  _faces[i]->getElement()->setName("Face " + QString(intToStr(i).c_str()));
62 
63  // Ajout de la couleur a chaque face.
64  TYAcousticRectangleNode::safeDownCast(_faces[i]->getElement())->setColor(getColor());
65  }
66 
67  // Ajout de la couleur a chaque rectangle de la face non sub.
69  for (i = 0; i < tab.size(); ++i)
70  {
71  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tab[i]->getElement());
72  if (!pAccSurf->getIsSub())
73  {
74  pAccSurf->setColor(getColor());
75  }
76  }
77 
78  TYRepere rep;
79 
80  rep._vecI = OVector3D(0, 1, 0);
81  rep._vecJ = OVector3D(0, 0, 1);
82  rep._vecK = OVector3D(1, 0, 0);
83  _faces[0]->setRepere(rep);
84 
85  rep._vecI = OVector3D(1, 0, 0);
86  rep._vecJ = OVector3D(0, 0, 1);
87  rep._vecK = OVector3D(0, -1, 0);
88  _faces[1]->setRepere(rep);
89 
90  rep._vecI = OVector3D(0, -1, 0);
91  rep._vecJ = OVector3D(0, 0, 1);
92  rep._vecK = OVector3D(-1, 0, 0);
93  _faces[2]->setRepere(rep);
94 
95  rep._vecI = OVector3D(-1, 0, 0);
96  rep._vecJ = OVector3D(0, 0, 1);
97  rep._vecK = OVector3D(0, 1, 0);
98  _faces[3]->setRepere(rep);
99 
100  rep._vecI = OVector3D(1, 0, 0);
101  rep._vecJ = OVector3D(0, -1, 0);
102  rep._vecK = OVector3D(0, 0, -1);
103  _faces[4]->setRepere(rep);
104 
105  rep._vecI = OVector3D(1, 0, 0);
106  rep._vecJ = OVector3D(0, 1, 0);
107  rep._vecK = OVector3D(0, 0, 1);
108  _faces[5]->setRepere(rep);
109 
110  setDimension(1.0, 1.0, 1.0);
111 
112  _volEnglob = volEnglob();
115 }
116 
118 {
119  *this = other;
120 }
121 
123 
124 void TYAcousticBox::setDimension(float larg, float lon, float haut)
125 {
126  LPTYAcousticRectangleNode pElement;
127 
128  ORepere3D repere;
129 
130  float demiLarg = larg / 2.0;
131  float demiLon = lon / 2.0;
132  float demiHaut = haut / 2.0;
133 
134  float oldX = 0, oldY = 0, oldZ = 0;
135 
136  getDimension(oldX, oldY, oldZ);
137 
138  // Modification de la position pour tenir compte des nouvelles dimensions
140  if (pParent)
141  {
142  LPTYAcousticVolumeGeoNode pGeoNode = pParent->findAcousticVol(this);
143  if (pGeoNode)
144  {
145  ORepere3D repere = pGeoNode->getORepere3D();
146  TYPoint org = repere._origin;
147  // On retire l'ancienne hauteur
148  org._z -= oldZ / 2;
149  // On ajoute la nouvelle hauteur
150  org._z += demiHaut;
151  repere._origin = org;
152  pGeoNode->setRepere(repere);
153  }
154  }
155 
156  pElement = TYAcousticRectangleNode::safeDownCast(_faces[0]->getElement());
157  repere = _faces[0]->getORepere3D();
158  repere._origin._x = demiLarg;
159  _faces[0]->setRepere(repere);
160  pElement->setSize(lon, haut);
161  _faces[0]->setIsGeometryModified(true);
162 
163  pElement = TYAcousticRectangleNode::safeDownCast(_faces[2]->getElement());
164  repere = _faces[2]->getORepere3D();
165  repere._origin._x = -demiLarg;
166  _faces[2]->setRepere(repere);
167  pElement->setSize(lon, haut);
168  _faces[2]->setIsGeometryModified(true);
169 
170  pElement = TYAcousticRectangleNode::safeDownCast(_faces[1]->getElement());
171  repere = _faces[1]->getORepere3D();
172  repere._origin._y = -demiLon;
173  _faces[1]->setRepere(repere);
174  pElement->setSize(larg, haut);
175  _faces[1]->setIsGeometryModified(true);
176 
177  pElement = TYAcousticRectangleNode::safeDownCast(_faces[3]->getElement());
178  repere = _faces[3]->getORepere3D();
179  repere._origin._y = demiLon;
180  _faces[3]->setRepere(repere);
181  pElement->setSize(larg, haut);
182  _faces[3]->setIsGeometryModified(true);
183 
184  pElement = TYAcousticRectangleNode::safeDownCast(_faces[4]->getElement());
185  repere = _faces[4]->getORepere3D();
186  repere._origin._z = -demiHaut;
187  _faces[4]->setRepere(repere);
188  pElement->setSize(larg, lon);
189  _faces[4]->setIsGeometryModified(true);
190 
191  pElement = TYAcousticRectangleNode::safeDownCast(_faces[5]->getElement());
192  repere = _faces[5]->getORepere3D();
193  repere._origin._z = demiHaut;
194  _faces[5]->setRepere(repere);
195  pElement->setSize(larg, lon);
196  _faces[5]->setIsGeometryModified(true);
197 
198  _volEnglob = volEnglob();
199  if (_pParent)
200  {
201  TYAcousticVolumeNode::safeDownCast(_pParent)->updateVolEnglob();
202  } // Informe le parent de se mettre a jour
203 
206 
207  setIsGeometryModified(true);
208 }
209 
210 void TYAcousticBox::getDimension(float& larg, float& lon, float& haut)
211 {
212  LPTYAcousticRectangleNode pElement;
213 
214  pElement = TYAcousticRectangleNode::safeDownCast(getFace(1)->getElement());
215  larg = pElement->getBoundingRect()->getSizeX();
216  pElement = TYAcousticRectangleNode::safeDownCast(getFace(0)->getElement());
217  lon = pElement->getBoundingRect()->getSizeX();
218  haut = pElement->getBoundingRect()->getSizeY();
219 }
220 
221 void TYAcousticBox::setFace(const LPTYAcousticRectangleNode pAccRect, int numFace)
222 {
223  _faces[numFace]->setElement((LPTYElement)pAccRect);
224  _faces[numFace]->setParent(this);
225 
226  _volEnglob = volEnglob();
227  if (_pParent)
228  {
229  TYAcousticVolumeNode::safeDownCast(_pParent)->updateVolEnglob();
230  } // Informe le parent de se mettre a jour
231 
234 
235  setIsGeometryModified(true);
236 }
237 
239 {
240  if (this != &other)
241  {
243  for (int i = 0; i < 6; i++)
244  {
245  _faces[i] = other._faces[i];
246  }
247  }
248 
249  _volEnglob = volEnglob();
252 
253  return *this;
254 }
255 
256 bool TYAcousticBox::operator==(const TYAcousticBox& other) const
257 {
258  if (this != &other)
259  {
260  if (TYAcousticVolume::operator!=(other))
261  {
262  return false;
263  }
264  for (int i = 0; i < 6; i++)
265  if (_faces[i] != other._faces[i])
266  {
267  return false;
268  }
269  }
270  return true;
271 }
272 
273 bool TYAcousticBox::operator!=(const TYAcousticBox& other) const
274 {
275  return !operator==(other);
276 }
277 
278 bool TYAcousticBox::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
279 {
280  if (!TYAcousticVolume::deepCopy(pOther, copyId))
281  {
282  return false;
283  }
284 
285  for (int i = 0; i < 6; i++)
286  {
287  _faces[i]->deepCopy(((TYAcousticBox*)pOther)->getFace(i), copyId);
288  _faces[i]->getElement()->setParent(this);
289  _faces[i]->setParent(this);
290  }
291 
292  _volEnglob = volEnglob();
295 
296  return true;
297 }
298 
299 std::string TYAcousticBox::toString() const
300 {
301  return "TYAcousticBox";
302 }
303 
305 {
306  DOM_Element domNewElem = TYAcousticVolume::toXML(domElement);
307 
308  for (int i = 0; i < 6; i++)
309  {
310  _faces[i]->toXML(domNewElem);
311  }
312 
313  return domNewElem;
314 }
315 
317 {
318  TYAcousticVolume::fromXML(domElement);
319 
320  int faceNb = 0;
321  unsigned int i = 0;
322  DOM_Element elemCur;
323  QDomNodeList childs = domElement.childNodes();
324 
325  for (i = 0; i < childs.length(); i++)
326  {
327  elemCur = childs.item(i).toElement();
328  if (faceNb < 6)
329  {
330  // Increment l'indice si la face est trouvee
331  if (_faces[faceNb]->callFromXMLIfEqual(elemCur))
332  {
333  faceNb++;
334  }
335  }
336  }
337 
338  // ------- A SUPPRIMER LORSQUE TOUT LES XML AURONT LES INFOS DE COULEUR -------
339  //
340  // Je sais c'est pas tres beau, mais c'est pour etre compatible avec les vielles versions
341  // de l'XML pour la gestion des couleurs... Je teste la couleur pour savoir
342  // si elle est blanche, si oui, c'est possible que ce soit un ancien fichier, on applique donc
343  // une couleur par default;
344  //
345  OColor color;
346  bool allWhite = true;
347  for (faceNb = 0; faceNb < 6; ++faceNb)
348  {
349  color = TYAcousticSurfaceNode::safeDownCast(_faces[0]->getElement())->getColor();
350  if (color.r != 1.0f || color.g != 1.0f || color.b != 1.0f)
351  {
352  allWhite = false;
353  break;
354  }
355  }
356 
357  if (allWhite)
358  {
359  float r = 46.0f, g = 4.0f, b = 184.0f;
360 
361 #if TY_USE_IHM
362  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColorR"))
363  {
364  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColor", r, g, b);
365  }
366  else
367  {
368  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColor", r, g, b);
369  }
370 
371 #endif // TY_USE_IHM
372 
373  OColor color;
374  color.r = r / 255;
375  color.g = g / 255;
376  color.b = b / 255;
377 
378  setColor(color);
379 
380  for (faceNb = 0; faceNb < 6; ++faceNb)
381  {
382  TYAcousticSurfaceNode::safeDownCast(_faces[faceNb]->getElement())->setColor(color);
383  }
384 
385  // Ajout de la couleur a chaque rectangle de la face non sub.
387  for (i = 0; i < tab.size(); ++i)
388  {
389  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tab[i]->getElement());
390  if (!pAccSurf->getIsSub())
391  {
392  pAccSurf->setColor(color);
393  }
394  }
395  }
396  //
397  // ----------------------------------------------------------------------------
398 
399  _volEnglob = volEnglob();
402 
403  if (_forceNormales)
404  {
405  inverseNormales();
406  }
407 
408  return 1;
409 }
410 
411 void TYAcousticBox::getChilds(LPTYElementArray& childs, bool recursif /*=true*/)
412 {
413  TYAcousticVolume::getChilds(childs, recursif);
414 
415  for (int i = 0; i < 6; i++)
416  {
417  childs.push_back(_faces[i]);
418  childs.push_back(_faces[i]->getElement());
419  }
420 
421  if (recursif)
422  {
423  for (int i = 0; i < 6; i++)
424  {
425  _faces[i]->getChilds(childs, recursif);
426  }
427  }
428 }
429 
430 void TYAcousticBox::setRegime(TYSpectre& Spectre, int regime /*=-1*/, bool recursif /*=false*/)
431 {
432  if (recursif)
433  {
434  for (int i = 0; i < 6; i++)
435  {
436  getFaceElement(i)->setRegime(Spectre, regime, recursif);
437  }
438  }
439 
440  TYAcousticVolume::setRegime(Spectre, regime, recursif);
441 }
442 
443 void TYAcousticBox::exportCSV(std::ofstream& ofs)
444 {
445  // Export du nom de l'objet
446  ofs << getName().toLatin1().data() << '\n';
447 
448  // Export du type de l'objet
449  ofs << toString() << '\n';
450 
451  // Export des donnees acoustiques
453 
454  for (int i = 0; i < 6; i++)
455  {
456  getFaceElement(i)->exportCSV(ofs);
457  }
458 
459  ofs << '\n';
460 }
461 
462 bool TYAcousticBox::remRegime(int regime)
463 {
464  for (int i = 0; i < 6; i++)
465  {
466  getFaceElement(i)->remRegime(regime);
467  }
468 
469  return TYAcousticVolume::remRegime(regime);
470 }
471 
472 void TYAcousticBox::loadRegime(int regimeNb)
473 {
474  for (int i = 0; i < 6; i++)
475  {
476  getFaceElement(i)->loadRegime(regimeNb);
477  }
478 
480 }
481 
483 {
484  for (int i = 0; i < 6; i++)
485  {
486  getFaceElement(i)->setCurRegime(regime);
487  }
488 
490 
491  setIsAcousticModified(true);
492 }
493 /*
494 int TYAcousticBox::addRegime(const TYRegime& regime)
495 {
496  for (int i = 0; i < 6; i++)
497  {
498  getFaceElement(i)->addRegime();
499  }
500 
501  return TYAcousticInterface::addRegime(regime);
502 }
503 */
505 {
506  for (int i = 0; i < 6; i++)
507  {
509  }
510 
512 }
513 
514 void TYAcousticBox::setNextRegimeNb(const int& next)
515 {
516  _nextRegime = next;
517 
518  for (int i = 0; i < 6; i++)
519  {
521  }
522 }
523 
524 void TYAcousticBox::setRegimeName(const QString& name)
525 {
526  bool status = true;
527  TYRegime& reg = getRegimeNb(_curRegime, status);
528  if (status)
529  {
530  reg.setRegimeName(name);
531  }
532 
533  for (int i = 0; i < 6; i++)
534  {
536  }
537 }
538 
540 {
541  for (int i = 0; i < 6; i++)
542  {
543  getFaceElement(i)->propagateAtt(pAtt);
544  }
545 
547 }
548 
550 {
552 
553  // Pour chaque face
554  for (int i = 0; i < 6; i++)
555  {
557 
558  if (pElement->getIsRayonnant())
559  {
560  // Recupere l'ensemble des srcs de la face
561  TYTabSourcePonctuelleGeoNode tabChild = pElement->getSrcs();
562 
563  // Concatenation des matrices
564  OMatrix matrix = _faces[i]->getMatrix();
565  for (unsigned int j = 0; j < tabChild.size(); j++)
566  {
567  tabChild[j]->setMatrix(matrix * tabChild[j]->getMatrix());
568  }
569 
570  //...et ajoute au tableau a retourner
571  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
572  }
573  }
574 
575  return tab;
576 }
577 
579 {
580  return TYSourcePonctuelle();
581 }
582 
583 void TYAcousticBox::setDensiteSrcsH(double densite, bool recursif /*=true*/)
584 {
585  TYAcousticVolume::setDensiteSrcsH(densite, recursif);
586 
587  if (recursif)
588  {
589  for (int i = 0; i < 6; i++)
590  {
592  }
593  }
594 }
595 
596 void TYAcousticBox::setDensiteSrcsV(double densite, bool recursif /*=true*/)
597 {
598  TYAcousticVolume::setDensiteSrcsV(densite, recursif);
599 
600  if (recursif)
601  {
602  for (int i = 0; i < 6; i++)
603  {
605  }
606  }
607 }
608 
610 {
611  if (_isRayonnant)
612  {
613  for (int i = 0; i < 6; i++)
614  {
615  // Si la face est rayonnante et que qu'elle a une densite de source, on lui en met...
616  if ((getFaceElement(i)->getIsRayonnant())) // && (getFaceElement(i)->getDensiteSrcs() > 0))
617  {
619  }
620  }
621  }
622 }
623 
625 {
626  // Suppression de toutes les sources pour toutes les faces
627  for (int i = 0; i < 6; i++)
628  {
630  }
631 }
632 
634 {
635  bool res = true;
636 
637  for (int i = 0; i < 6; i++)
638  {
639  // Affectation de puissance uniquement si l'element est rayonnant
640  if ((getFaceElement(i)->getIsRayonnant())) //&& (getFaceElement(i)->getDensiteSrcs() > 0))
641  {
642  res = getFaceElement(i)->setSrcsLw();
643  }
644  }
645 
646  return res;
647 }
648 
649 double TYAcousticBox::volume() const
650 {
651  double profondeur = getFaceElement(1)->getSizeX();
652 
653  // Vol = aire d'un cote x profondeur
654  return (getFaceElement(0)->surface() * profondeur);
655 }
656 
658 {
659  double ret = 0.0;
660 
661  // C'est la somme de toutes les surfaces
662  for (int i = 0; i < 6; i++)
663  {
664  ret += getFaceElement(i)->surface();
665  }
666 
667  return ret;
668 }
669 
671 {
672  double ret = 0.0;
673 
674  // C'est la somme de toutes les surfaces actives
675  for (int i = 0; i < 6; i++)
676  {
677  if (getFaceElement(i)->getIsRayonnant())
678  {
679  ret += getFaceElement(i)->activeSurface();
680  }
681  }
682 
683  return ret;
684 }
685 
687 {
688  double ret = 0.0;
689 
690  // C'est la somme de toutes les surfaces actives
691  for (int i = 0; i < 6; i++)
692  {
693  if (getFaceElement(i)->getIsRayonnant())
694  {
695  ret += getFaceElement(i)->activeSurface();
696  }
697  }
698 
699  return ret;
700 }
701 
703 {
704  TYTabVector tab;
705 
706  for (int i = 0; i < 6; i++)
707  {
708  // On recupere la normale de la face
710 
711  // On convertit la normale dans le repere du vol node
712  normal = _faces[i]->getMatrix() * normal;
713 
714  // Ajout
715  tab.push_back(normal);
716  }
717 
718  return tab;
719 }
720 
722 {
723  TYTabPoint tab;
724  TYPoint pt;
725  OMatrix matrix0 = _faces[0]->getMatrix();
726  OMatrix matrix2 = _faces[2]->getMatrix();
727 
728  tab.reserve(8);
729 
730  // Les sommets des faces 0 et 2 suffisent
731  for (int i = 0; i < 4; i++)
732  {
733  pt = getFaceElement(0)->getBoundingRect()->_pts[i];
734  pt = matrix0 * pt;
735  tab.push_back(pt);
736 
737  pt = getFaceElement(2)->getBoundingRect()->_pts[i];
738  pt = matrix2 * pt;
739  tab.push_back(pt);
740  }
741 
742  return tab;
743 }
744 
746 {
747  TYTabLPPolygon tab;
748 
749  tab.reserve(6);
750 
751  for (int i = 0; i < 6; i++)
752  {
753  // Polygon representant la face
754  TYPolygon* pPolygon = getFaceElement(i)->getBoundingRect()->toPolygon();
755 
756  // On convertit le polygon dans le repere de l'acc box
757  OMatrix matrix = _faces[i]->getMatrix();
758 
759  pPolygon->transform(matrix);
760  // Ajout du polygon
761  tab.push_back(pPolygon);
762  }
763 
764  return tab;
765 }
766 
768 {
770 }
771 
773 {
774  // Le centre de gravite se trouve au milieu du segment defini par 2 points opposes dans la box
777 
778  OVector3D vecDiagonale(pt1, pt2);
779  OVector3D vecCentreGravite = OVector3D(pt1) + (vecDiagonale * 0.5);
780 
781  return TYPoint(vecCentreGravite);
782 }
783 
784 int TYAcousticBox::intersects(const OSegment3D& seg, TYTabPoint& ptList) const
785 {
786  return TYVolumeInterface::intersects(seg, ptList);
787 }
788 
789 int TYAcousticBox::isInside(const TYPoint& pt) const
790 {
791  return _volEnglob.isInside(pt);
792 }
793 
794 bool TYAcousticBox::updateAcoustic(const bool& force) // force = false
795 {
796  /*
797  NB : On travaille sur un regime donne.
798  */
799 
800  int i = 0;
801  bool ret = true;
802 
803  // 1/ Recuperer la surface totale
804  double surfTotale = activeSurface();
805 
806  // Si le volume n'est pas rayonnant, ou si les densités sont nulles,
807  // ce qui revient au même, inutile de tenter de distribuer
808  // la puissance, mais ce n'est pas une raison pour bloquer le calcul
809  if (!_isRayonnant || surfTotale == 0)
810  {
811  return true;
812  }
813 
814  TYSpectre LWc = TYSpectre::getEmptyLinSpectre(); // Spectre cumule de l'ensembles des elements
815  TYSpectre LWg = getCurrentSpectre().toGPhy(); // Spectre global du regime courant
816  TYSpectre LWv; // Spectre de puissance de la face courante
817 
819 
820  for (i = 0; i < 6; i++) // Les faces ordinaires
821  {
823 
824  // Si la face est rayonnante
825  if (pFace->getIsRayonnant())
826  {
827  LWv = pFace->setGlobalLW(LWg, surfTotale);
828  LWc = LWc.sum(LWv);
829  ret &= pFace->updateAcoustic();
830  }
831  else
832  {
833  TYSpectre aTYSpectre;
834  pFace->setRegime(aTYSpectre);
835  }
836  }
837 
838  // 3 cas le derner ret==false
839 
840  if (ret && (_typeDistribution == TY_PUISSANCE_IMPOSEE))
841  {
842  // Il faut s'assurer que la somme des puissances des volumes egale la puissance de la machine
843  double residu = ABS(10 * log10(LWg.sigma()) - 10 * log10(LWc.sigma()));
844 
845  // Si l'ecart est inferieur a 1 dB on accepte
846  ret = residu < 1 ? true : false;
847  }
848  else if (ret && (_typeDistribution == TY_PUISSANCE_CALCULEE))
849  {
850  // Puissance de la machine = puissance cumulee des volumes qui la composent
853 
854  for (i = 0; i < 6; i++)
855  {
857  if (pFace->getIsRayonnant())
858  {
859  LWc = LWc.sum(pFace->getCurrentSpectre().toGPhy());
860  }
861  }
862 
863  TYSpectre temp = LWc.toDB();
864  this->setRegime(temp, -1,
865  false); // Pas de probleme la puissance attribuee au volume peut etre modifiee
866  }
867 
868  return ret;
869 }
870 
872 {
874 
875  for (int i = 0; i < 6; i++)
876  {
877  // Sous-faces pour cette face
879  OMatrix matrixFace = _faces[i]->getMatrix();
880 
881  for (unsigned int j = 0; j < tabTmp.size(); j++)
882  {
883  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tabTmp[j]->getElement());
884 
885  // M = M(face) . M(sous-face)
886  OMatrix matrix = matrixFace * tabTmp[j]->getMatrix();
887 
888  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf, matrix));
889  }
890  }
891 
892  return tab;
893 }
894 
895 bool TYAcousticBox::findAcousticSurface(const TYAcousticSurface* pAccSurf, OMatrix* pMatrix /*=0*/)
896 {
897  bool ret = false;
898 
899  for (int i = 0; (i < 6) && !ret; i++)
900  {
901  // Sous-faces pour cette face
903 
904  for (unsigned int j = 0; j < tabTmp.size(); j++)
905  {
906  if (TYAcousticSurface::safeDownCast(tabTmp[j]._pObj->getElement()) == pAccSurf)
907  {
908  if (pMatrix)
909  {
910  // Mise a jour de la matrice
911  *pMatrix = *pMatrix * _faces[i]->getMatrix() * tabTmp[j]->getMatrix();
912  }
913 
914  // Surf trouvee
915  break;
916  }
917  }
918  }
919 
920  return ret;
921 }
922 
924 {
925  TYTabLPAcousticSurface tabSubFaces;
926 
927  // On balaye toutes les faces
928  for (int i = 0; i < 6; i++)
929  {
931 
932  for (unsigned int j = 0; j < tabSurf.size(); j++)
933  {
934  LPTYAcousticSurface pSurface = TYAcousticSurface::safeDownCast(tabSurf[j]->getElement());
935 
936  if (pSurface->getIsSub())
937  {
938  tabSubFaces.push_back(pSurface);
939  }
940  }
941  }
942 
943  return tabSubFaces;
944 }
945 
946 void TYAcousticBox::setIsRayonnant(bool rayonnant, bool recursif)
947 {
948  TYAcousticVolume::setIsRayonnant(rayonnant, recursif);
949 }
double ABS(double a)
Return the absolute value.
Definition: 3d.h:67
QColor getColor
QDomElement DOM_Element
Definition: QT2DOM.h:30
Representation graphique d'une boite acoustique (fichier header)
outil IHM pour une boite acoustique (fichier header)
TY_EXTENSION_INST(TYAcousticBox)
TY_EXT_GRAPHIC_INST(TYAcousticBox)
TYGeometryNode TYAcousticRectangleNodeGeoNode
Noeud geometrique de type TYAcousticRectangleNode.
TYGeometryNode TYAcousticSurfaceGeoNode
Noeud geometrique de type TYAcousticSurface.
std::vector< LPTYAcousticSurface > TYTabLPAcousticSurface
Tableau de TYAcousticSurfaces.
std::vector< LPTYAcousticSurfaceGeoNode > TYTabAcousticSurfaceGeoNode
Collection de noeuds geometriques de type TYAcousticSurface.
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
std::vector< OVector3D > TYTabVector
Collection de OVector3D.
Definition: TYDefines.h:398
std::vector< LPTYPolygon > TYTabLPPolygon
Collection de pointeurs de TYPolygon.
Definition: TYDefines.h:349
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:344
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
const char * name
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
The 4x4 matrix class.
Definition: 3d.h:625
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
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
OSpectreAbstract & sum(const OSpectreAbstract &spectre) const
Arithmetic sum of two spectrums in one-third Octave.
Definition: spectre.cpp:224
OSpectreAbstract & toGPhy() const
Converts to physical quantity.
Definition: spectre.cpp:642
void setType(TYSpectreType type)
Set the spectrum type.
Definition: spectre.h:153
double sigma()
Sum the values of the spectrum.
Definition: spectre.cpp:558
OSpectreAbstract & toDB() const
Converts to dB.
Definition: spectre.cpp:595
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
Spectrum class.
Definition: Spectre.h:25
virtual void remAllSrcs()
virtual int addRegime()
virtual bool remRegime(int regime)
virtual TYTabPoint sommets() const
virtual int isInside(const TYPoint &pt) const
void setFace(const LPTYAcousticRectangleNode pAccRect, int numFace)
virtual TYTabAcousticSurfaceGeoNode acousticFaces()
virtual TYTabLPPolygon faces() const
virtual TYPoint centreGravite() const
LPTYAcousticRectangleNodeGeoNode getFace(int numFace)
virtual void propagateAtt(LPTYAttenuateur pAtt)
void setDimension(float larg, float lon, float haut)
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
virtual TYTabVector normals() const
void getDimension(float &larg, float &lon, float &haut)
virtual ~TYAcousticBox()
virtual void loadRegime(int regimeNb=-1)
virtual void distriSrcs()
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
TYTabLPAcousticSurface getSubFace()
virtual double activeSurface() const
TYAcousticRectangleNode * getFaceElement(unsigned long index) const
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
bool operator!=(const TYAcousticBox &other) const
Operateur !=.
virtual bool findAcousticSurface(const TYAcousticSurface *pAccSurf, OMatrix *pMatrix=0)
virtual TYBox volEnglob() const
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
TYAcousticBox & operator=(const TYAcousticBox &other)
Operateur =.
LPTYAcousticRectangleNodeGeoNode _faces[6]
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=false)
virtual void setRegimeName(const QString &name)
virtual void setCurRegime(int regime)
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
virtual void setDensiteSrcsV(double densite, bool recursif=true)
bool operator==(const TYAcousticBox &other) const
Operateur ==.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual void setNextRegimeNb(const int &next)
virtual void setDensiteSrcsH(double densite, bool recursif=true)
virtual int fromXML(DOM_Element domElement)
bool updateAcoustic(const bool &force=false)
virtual std::string toString() const
virtual double surface() const
virtual TYSourcePonctuelle srcPonctEquiv() const
virtual bool setSrcsLw()
virtual double volume() const
virtual DOM_Element toXML(DOM_Element &domElement)
double getDensiteSrcsH() const
virtual void setDensiteSrcsH(double densite, bool recursif=true)
TYRegime & getRegimeNb(const int &nb, bool &status)
double getDensiteSrcsV() const
int _curRegime
Numero du regime de fonctionnement courant.
int _typeDistribution
Indique le type de distribution a utiliser. pour l'etat courant.
virtual void loadRegime(int regimeNb=-1)
TYSpectre & getCurrentSpectre()
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 bool remRegime(int regime)
bool _isRayonnant
Etat courant de l'element (rayonnant ou non rayonnant)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
virtual void setSize(float sizeX, float sizeY)
virtual void setDensiteSrcsV(double densite, bool recursif=true)
virtual void setDensiteSrcsH(double densite, bool recursif=true)
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
TYSpectre setGlobalLW(const TYSpectre &spectre, const double &surfGlobale, const int &regime=-1)
virtual void setNextRegimeNb(const int &next)
virtual void setCurRegime(int regime)
virtual void propagateAtt(LPTYAttenuateur pAtt)
virtual void setRegimeName(const QString &name)
virtual void loadRegime(int regimeNb=-1)
virtual double surface() const
virtual bool remRegime(int regime)
virtual bool updateAcoustic(const bool &force=false)
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=false)
TYTabAcousticSurfaceGeoNode & getTabAcousticSurf()
LPTYAcousticVolumeGeoNode findAcousticVol(const LPTYAcousticVolume pAccVol)
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 setIsRayonnant(bool rayonnant=true, bool recursif=true)
virtual void inverseNormales()
Definition: TYBox.h:34
int isInside(const TYPoint &pt) const
Definition: TYBox.cpp:236
OColor getColor() const
virtual void setColor(const OColor &color)
void setName(QString name)
Definition: TYElement.h:678
QString _name
Nom courant de l'element.
Definition: TYElement.h:965
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:542
virtual QString getName() const
Definition: TYElement.h:691
TYElement * _pParent
Reference sur l'element parent.
Definition: TYElement.h:968
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYElement.h:530
void setParent(TYElement *pParent)
Definition: TYElement.h:699
virtual void setIsGeometryModified(bool isModified)
Definition: TYElement.cpp:253
const ORepere3D & getORepere3D() const
virtual DOM_Element toXML(DOM_Element &domElement)
void setElement(LPTYElement pElt)
TYElement * getElement() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
OMatrix getMatrix() const
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
void setRepere(const ORepere3D &repere)
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
void transform(const OMatrix &matrix)
Definition: TYPolygon.cpp:417
float getSizeX()
TYPoint _pts[4]
Sommets.
Definition: TYRectangle.h:274
TYPolygon * toPolygon() const
virtual OVector3D normal() const
float getSizeY()
void setRegimeName(const QString &nom)
Definition: TYRegime.h:78
static TYSpectre getEmptyLinSpectre(const double &valInit=1.0E-20)
Cree un spectre en lin.
Definition: TYSpectre.cpp:451
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
virtual TYBox volEnglob() const
void calculRayonSphere(const TYBox &volEnglob)
virtual void calculCentreGravite()
std::string intToStr(int val)
Definition: macros.h:158
@ SPECTRE_TYPE_LW
Definition: spectre.h:30