Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticBox.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #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  pElement = TYAcousticRectangleNode::safeDownCast(_faces[0]->getElement());
135  repere = _faces[0]->getORepere3D();
136  repere._origin._x = demiLarg;
137  _faces[0]->setRepere(repere);
138  pElement->setSize(lon, haut);
139  _faces[0]->setIsGeometryModified(true);
140 
141  pElement = TYAcousticRectangleNode::safeDownCast(_faces[2]->getElement());
142  repere = _faces[2]->getORepere3D();
143  repere._origin._x = -demiLarg;
144  _faces[2]->setRepere(repere);
145  pElement->setSize(lon, haut);
146  _faces[2]->setIsGeometryModified(true);
147 
148  pElement = TYAcousticRectangleNode::safeDownCast(_faces[1]->getElement());
149  repere = _faces[1]->getORepere3D();
150  repere._origin._y = -demiLon;
151  _faces[1]->setRepere(repere);
152  pElement->setSize(larg, haut);
153  _faces[1]->setIsGeometryModified(true);
154 
155  pElement = TYAcousticRectangleNode::safeDownCast(_faces[3]->getElement());
156  repere = _faces[3]->getORepere3D();
157  repere._origin._y = demiLon;
158  _faces[3]->setRepere(repere);
159  pElement->setSize(larg, haut);
160  _faces[3]->setIsGeometryModified(true);
161 
162  pElement = TYAcousticRectangleNode::safeDownCast(_faces[4]->getElement());
163  repere = _faces[4]->getORepere3D();
164  repere._origin._z = -demiHaut;
165  _faces[4]->setRepere(repere);
166  pElement->setSize(larg, lon);
167  _faces[4]->setIsGeometryModified(true);
168 
169  pElement = TYAcousticRectangleNode::safeDownCast(_faces[5]->getElement());
170  repere = _faces[5]->getORepere3D();
171  repere._origin._z = demiHaut;
172  _faces[5]->setRepere(repere);
173  pElement->setSize(larg, lon);
174  _faces[5]->setIsGeometryModified(true);
175 
176  _volEnglob = volEnglob();
177  if (_pParent)
178  {
179  TYAcousticVolumeNode::safeDownCast(_pParent)->updateVolEnglob();
180  } // Informe le parent de se mettre a jour
181 
184 
185  setIsGeometryModified(true);
186 }
187 
188 void TYAcousticBox::getDimension(float& larg, float& lon, float& haut)
189 {
190  LPTYAcousticRectangleNode pElement;
191 
192  pElement = TYAcousticRectangleNode::safeDownCast(getFace(1)->getElement());
193  larg = pElement->getBoundingRect()->getSizeX();
194  pElement = TYAcousticRectangleNode::safeDownCast(getFace(0)->getElement());
195  lon = pElement->getBoundingRect()->getSizeX();
196  haut = pElement->getBoundingRect()->getSizeY();
197 }
198 
199 void TYAcousticBox::setFace(const LPTYAcousticRectangleNode pAccRect, int numFace)
200 {
201  _faces[numFace]->setElement((LPTYElement)pAccRect);
202  _faces[numFace]->setParent(this);
203 
204  _volEnglob = volEnglob();
205  if (_pParent)
206  {
207  TYAcousticVolumeNode::safeDownCast(_pParent)->updateVolEnglob();
208  } // Informe le parent de se mettre a jour
209 
212 
213  setIsGeometryModified(true);
214 }
215 
217 {
218  if (this != &other)
219  {
221  for (int i = 0; i < 6; i++)
222  {
223  _faces[i] = other._faces[i];
224  }
225  }
226 
227  _volEnglob = volEnglob();
230 
231  return *this;
232 }
233 
234 bool TYAcousticBox::operator==(const TYAcousticBox& other) const
235 {
236  if (this != &other)
237  {
238  if (TYAcousticVolume::operator!=(other))
239  {
240  return false;
241  }
242  for (int i = 0; i < 6; i++)
243  if (_faces[i] != other._faces[i])
244  {
245  return false;
246  }
247  }
248  return true;
249 }
250 
251 bool TYAcousticBox::operator!=(const TYAcousticBox& other) const
252 {
253  return !operator==(other);
254 }
255 
256 bool TYAcousticBox::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
257 {
258  if (!TYAcousticVolume::deepCopy(pOther, copyId))
259  {
260  return false;
261  }
262 
263  for (int i = 0; i < 6; i++)
264  {
265  _faces[i]->deepCopy(((TYAcousticBox*)pOther)->getFace(i), copyId);
266  _faces[i]->getElement()->setParent(this);
267  _faces[i]->setParent(this);
268  }
269 
270  _volEnglob = volEnglob();
273 
274  return true;
275 }
276 
277 std::string TYAcousticBox::toString() const
278 {
279  return "TYAcousticBox";
280 }
281 
283 {
284  DOM_Element domNewElem = TYAcousticVolume::toXML(domElement);
285 
286  for (int i = 0; i < 6; i++)
287  {
288  _faces[i]->toXML(domNewElem);
289  }
290 
291  return domNewElem;
292 }
293 
295 {
296  TYAcousticVolume::fromXML(domElement);
297 
298  int faceNb = 0;
299  unsigned int i = 0;
300  DOM_Element elemCur;
301  QDomNodeList childs = domElement.childNodes();
302 
303  for (i = 0; i < childs.length(); i++)
304  {
305  elemCur = childs.item(i).toElement();
306  if (faceNb < 6)
307  {
308  // Increment l'indice si la face est trouvee
309  if (_faces[faceNb]->callFromXMLIfEqual(elemCur))
310  {
311  faceNb++;
312  }
313  }
314  }
315 
316  // ------- A SUPPRIMER LORSQUE TOUT LES XML AURONT LES INFOS DE COULEUR -------
317  //
318  // Je sais c'est pas tres beau, mais c'est pour etre compatible avec les vielles versions
319  // de l'XML pour la gestion des couleurs... Je teste la couleur pour savoir
320  // si elle est blanche, si oui, c'est possible que ce soit un ancien fichier, on applique donc
321  // une couleur par default;
322  //
323  OColor color;
324  bool allWhite = true;
325  for (faceNb = 0; faceNb < 6; ++faceNb)
326  {
327  color = TYAcousticSurfaceNode::safeDownCast(_faces[0]->getElement())->getColor();
328  if (color.r != 1.0f || color.g != 1.0f || color.b != 1.0f)
329  {
330  allWhite = false;
331  break;
332  }
333  }
334 
335  if (allWhite)
336  {
337  float r = 46.0f, g = 4.0f, b = 184.0f;
338 
339 #if TY_USE_IHM
340  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColorR"))
341  {
342  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColor", r, g, b);
343  }
344  else
345  {
346  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYAcousticBoxGraphicColor", r, g, b);
347  }
348 
349 #endif // TY_USE_IHM
350 
351  OColor color;
352  color.r = r / 255;
353  color.g = g / 255;
354  color.b = b / 255;
355 
356  setColor(color);
357 
358  for (faceNb = 0; faceNb < 6; ++faceNb)
359  {
360  TYAcousticSurfaceNode::safeDownCast(_faces[faceNb]->getElement())->setColor(color);
361  }
362 
363  // Ajout de la couleur a chaque rectangle de la face non sub.
365  for (i = 0; i < tab.size(); ++i)
366  {
367  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tab[i]->getElement());
368  if (!pAccSurf->getIsSub())
369  {
370  pAccSurf->setColor(color);
371  }
372  }
373  }
374  //
375  // ----------------------------------------------------------------------------
376 
377  _volEnglob = volEnglob();
380 
381  if (_forceNormales)
382  {
383  inverseNormales();
384  }
385 
386  return 1;
387 }
388 
389 void TYAcousticBox::getChilds(LPTYElementArray& childs, bool recursif /*=true*/)
390 {
391  TYAcousticVolume::getChilds(childs, recursif);
392 
393  for (int i = 0; i < 6; i++)
394  {
395  childs.push_back(_faces[i]);
396  childs.push_back(_faces[i]->getElement());
397  }
398 
399  if (recursif)
400  {
401  for (int i = 0; i < 6; i++)
402  {
403  _faces[i]->getChilds(childs, recursif);
404  }
405  }
406 }
407 
408 void TYAcousticBox::setRegime(TYSpectre& Spectre, int regime /*=-1*/, bool recursif /*=false*/)
409 {
410  if (recursif)
411  {
412  for (int i = 0; i < 6; i++)
413  {
414  getFaceElement(i)->setRegime(Spectre, regime, recursif);
415  }
416  }
417 
418  TYAcousticVolume::setRegime(Spectre, regime, recursif);
419 }
420 
421 void TYAcousticBox::exportCSV(std::ofstream& ofs)
422 {
423  // Export du nom de l'objet
424  ofs << getName().toLatin1().data() << '\n';
425 
426  // Export du type de l'objet
427  ofs << toString() << '\n';
428 
429  // Export des donnees acoustiques
431 
432  for (int i = 0; i < 6; i++)
433  {
434  getFaceElement(i)->exportCSV(ofs);
435  }
436 
437  ofs << '\n';
438 }
439 
440 bool TYAcousticBox::remRegime(int regime)
441 {
442  for (int i = 0; i < 6; i++)
443  {
444  getFaceElement(i)->remRegime(regime);
445  }
446 
447  return TYAcousticVolume::remRegime(regime);
448 }
449 
450 void TYAcousticBox::loadRegime(int regimeNb)
451 {
452  for (int i = 0; i < 6; i++)
453  {
454  getFaceElement(i)->loadRegime(regimeNb);
455  }
456 
458 }
459 
461 {
462  for (int i = 0; i < 6; i++)
463  {
464  getFaceElement(i)->setCurRegime(regime);
465  }
466 
468 
469  setIsAcousticModified(true);
470 }
471 /*
472 int TYAcousticBox::addRegime(const TYRegime& regime)
473 {
474  for (int i = 0; i < 6; i++)
475  {
476  getFaceElement(i)->addRegime();
477  }
478 
479  return TYAcousticInterface::addRegime(regime);
480 }
481 */
483 {
484  for (int i = 0; i < 6; i++)
485  {
487  }
488 
490 }
491 
492 void TYAcousticBox::setNextRegimeNb(const int& next)
493 {
494  _nextRegime = next;
495 
496  for (int i = 0; i < 6; i++)
497  {
499  }
500 }
501 
502 void TYAcousticBox::setRegimeName(const QString& name)
503 {
504  bool status = true;
505  TYRegime& reg = getRegimeNb(_curRegime, status);
506  if (status)
507  {
508  reg.setRegimeName(name);
509  }
510 
511  for (int i = 0; i < 6; i++)
512  {
514  }
515 }
516 
518 {
519  for (int i = 0; i < 6; i++)
520  {
521  getFaceElement(i)->propagateAtt(pAtt);
522  }
523 
525 }
526 
528 {
530 
531  // Pour chaque face
532  for (int i = 0; i < 6; i++)
533  {
535 
536  if (pElement->getIsRayonnant())
537  {
538  // Recupere l'ensemble des srcs de la face
539  TYTabSourcePonctuelleGeoNode tabChild = pElement->getSrcs();
540 
541  // Concatenation des matrices
542  OMatrix matrix = _faces[i]->getMatrix();
543  for (unsigned int j = 0; j < tabChild.size(); j++)
544  {
545  tabChild[j]->setMatrix(matrix * tabChild[j]->getMatrix());
546  }
547 
548  //...et ajoute au tableau a retourner
549  tab.insert(tab.end(), tabChild.begin(), tabChild.end());
550  }
551  }
552 
553  return tab;
554 }
555 
557 {
558  return TYSourcePonctuelle();
559 }
560 
561 void TYAcousticBox::setDensiteSrcsH(double densite, bool recursif /*=true*/)
562 {
563  TYAcousticVolume::setDensiteSrcsH(densite, recursif);
564 
565  if (recursif)
566  {
567  for (int i = 0; i < 6; i++)
568  {
570  }
571  }
572 }
573 
574 void TYAcousticBox::setDensiteSrcsV(double densite, bool recursif /*=true*/)
575 {
576  TYAcousticVolume::setDensiteSrcsV(densite, recursif);
577 
578  if (recursif)
579  {
580  for (int i = 0; i < 6; i++)
581  {
583  }
584  }
585 }
586 
588 {
589  if (_isRayonnant)
590  {
591  for (int i = 0; i < 6; i++)
592  {
593  // Si la face est rayonnante et que qu'elle a une densite de source, on lui en met...
594  if ((getFaceElement(i)->getIsRayonnant())) // && (getFaceElement(i)->getDensiteSrcs() > 0))
595  {
597  }
598  }
599  }
600 }
601 
603 {
604  // Suppression de toutes les sources pour toutes les faces
605  for (int i = 0; i < 6; i++)
606  {
608  }
609 }
610 
612 {
613  bool res = true;
614 
615  for (int i = 0; i < 6; i++)
616  {
617  // Affectation de puissance uniquement si l'element est rayonnant
618  if ((getFaceElement(i)->getIsRayonnant())) //&& (getFaceElement(i)->getDensiteSrcs() > 0))
619  {
620  res = getFaceElement(i)->setSrcsLw();
621  }
622  }
623 
624  return res;
625 }
626 
627 double TYAcousticBox::volume() const
628 {
629  double profondeur = getFaceElement(1)->getSizeX();
630 
631  // Vol = aire d'un cote x profondeur
632  return (getFaceElement(0)->surface() * profondeur);
633 }
634 
636 {
637  double ret = 0.0;
638 
639  // C'est la somme de toutes les surfaces
640  for (int i = 0; i < 6; i++)
641  {
642  ret += getFaceElement(i)->surface();
643  }
644 
645  return ret;
646 }
647 
649 {
650  double ret = 0.0;
651 
652  // C'est la somme de toutes les surfaces actives
653  for (int i = 0; i < 6; i++)
654  {
655  if (getFaceElement(i)->getIsRayonnant())
656  {
657  ret += getFaceElement(i)->activeSurface();
658  }
659  }
660 
661  return ret;
662 }
663 
665 {
666  double ret = 0.0;
667 
668  // C'est la somme de toutes les surfaces actives
669  for (int i = 0; i < 6; i++)
670  {
671  if (getFaceElement(i)->getIsRayonnant())
672  {
673  ret += getFaceElement(i)->activeSurface();
674  }
675  }
676 
677  return ret;
678 }
679 
681 {
682  TYTabVector tab;
683 
684  for (int i = 0; i < 6; i++)
685  {
686  // On recupere la normale de la face
688 
689  // On convertit la normale dans le repere du vol node
690  normal = _faces[i]->getMatrix() * normal;
691 
692  // Ajout
693  tab.push_back(normal);
694  }
695 
696  return tab;
697 }
698 
700 {
701  TYTabPoint tab;
702  TYPoint pt;
703  OMatrix matrix0 = _faces[0]->getMatrix();
704  OMatrix matrix2 = _faces[2]->getMatrix();
705 
706  tab.reserve(8);
707 
708  // Les sommets des faces 0 et 2 suffisent
709  for (int i = 0; i < 4; i++)
710  {
711  pt = getFaceElement(0)->getBoundingRect()->_pts[i];
712  pt = matrix0 * pt;
713  tab.push_back(pt);
714 
715  pt = getFaceElement(2)->getBoundingRect()->_pts[i];
716  pt = matrix2 * pt;
717  tab.push_back(pt);
718  }
719 
720  return tab;
721 }
722 
724 {
725  TYTabLPPolygon tab;
726 
727  tab.reserve(6);
728 
729  for (int i = 0; i < 6; i++)
730  {
731  // Polygon representant la face
732  TYPolygon* pPolygon = getFaceElement(i)->getBoundingRect()->toPolygon();
733 
734  // On convertit le polygon dans le repere de l'acc box
735  OMatrix matrix = _faces[i]->getMatrix();
736 
737  pPolygon->transform(matrix);
738  // Ajout du polygon
739  tab.push_back(pPolygon);
740  }
741 
742  return tab;
743 }
744 
746 {
748 }
749 
751 {
752  // Le centre de gravite se trouve au milieu du segment defini par 2 points opposes dans la box
755 
756  OVector3D vecDiagonale(pt1, pt2);
757  OVector3D vecCentreGravite = OVector3D(pt1) + (vecDiagonale * 0.5);
758 
759  return TYPoint(vecCentreGravite);
760 }
761 
762 int TYAcousticBox::intersects(const OSegment3D& seg, TYTabPoint& ptList) const
763 {
764  return TYVolumeInterface::intersects(seg, ptList);
765 }
766 
767 int TYAcousticBox::isInside(const TYPoint& pt) const
768 {
769  return _volEnglob.isInside(pt);
770 }
771 
772 bool TYAcousticBox::updateAcoustic(const bool& force) // force = false
773 {
774  /*
775  NB : On travaille sur un regime donne.
776  */
777 
778  int i = 0;
779  bool ret = true;
780 
781  // Si le volume n'est pas rayonnant, inutile de tenter de distribuer
782  // la puissance, mais ce n'est pas une raison pour bloquer le calcul
783  if (!_isRayonnant)
784  {
785  return true;
786  }
787 
788  // 1/ Recuperer la surface totale
789  double surfTotale = activeSurface();
790 
791  TYSpectre LWc = TYSpectre::getEmptyLinSpectre(); // Spectre cumule de l'ensembles des elements
792  TYSpectre LWg = getCurrentSpectre().toGPhy(); // Spectre global du regime courant
793  TYSpectre LWv; // Spectre de puissance de la face courante
794 
796 
797  for (i = 0; i < 6; i++) // Les faces ordinaires
798  {
800 
801  // Si la face est rayonnante
802  if (pFace->getIsRayonnant())
803  {
804  LWv = pFace->setGlobalLW(LWg, surfTotale);
805  LWc = LWc.sum(LWv);
806  ret &= pFace->updateAcoustic();
807  }
808  else
809  {
810  TYSpectre aTYSpectre;
811  pFace->setRegime(aTYSpectre);
812  }
813  }
814 
815  // 3 cas le derner ret==false
816 
817  if (ret && (_typeDistribution == TY_PUISSANCE_IMPOSEE))
818  {
819  // Il faut s'assurer que la somme des puissances des volumes egale la puissance de la machine
820  double residu = ABS(10 * log10(LWg.sigma()) - 10 * log10(LWc.sigma()));
821 
822  // Si l'ecart est inferieur a 1 dB on accepte
823  ret = residu < 1 ? true : false;
824  }
825  else if (ret && (_typeDistribution == TY_PUISSANCE_CALCULEE))
826  {
827  // Puissance de la machine = puissance cumulee des volumes qui la composent
830 
831  for (i = 0; i < 6; i++)
832  {
834  if (pFace->getIsRayonnant())
835  {
836  LWc = LWc.sum(pFace->getCurrentSpectre().toGPhy());
837  }
838  }
839 
840  TYSpectre temp = LWc.toDB();
841  this->setRegime(temp, -1,
842  false); // Pas de probleme la puissance attribuee au volume peut etre modifiee
843  }
844 
845  return ret;
846 }
847 
849 {
851 
852  for (int i = 0; i < 6; i++)
853  {
854  // Sous-faces pour cette face
856  OMatrix matrixFace = _faces[i]->getMatrix();
857 
858  for (unsigned int j = 0; j < tabTmp.size(); j++)
859  {
860  LPTYAcousticSurface pAccSurf = TYAcousticSurface::safeDownCast(tabTmp[j]->getElement());
861 
862  // M = M(face) . M(sous-face)
863  OMatrix matrix = matrixFace * tabTmp[j]->getMatrix();
864 
865  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement)pAccSurf, matrix));
866  }
867  }
868 
869  return tab;
870 }
871 
872 bool TYAcousticBox::findAcousticSurface(const TYAcousticSurface* pAccSurf, OMatrix* pMatrix /*=0*/)
873 {
874  bool ret = false;
875 
876  for (int i = 0; (i < 6) && !ret; i++)
877  {
878  // Sous-faces pour cette face
880 
881  for (unsigned int j = 0; j < tabTmp.size(); j++)
882  {
883  if (TYAcousticSurface::safeDownCast(tabTmp[j]._pObj->getElement()) == pAccSurf)
884  {
885  if (pMatrix)
886  {
887  // Mise a jour de la matrice
888  *pMatrix = *pMatrix * _faces[i]->getMatrix() * tabTmp[j]->getMatrix();
889  }
890 
891  // Surf trouvee
892  break;
893  }
894  }
895  }
896 
897  return ret;
898 }
899 
901 {
902  TYTabLPAcousticSurface tabSubFaces;
903 
904  // On balaye toutes les faces
905  for (int i = 0; i < 6; i++)
906  {
908 
909  for (unsigned int j = 0; j < tabSurf.size(); j++)
910  {
911  LPTYAcousticSurface pSurface = TYAcousticSurface::safeDownCast(tabSurf[j]->getElement());
912 
913  if (pSurface->getIsSub())
914  {
915  tabSubFaces.push_back(pSurface);
916  }
917  }
918  }
919 
920  return tabSubFaces;
921 }
922 
923 void TYAcousticBox::setIsRayonnant(bool rayonnant, bool recursif)
924 {
925  TYAcousticVolume::setIsRayonnant(rayonnant, recursif);
926 }
double ABS(double a)
Return the absolute value.
Definition: 3d.h:67
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:345
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
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:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
3D frame with a point and 3 vectors.
Definition: 3d.h:1211
OVector3D _vecK
Vector K for the Z axis.
Definition: 3d.h:1285
OVector3D _vecJ
Vector J for the Y axis.
Definition: 3d.h:1283
OVector3D _vecI
Vector I for the X axis.
Definition: 3d.h:1281
OPoint3D _origin
The origin point.
Definition: 3d.h:1279
Class to define a segment.
Definition: 3d.h:1089
OSpectreAbstract & sum(const OSpectreAbstract &spectre) const
Arithmetic sum of two spectrums in one-third Octave.
Definition: spectre.cpp:219
OSpectreAbstract & toGPhy() const
Converts to physical quantity.
Definition: spectre.cpp:634
void setType(TYSpectreType type)
Set the spectrum type.
Definition: spectre.h:152
double sigma()
Sum the values of the spectrum.
Definition: spectre.cpp:553
OSpectreAbstract & toDB() const
Converts to dB.
Definition: spectre.cpp:590
static OSpectre getEmptyLinSpectre(const double &valInit=1.0E-20)
Create a physical quantity spectrum.
Definition: spectre.cpp:1115
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()
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:671
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:544
virtual QString getName() const
Definition: TYElement.h:684
TYElement * _pParent
Reference sur l'element parent.
Definition: TYElement.h:969
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYElement.h:532
void setParent(TYElement *pParent)
Definition: TYElement.h:692
virtual 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