Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticCylinder.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"
19 #if TY_USE_IHM
23 #endif
24 #include "TYAcousticCylinder.h"
25 
28 
30 {
32 
33  // Couleur par default
34  float r = 255.0f, g = 67.0f, b = 133.0f;
35 
36 #if TY_USE_IHM
37  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "TYAcousticCylinderGraphicColorR"))
38  {
39  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "TYAcousticCylinderGraphicColor", r, g, b);
40  }
41  else
42  {
43  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "TYAcousticCylinderGraphicColor", r, g, b);
44  }
45 
46 #endif // TY_USE_IHM
47 
48  OColor color;
49  color.r = r / 255;
50  color.g = g / 255;
51  color.b = b / 255;
52 
53  setColor(color);
54 
56  _pEnveloppe->setParent(this);
57 
59  *_pCircTop->getShape() =
60  TYRectangle(TYPoint(-1, 1, 0.5), TYPoint(1, 1, 0.5), TYPoint(1, -1, 0.5), TYPoint(-1, -1, 0.5));
61  _pCircTop->setParent(this);
62 
65  TYRectangle(TYPoint(-1, -1, -0.5), TYPoint(1, -1, -0.5), TYPoint(1, 1, -0.5), TYPoint(-1, 1, -0.5));
66  _pCircBottom->setParent(this);
67 
72 }
73 
75 {
76  *this = other;
77 }
78 
80 
82 {
83  if (this != &other)
84  {
86  _pEnveloppe = other._pEnveloppe;
87  _pCircTop = other._pCircTop;
88  _pCircBottom = other._pCircBottom;
89  }
90 
95 
96  return *this;
97 }
98 
100 {
101  if (this != &other)
102  {
103  if (TYAcousticVolume::operator!=(other))
104  {
105  return false;
106  }
107  if (_pEnveloppe != other._pEnveloppe)
108  {
109  return false;
110  }
111  if (_pCircTop != other._pCircTop)
112  {
113  return false;
114  }
115  if (_pCircBottom != other._pCircBottom)
116  {
117  return false;
118  }
119  }
120  return true;
121 }
122 
124 {
125  return !operator==(other);
126 }
127 
128 bool TYAcousticCylinder::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
129 {
130  if (!TYAcousticVolume::deepCopy(pOther, copyId))
131  {
132  return false;
133  }
134 
135  TYAcousticCylinder* pOtherCyl = (TYAcousticCylinder*)pOther;
136 
137  _pEnveloppe->deepCopy(pOtherCyl->_pEnveloppe, copyId);
138  _pEnveloppe->setParent(this);
139  _pCircTop->deepCopy(pOtherCyl->_pCircTop, copyId);
140  _pCircTop->setParent(this);
141  _pCircBottom->deepCopy(pOtherCyl->_pCircBottom, copyId);
142  _pCircBottom->setParent(this);
143 
144  _volEnglob = volEnglob();
148 
149  return true;
150 }
151 
152 std::string TYAcousticCylinder::toString() const
153 {
154  return "TYAcousticCylinder";
155 }
156 
158 {
159  DOM_Element domNewElem = TYAcousticVolume::toXML(domElement);
160 
161  _pEnveloppe->toXML(domNewElem);
162  _pCircTop->toXML(domNewElem);
163  _pCircBottom->toXML(domNewElem);
164 
165  return domNewElem;
166 }
167 
169 {
170  TYAcousticVolume::fromXML(domElement);
171 
172  bool circTopFound = false;
173  bool circBottomFound = false;
174  bool enveloppeFound = false;
175 
176  DOM_Element elemCur;
177 
178  QDomNodeList childs = domElement.childNodes();
179  for (unsigned int i = 0; i < childs.length(); i++)
180  {
181  elemCur = childs.item(i).toElement();
182 
183  if (!enveloppeFound)
184  {
185  enveloppeFound = _pEnveloppe->callFromXMLIfEqual(elemCur);
186  }
187 
188  if (!circTopFound)
189  {
190  circTopFound = _pCircTop->callFromXMLIfEqual(elemCur);
191  }
192  else if (!circBottomFound)
193  {
194  circBottomFound = _pCircBottom->callFromXMLIfEqual(elemCur);
195  }
196  }
197 
198  if (!enveloppeFound) // Lecture d'un fichier TYMPAN 3.2
199  {
202 
203  // On ajoute autant de regime a l'enveloppe qu'il y a de regime a la machine.
204  // On prend la machine comme reference car il y a un probleme sur le modele chinon
205  // un cylindre possede 11 regimes alors que la machine n'en possede que 2.
207  size_t nbRegMachine = pMachine->getNbRegimes();
208 
209  size_t j = 0;
210  for (j = 0; j < nbRegMachine - 1; j++) // (-1) car l'enveloppe possede deja au moins un regime
211  {
213  }
214 
215  // On "construit" les regimes
216  bool statusFrom = true;
217  bool statusTo = true;
218  for (j = 0; j < _pEnveloppe->getNbRegimes(); j++)
219  {
220  TYRegime& regimeFrom = this->getRegimeNb(static_cast<int>(j), statusFrom);
221  TYRegime& regimeTo = _pEnveloppe->getRegimeNb(static_cast<int>(j), statusTo);
222 
223  if (!statusFrom || !statusTo)
224  {
225  break;
226  }
227 
228  regimeTo.deepCopy(&regimeFrom, false);
229  }
230 
232  _pEnveloppe->loadRegime(-1); // On met l'etat de l'enveloppe par rapport au regime courant
233  }
234 
235  _volEnglob = volEnglob();
239 
240  return 1;
241 }
242 
243 void TYAcousticCylinder::getChilds(LPTYElementArray& childs, bool recursif /*=true*/)
244 {
245  TYAcousticVolume::getChilds(childs, recursif);
246 
247  childs.push_back(_pCircTop);
248  childs.push_back(_pCircBottom);
249  childs.push_back(_pEnveloppe);
250 
251  if (recursif)
252  {
253  _pCircTop->getChilds(childs, recursif);
254  _pCircBottom->getChilds(childs, recursif);
255  _pEnveloppe->getChilds(childs, recursif);
256  }
257 }
258 
259 void TYAcousticCylinder::setRegime(TYSpectre& Spectre, int regime /*=-1*/, bool recursif /*=false*/)
260 {
261  if (recursif)
262  {
263  _pEnveloppe->setRegime(Spectre, regime, recursif);
264  _pCircTop->setRegime(Spectre, regime, recursif);
265  _pCircBottom->setRegime(Spectre, regime, recursif);
266  }
267 
268  TYAcousticInterface::setRegime(Spectre, regime, recursif);
269 }
270 
272 {
273  _pEnveloppe->remRegime(regime);
274  _pCircTop->remRegime(regime);
275  _pCircBottom->remRegime(regime);
276 
277  return TYAcousticVolume::remRegime(regime);
278 }
279 
281 {
282  _pEnveloppe->loadRegime(regimeNb);
283  _pCircTop->loadRegime(regimeNb);
284  _pCircBottom->loadRegime(regimeNb);
285 
287 }
288 
290 {
291  _pEnveloppe->setCurRegime(regime);
292  _pCircTop->setCurRegime(regime);
293  _pCircBottom->setCurRegime(regime);
294 
296 
297  setIsAcousticModified(true);
298 }
299 
301 {
302  _pEnveloppe->propagateAtt(pAtt);
303  _pCircTop->propagateAtt(pAtt);
304  _pCircBottom->propagateAtt(pAtt);
305 
307 }
308 /*
309 int TYAcousticCylinder::addRegime(const TYRegime& regime)
310 {
311  _pEnveloppe->addRegime();
312  _pCircTop->addRegime();
313  _pCircBottom->addRegime();
314 
315  return TYAcousticInterface::addRegime(regime);
316 }
317 */
319 {
321  _pCircTop->addRegime();
323 
325 }
326 
328 {
329  TYTabSourcePonctuelleGeoNode tab, tabTmp;
330 
331  tabTmp = _pCircBottom->getSrcs();
332  tab.insert(tab.end(), tabTmp.begin(), tabTmp.end());
333 
334  tabTmp = _pCircTop->getSrcs();
335  tab.insert(tab.end(), tabTmp.begin(), tabTmp.end());
336 
337  tabTmp = _pEnveloppe->getSrcs();
338  tab.insert(tab.end(), tabTmp.begin(), tabTmp.end());
339 
340  return tab;
341 }
342 
344 {
345  return TYSourcePonctuelle();
346 }
347 
348 void TYAcousticCylinder::setDensiteSrcsH(double densite, bool recursif /*= true*/)
349 {
350  TYAcousticVolume::setDensiteSrcsH(densite, recursif);
351 
352  if (recursif)
353  {
354  // Cercle bottom
356 
357  // Cercle top
359 
360  // Enveloppe (src surf)
362  }
363 }
364 
365 void TYAcousticCylinder::setDensiteSrcsV(double densite, bool recursif /*=true*/)
366 {
367  TYAcousticVolume::setDensiteSrcsV(densite, recursif);
368 
369  if (recursif)
370  {
371  // Cercle bottom
373 
374  // Cercle top
376 
377  // Enveloppe (src surf)
379  }
380 }
381 
383 {
384  // Suppression des sources existantes
388 }
389 
391 {
392  if (_isRayonnant == false)
393  {
394  // Pas de calcul
395  return;
396  }
397 
398  // Cercle bottom
400  {
402  }
403 
404  // Cercle top
405  if (_pCircTop->getIsRayonnant())
406  {
408  }
409 
410  // Enveloppe (src surf)
411  if (!_pEnveloppe->getIsRayonnant() || (_pEnveloppe->getDensiteSrcsH() == 0) ||
412  (_pEnveloppe->getDensiteSrcsV() == 0))
413  {
414  return;
415  }
416 
417  // On travaille directement sur la source surfacique de l'enveloppe
419 
420  // Distance angulaire (sur la circonference de chaque cercle
421  // concentrique)
422  const double distAngle = pSrcSurf->getDensiteSrcsH();
423  int nbSrcs = ROUND(M_PI * getDiameter() / distAngle);
424  nbSrcs = nbSrcs < 4 ? 4 : nbSrcs; // Au moins 4 sources sur la circonference (champ rayonne homogene)
425  const double anglePortion = M_2PI / nbSrcs;
426 
427  // Distance sur la hauteur
428  double distHauteur = pSrcSurf->getDensiteSrcsV();
429 
430  const double hauteurCyl = getHauteur();
431 
432  int nbCercle = (int)(hauteurCyl / distHauteur);
433  if (nbCercle == 0)
434  {
435  nbCercle = 1;
436  distHauteur = hauteurCyl / 2.0;
437  }
438 
439  // Si la hauteur residuelle est inferieure a la demi distance entre les cercles, on retire un cercle
440  const double HResiduel = (hauteurCyl - (distHauteur * nbCercle)) / 2.0;
441  if ((nbCercle > 1) && (HResiduel < (distHauteur / 2.0)))
442  {
443  nbCercle--;
444  }
445 
446  // Position du premier cercle en partant du bas
447  double base = (hauteurCyl - (nbCercle - 1) * distHauteur) / 2.0;
448 
449  // nombre d'iterations ((M_2PI / distAngle) + (hauteurCyl / distHauteur));
450 
451  OPoint3D pt;
452  double angle = 0.0;
453  double hauteur = base;
454  double rayon = (getDiameter() / 2.0) + _offsetSources; // decalage des sources pour le lancer de rayons
455  const double hauteurOffset = _pCircBottom->getCenter()._z;
456  OPoint3D center = _pCircBottom->getCenter();
457 
458  // To define directivity
459  double specificSize = this->getDiameter();
461 
462  // Calcul de la portion d'angle pour le cercle
463  if (anglePortion > 0.0)
464  {
465  // Parcours sur la hauteur
466  for (int i = 0; i < nbCercle; i++)
467  {
468  // Init angle
469  angle = 0.0;
470 
471  // Pour chaque portion d'angle
472  while ((angle < M_2PI))
473  {
474 
475  // Point correspondant
476  pt._x = cos(angle) * rayon;
477  pt._y = sin(angle) * rayon;
478  pt._z = hauteurOffset + hauteur;
479 
480  // Pour trouver la normale
481  center._z = pt._z;
482  OVector3D faceNormal(center, pt);
483  faceNormal.normalize();
484 
485  // Creation d'une source ponctuelle
487  pSrc->setDirectivity(new TYComputedDirectivity(faceNormal, type, specificSize));
488 
489  // Definition de sa position
490  *pSrc->getPos() = pt;
491 
492  // Definition des sources comme sources a directivite calculee
493  pSrc->setTypeRaynt(CALCULATED);
494 
495  // Ajout de la src ponct a la src surf
496  pSrcSurf->addSrc(pSrc);
497 
498  // Attribution du parent
499  // pSrc->setParent(_pEnveloppe);
500 
501  // Increment de la portion (sens horaire)
502  angle += anglePortion;
503  }
504 
505  // Increment de la hauteur
506  hauteur += distHauteur;
507  }
508  }
509 }
510 
512 {
514  {
516  }
517  if (_pCircTop->getIsRayonnant())
518  {
519  _pCircTop->setSrcsLw();
520  }
522  {
524  }
525 
526  return true;
527 }
528 
530 {
531  // Pi.Ri¿½.h
532  double rayon = getDiameter() / 2.0;
533  return (M_PI * rayon * rayon * getHauteur());
534 }
535 
537 {
538  // 2.Pi.R.(R+h)
539  double rayon = getDiameter() / 2.0;
540  return (2 * M_PI * rayon * (rayon + getHauteur()));
541 }
542 
544 {
545  double res = 0.0;
546 
548  {
549  res += _pCircBottom->surface();
550  }
551  if (_pCircTop->getIsRayonnant())
552  {
553  res += _pCircTop->surface();
554  }
556  {
557  res += _pEnveloppe->surface();
558  }
559 
560  return res;
561 }
562 
564 {
565  double res = 0.0;
566 
568  {
569  res += _pCircBottom->surface();
570  }
571  if (_pCircTop->getIsRayonnant())
572  {
573  res += _pCircTop->surface();
574  }
576  {
577  res += _pEnveloppe->surface();
578  }
579 
580  return res;
581 }
582 
584 {
585  TYTabVector tab;
586 
587  tab.push_back(_pCircBottom->getShape()->normal());
588  tab.push_back(_pCircTop->getShape()->normal());
589 
590  TYTabRectangle tabRect = getEnveloppe();
591  for (unsigned int i = 0; i < tabRect.size(); i++)
592  {
593  tab.push_back(tabRect[i].normal());
594  }
595 
596  return tab;
597 }
598 
600 {
601  TYTabPoint tab;
602 
603  TYTabRectangle tabRect = getEnveloppe();
604  tab.reserve(tabRect.size() * 4);
605 
606  // Chaque rectangle
607  for (unsigned int i = 0; i < tabRect.size(); i++)
608  {
609  // Chaque point du rectangle
610  for (int j = 0; j < 4; j++)
611  {
612  // Ajout du sommet au tableau
613  tab.push_back(tabRect[i]._pts[j]);
614  }
615  }
616 
617  return tab;
618 }
619 
621 {
622  TYTabLPPolygon tab;
623 
624  TYTabRectangle enveloppe = getEnveloppe();
625  for (unsigned int i = 0; i < enveloppe.size(); i++)
626  {
627  tab.push_back(enveloppe[i].toPolygon());
628  }
629 
630  tab.push_back(_pCircBottom->getBoundingRect()->toPolygon());
631  tab.push_back(_pCircTop->getBoundingRect()->toPolygon());
632 
633  return tab;
634 }
635 
637 {
639 }
640 
642 {
643  return getCenter();
644 }
645 
647 {
648  return TYVolumeInterface::intersects(seg, ptList);
649 }
650 
652 {
653  int res = INTERS_NULLE;
654 
655  // Test de la position du point par rapport au vol englob
656  if (_volEnglob.isInside(pt) == INTERS_NULLE)
657  {
658  return res;
659  }
660 
661  // Le point doit verifier Xi¿½+Yi¿½ < Ri¿½ pour Z a l'interieur
662  // du cylindre (Le cylindre ne doit pas etre un ci¿½ne...)
663  // La verification de l'appartenance au cone infini est
664  // suffisante car on a deja teste si le point est compris
665  // entre les plan haut et bas du cylindre (boi¿½te englobante)
666 
667  // Obtention de la matrice de changement de repere
669  repere._origin = getCenter();
670 
671  // On passe dans le repere du cylindre pour travailler en 2D
672  OPoint3D ptCopy = repere.asMatrix() * pt;
673 
674  // Test Xi¿½ + Yi¿½ <= Ri¿½
675  double rayon = getDiameter() / 2.0;
676  if ((ptCopy._x * ptCopy._x) + (ptCopy._y * ptCopy._y) <= (rayon * rayon))
677  {
678  // Le point est a l'interieur du cylindre
679  res = INTERS_OUI;
680  }
681 
682  return res;
683 }
684 
686 {
688 
689  // Circ top
690  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement&)_pCircTop));
691  // Circ bottom
692  tab.push_back(new TYAcousticSurfaceGeoNode((LPTYElement&)_pCircBottom));
693 
694  // Enveloppe
695  // Resolution pour l'enveloppe
696  int resolution = TYDEFAULTRESOLUTIONIONCIRCLE;
697 
698 #if TY_USE_IHM
699  // static const char prefName[] = "ResolutionCircle";
700 
701  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ResolutionCircle"))
702  {
703  resolution = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle");
704  }
705  else
706  {
707  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "ResolutionCircle", resolution);
708  }
709 #endif // TY_USE_IHM
710 
711  TYTabRectangle enveloppe = getEnveloppe(resolution);
712  TYAcousticRectangle* pEnvElt = NULL;
713 
714  for (unsigned int i = 0; i < enveloppe.size(); i++)
715  {
716  // Element de l'enveloppe
717  pEnvElt = new TYAcousticRectangle();
718  pEnvElt->setParent(this);
720 
721  // Geometrie
722  *pEnvElt->getShape() = enveloppe[i];
723 
724  // Acoustique
725  // pEnvElt->setSrcSurf(_pEnveloppe->getSrcSurf());
726 
727  // Ajout
728  tab.push_back(new TYAcousticSurfaceGeoNode(pEnvElt));
729  }
730 
731  return tab;
732 }
733 
735 {
736  bool ret = false;
737 
738  if (((TYAcousticSurface*)_pCircBottom._pObj == pAccSurf) ||
739  ((TYAcousticSurface*)_pCircTop._pObj == pAccSurf))
740  {
741  // Pas de changement de repere pour ces surfaces
742  ret = true;
743  }
744 
745  return ret;
746 }
747 
749 {
750  return _pCircBottom->getDiameter();
751 }
752 
753 void TYAcousticCylinder::setDiameter(double diameter)
754 {
755  _pCircBottom->setDiameter(diameter);
756  _pCircTop->setDiameter(diameter);
757 
758  _volEnglob = volEnglob();
759  if (_pParent)
760  {
761  TYAcousticVolumeNode::safeDownCast(_pParent)->updateVolEnglob();
762  } // Informe le parent de se mettre a jour
763 
765 
767 
768  // Recalcul de la surface de l'enveloppe affectee au rectangle associe a l'acousticsurface
770 
771  setIsGeometryModified(true);
772 }
773 
775 {
777 }
778 
779 void TYAcousticCylinder::setHauteur(double hauteur)
780 {
781  // On attribue +hauteur/2 au cercle du dessus
782  // et -hauteur/2 au cercle du dessous
783  // On calcul en fait des facteurs en fonction de la taille actuelle
784  // Les vecteurs obtenus font abstraction de la position du cylindre
785 
786  // Cercle top
787  OVector3D vecTop(getCenter(), _pCircTop->getCenter());
788  vecTop = vecTop * (((hauteur / 2.0) / vecTop.norme()) - 1.0);
789 
790  // Cercle bottom
791  OVector3D vecBottom(getCenter(), _pCircBottom->getCenter());
792  vecBottom = vecBottom * (((hauteur / 2.0) / vecBottom.norme()) - 1.0);
793 
794  // Pour chaque point
795  for (int i = 0; i < 4; i++)
796  {
797  // On applique le vecteur facteur
798  _pCircTop->getShape()->_pts[i] = OVector3D(_pCircTop->getShape()->_pts[i]) + vecTop;
799  _pCircBottom->getShape()->_pts[i] = OVector3D(_pCircBottom->getShape()->_pts[i]) + vecBottom;
800  }
801 
802  _volEnglob = volEnglob();
803  if (_pParent)
804  {
805  TYAcousticVolumeNode::safeDownCast(_pParent)->updateVolEnglob();
806  } // Informe le parent de se mettre a jour
807 
810 
811  // Recalcul de la surface de l'enveloppe affectee au rectangle associe a l'acousticsurface
813 
814  setIsGeometryModified(true);
815 }
816 
818 {
819  TYTabRectangle tab;
820 
821  if (n == -1)
822  {
823  // Prise en compte de la precision
824  n = ROUND((getDiameter() / 2.0) / TYPRECISIONCIRCLE);
825 
826  // On veut au moins tous les Pi/2 (90i¿½)
827  n = ROUND(n / 4 * 4);
828  }
829 
830  if (n < 3)
831  {
832  return tab;
833  }
834 
835  // Obtention des contours des cercles top et bottom
836  // (Le nombre de points generes doit etre le meme)
837  TYTabPoint tabPtBottom = _pCircBottom->getContour(n);
838  TYTabPoint tabPtTop = _pCircTop->getContour(n);
839 
840  // On genere une face pour chaque couple de points top bottom
841  for (int i = 0; i < n; i++)
842  {
843  TYRectangle rect(tabPtTop[(i + 1) % n], tabPtTop[i], tabPtBottom[(n - i) % n],
844  tabPtBottom[n - i - 1]);
845  tab.push_back(rect);
846  }
847 
848  return tab;
849 }
850 
852 {
853  // Le centre du cylindre est la mi-hauteur entre les centres des 2 cercles
855  return (OVector3D(_pCircBottom->getCenter()) + (vec * 0.5));
856 }
857 
858 bool TYAcousticCylinder::updateAcoustic(const bool& force) // force = false
859 {
860  /*
861  NB : On travaille sur un regime donne.
862  */
863 
864  bool ret = true;
865 
866  // Si le volume n'est pas rayonnant, inutile de tenter de distribuer
867  // la puissance, mais ce n'est pas une raison pour bloquer le calcul
868  if (!_isRayonnant)
869  {
870  return true;
871  }
872 
873  // 1/ Recuperer la surface totale
874  double surfTotale = this->activeSurface();
875 
876  OSpectre LWc = OSpectre::getEmptyLinSpectre(); // Spectre cumule de l'ensemble des elements
877  OSpectre LWg = getCurrentSpectre().toGPhy(); // Spectre global du regime courant
878  OSpectre LWv; // Spectre de puissance de la face courante
879 
880  LWc.setType(SPECTRE_TYPE_LW); // LWc represente une puissance
881 
882  if (_pCircTop->getIsRayonnant())
883  {
884  LWv = _pCircTop->setGlobalLW(LWg, surfTotale);
885  LWc = LWc.sum(LWv);
886  }
887  else
888  {
889  TYSpectre aTYSpectre;
890  _pCircTop->setRegime(aTYSpectre);
891  }
892 
894  {
895  LWv = _pCircBottom->setGlobalLW(LWg, surfTotale);
896  LWc = LWc.sum(LWv);
897  }
898  else
899  {
900  TYSpectre aTYSpectre;
901  _pCircBottom->setRegime(aTYSpectre);
902  }
903 
905  {
906  LWv = _pEnveloppe->setGlobalLW(LWg, surfTotale);
907  LWc = LWc.sum(LWv);
908  }
909  else
910  {
911  TYSpectre aSpectre;
912  _pEnveloppe->setRegime(aSpectre);
913  }
914 
916  {
917  // Il faut s'assurer que la somme des puissances des volumes egale la puissance de la machine
918  double residu = ABS(10 * log10(LWg.sigma()) - 10 * log10(LWc.sigma()));
919 
920  // Si l'ecart est inferieur a 1 dB on accepte
921  ret = residu < 1 ? true : false;
922  }
924  {
927 
928  if (_pCircTop->getIsRayonnant())
929  {
930  LWc = LWc.sum(_pCircTop->getCurrentSpectre().toGPhy());
931  }
933  {
934  LWc = LWc.sum(_pCircBottom->getCurrentSpectre().toGPhy());
935  }
937  {
938  LWc = LWc.sum(_pEnveloppe->getCurrentSpectre().toGPhy());
939  }
940 
941  TYSpectre temp = LWc.toDB();
942  setRegime(temp, -1, false); // Pas de problemes, la puissance peut etre modifiee
943  ret = true;
944  }
945 
946  if (_pParent && _pParent->isA("TYBatiment"))
947  {
948  // Dans le cas des machine, cette operation est pilotee par TYAcousticVolumeNode
949  distriSrcs();
950  setSrcsLw();
951  }
952 
953  return ret;
954 }
955 
957 {
958  TYTabLPAcousticSurface tabSubFaces;
959 
960  // On balaye toutes les faces
962  for (unsigned int j = 0; j < tabFaces.size(); j++)
963  {
964  if (TYAcousticSurface::safeDownCast(tabFaces[j]->getElement())->getIsSub())
965  {
966  tabSubFaces.push_back(TYAcousticSurface::safeDownCast(tabFaces[j]->getElement()));
967  }
968  }
969 
970  return tabSubFaces;
971 }
972 
973 void TYAcousticCylinder::setIsRayonnant(bool rayonnant /*= true*/, bool recursif /*=true*/)
974 {
975  TYAcousticVolume::setIsRayonnant(rayonnant, recursif);
976 }
977 
979 {
980  _nextRegime = next;
981 
982  // Surface du dessus
983  _pCircTop->setNextRegimeNb(next);
986  // Enveloppe
988 }
989 
991 {
993 
994  // Surface du dessus
998  // Enveloppe
1000 }
1001 
1003 {
1004  double sizeRectangle = sqrt(getDiameter() * M_PI * getHauteur()); // = 2.pi.r.h
1005  _pEnveloppe->getBoundingRect()->setDimension(sizeRectangle, sizeRectangle);
1006 }
1007 
1008 void TYAcousticCylinder::exportCSV(std::ofstream& ofs)
1009 {
1010  // Export du nom de l'objet
1011  ofs << getName().toLatin1().data() << '\n';
1012 
1013  // Export du type de l'objet
1014  ofs << toString() << '\n';
1015 
1016  // Export des donnees acoustiques
1018 
1019  _pCircTop->exportCSV(ofs);
1020  _pCircBottom->exportCSV(ofs);
1021  _pEnveloppe->exportCSV(ofs);
1022 }
#define M_2PI
2Pi.
Definition: 3d.h:55
int ROUND(double a)
Compute the rounded value of a number.
Definition: 3d.h:192
#define INTERS_OUI
The intersection exists.
Definition: 3d.h:33
double ABS(double a)
Return the absolute value.
Definition: 3d.h:67
#define INTERS_NULLE
No intersection.
Definition: 3d.h:35
QDomElement DOM_Element
Definition: QT2DOM.h:30
Representation graphique d'un cylindre accoustique (fichier header)
outil IHM pour un cylindre acoustique (fichier header)
TY_EXTENSION_INST(TYAcousticCylinder)
TY_EXT_GRAPHIC_INST(TYAcousticCylinder)
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< TYRectangle > TYTabRectangle
Collection de TYRectangle.
Definition: TYDefines.h:346
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
#define TYDEFAULTRESOLUTIONIONCIRCLE
Resolution par defaut pour la representation des cercles par des segments.
Definition: TYDefines.h:415
#define TYPRECISIONCIRCLE
Precision pour la representation des cercles par des segments.
Definition: TYDefines.h:412
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.
@ CALCULATED
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
bool isA(const char *className) const
Definition: TYElement.cpp:65
3D frame with a point and 3 vectors.
Definition: 3d.h:1211
OPoint3D _origin
The origin point.
Definition: 3d.h:1279
OMatrix asMatrix() const
return the transformation matrix from unity to this pose such as this = transform * unity
Definition: 3d.cpp:1462
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
double norme() const
Computes the length of this vector.
Definition: 3d.cpp:215
void normalize()
Normalizes this vector.
Definition: 3d.cpp:225
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
Spectrum class.
Definition: Spectre.h:25
TYRectangle * getShape()
virtual double surface() const
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
void setDiameter(double diameter)
TYPoint getCenter() const
virtual void distriSrcs()
virtual DOM_Element toXML(DOM_Element &domElement)
virtual TYTabPoint getContour(int n=-1) const
double getDiameter() const
virtual bool setSrcsLw()
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual TYTabPoint sommets() const
bool operator==(const TYAcousticCylinder &other) const
Operateur ==.
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
TYTabLPAcousticSurface getSubFace()
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual int isInside(const TYPoint &pt) const
virtual std::string toString() const
LPTYAcousticCircle _pCircBottom
Surface de dessous.
bool operator!=(const TYAcousticCylinder &other) const
Operateur !=.
virtual void setDensiteSrcsV(double densite, bool recursif=true)
virtual TYPoint getCenter() const
virtual double surface() const
virtual bool remRegime(int regime)
virtual void setCurRegime(int regime)
virtual TYTabVector normals() const
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
virtual TYSourcePonctuelle srcPonctEquiv() const
void setHauteur(double hauteur)
virtual TYPoint centreGravite() const
virtual int fromXML(DOM_Element domElement)
virtual void setDensiteSrcsH(double densite, bool recursif=true)
virtual void setRegime(TYSpectre &Spectre, int regime=-1, bool recursif=false)
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
LPTYAcousticSurface _pEnveloppe
Enveloppe.
virtual void propagateAtt(LPTYAttenuateur pAtt)
virtual TYTabLPPolygon faces() const
void setDiameter(double diameter)
virtual void loadRegime(int regimeNb=-1)
virtual void setNextRegimeNb(const int &next)
virtual TYTabRectangle getEnveloppe(int n=-1) const
virtual double volume() const
virtual double activeSurface() const
bool updateAcoustic(const bool &force=false)
double getDiameter() const
virtual DOM_Element toXML(DOM_Element &domElement)
virtual bool findAcousticSurface(const TYAcousticSurface *pAccSurf, OMatrix *pMatrix=0)
virtual void setRegimeName(const QString &name)
virtual TYTabAcousticSurfaceGeoNode acousticFaces()
LPTYAcousticCircle _pCircTop
Surface de dessus.
virtual TYBox volEnglob() const
TYAcousticCylinder & operator=(const TYAcousticCylinder &other)
Operateur =.
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
double _densiteSrcsV
Densite verticale de sources.
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 _typeDistribution
Indique le type de distribution a utiliser. pour l'etat courant.
double _offsetSources
Offset de decalage des sources ponctuelles sur les surfaces.
virtual void loadRegime(int regimeNb=-1)
TYSpectre & getCurrentSpectre()
virtual int addRegime(const TYRegime &regime)
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.
double _densiteSrcsH
Densite horizontale de sources.
virtual bool remRegime(int regime)
virtual void setRegimeName(const QString &name)
bool _isRayonnant
Etat courant de l'element (rayonnant ou non rayonnant)
TYRectangle * getShape()
virtual void setDensiteSrcsV(double densite, bool recursif=true)
virtual void remAllSrcs()
virtual void setCurRegime(int regime)
virtual double surface() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual void propagateAtt(LPTYAttenuateur pAtt)
virtual TYTabSourcePonctuelleGeoNode getSrcs() const
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)
LPTYSourceSurfacic getSrcSurf()
virtual void setDensiteSrcsH(double densite, bool recursif=true)
virtual bool setSrcsLw()
TYRectangle * getBoundingRect()
virtual DOM_Element toXML(DOM_Element &domElement)
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)
virtual void setIsRayonnant(bool rayonnant=true, bool recursif=true)
Definition: TYBox.h:34
int isInside(const TYPoint &pt) const
Definition: TYBox.cpp:236
virtual void setColor(const OColor &color)
TYElement * getParent() const
Definition: TYElement.h:699
virtual bool isInCurrentCalcul()
Definition: TYElement.h:541
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 setInCurrentCalcul(bool state, bool recurschild=true, bool recursparent=true)
Definition: TYElement.cpp:410
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
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
ORepere3D getORepere3D() const
void setDimension(float lon, float haut)
TYPoint _pts[4]
Sommets.
Definition: TYRectangle.h:274
TYPolygon * toPolygon() const
virtual OVector3D normal() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYRegime.cpp:99
void setDirectivity(TYDirectivity *directivity_)
: Get/Set directivity to source
void setTypeRaynt(TYTypeRaynt type)
double getDensiteSrcsH() const
bool addSrc(LPTYSourcePonctuelle pSrcPonct)
double getDensiteSrcsV() const
virtual int intersects(const OSegment3D &seg, TYTabPoint &ptList) const
virtual TYBox volEnglob() const
void calculRayonSphere(const TYBox &volEnglob)
virtual void calculCentreGravite()
#define M_PI
Pi.
Definition: color.cpp:25
@ SPECTRE_TYPE_LW
Definition: spectre.h:30