Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYCalcul.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 #ifdef _MSC_VER
17  #pragma warning(disable : 4786)
18 #endif
19 
20 #include <math.h>
21 #include <stdlib.h>
22 #include <string>
23 
24 #include "Tympan/core/defines.h"
25 #include "Tympan/core/logging.h"
30 #include "Tympan/models/business/DefaultSolverConfig.h"
33 
34 #if TY_USE_IHM
37 #endif
38 
41 
42 #define TR(id) OLocalizator::getString("OMessageManager", (id))
43 
44 #define MAX_SOURCES 1024
45 #define MAX_RECEPTEURS 131072
46 
48  : solverParams(DEFAULT_SOLVER_CONFIG), _solverId(OGenID("{A98B320C-44C4-47a9-B689-1DD352DAA8B2}")),
49  _numero(1), _auteur("Auteur"), _dateCreation("2001-10-01"), _dateModif("2001-10-01"),
50  _comment("Commentaire"), _upTodate(true), _state(TYCalcul::Actif), _pResultat(new TYResultat()),
51  _hasResuCtrlPnts(false)
52 {
54  _pResultat->setParent(this);
55 }
56 
58 {
59  *this = other;
60 }
61 
63 {
64  purge();
65 }
66 
68 {
70 }
71 
73 {
74  _tabRays.clear();
75  if (this != &other)
76  {
77  TYElement::operator=(other);
78  _numero = other._numero;
79  _auteur = other._auteur;
81  _dateModif = other._dateModif;
82  _comment = other._comment;
83  _upTodate = other._upTodate;
84  _state = other._state;
85  //_maillages = other._maillages;
86  _pResultat = other._pResultat;
90  _solverId = other._solverId;
91  _tabRays = other._tabRays;
92  solverParams = other.solverParams;
94  }
95 
96  return *this;
97 }
98 
99 bool TYCalcul::operator==(const TYCalcul& other) const
100 {
101  if (this != &other)
102  {
103  if (TYElement::operator!=(other))
104  {
105  return false;
106  }
107  if (_auteur != other._auteur)
108  {
109  return false;
110  }
111  if (_dateCreation != other._dateCreation)
112  {
113  return false;
114  }
115  if (_dateModif != other._dateModif)
116  {
117  return false;
118  }
119  if (_comment != other._comment)
120  {
121  return false;
122  }
123  if (_numero != other._numero)
124  {
125  return false;
126  }
127  if (_upTodate != other._upTodate)
128  {
129  return false;
130  }
131  if (_state != other._state)
132  {
133  return false;
134  }
135  // if (_maillages != other._maillages) { return false; }
136  if (_pResultat != other._pResultat)
137  {
138  return false;
139  }
140  if (_emitAcVolNode != other._emitAcVolNode)
141  {
142  return false;
143  }
145  {
146  return false;
147  }
149  {
150  return false;
151  }
153  {
154  return false;
155  }
156  if (_solverId != other._solverId)
157  {
158  return false;
159  }
160  if (_tabRays != other._tabRays)
161  {
162  return false;
163  }
164  if (_hasResuCtrlPnts != other._hasResuCtrlPnts)
165  {
166  return false;
167  }
168  }
169  return true;
170 }
171 
172 bool TYCalcul::operator!=(const TYCalcul& other) const
173 {
174  return !operator==(other);
175 }
176 
177 bool TYCalcul::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
178 {
179  if (!TYElement::deepCopy(pOther, copyId, true))
180  {
181  return false;
182  }
183 
184  purge();
185 
186  TYCalcul* pOtherCalcul = (TYCalcul*)pOther;
187 
188  // copie du parent
189  _pParent = pOther->getParent();
190 
191  _numero = pOtherCalcul->_numero;
192  _auteur = pOtherCalcul->_auteur;
193  _dateCreation = pOtherCalcul->_dateCreation;
194  _dateModif = pOtherCalcul->_dateModif;
195  _comment = pOtherCalcul->_comment;
196  _upTodate = pOtherCalcul->_upTodate;
197  _state = pOtherCalcul->_state;
198 
199  _pResultat->deepCopy(pOtherCalcul->_pResultat, copyId);
200 
201  _elementSelection = pOtherCalcul->_elementSelection;
202  _emitAcVolNode = pOtherCalcul->_emitAcVolNode;
203  _mapElementRegime = pOtherCalcul->_mapElementRegime;
204 
205  // Use same points but initialize spectrum
208 
209  _hasResuCtrlPnts = pOtherCalcul->_hasResuCtrlPnts;
210 
211  // Use Same NoiseMap but initialize spectrums
213 
214  _solverId = pOtherCalcul->_solverId;
215  solverParams = pOtherCalcul->solverParams;
216 
217  for (unsigned int i = 0; i < pOtherCalcul->_tabRays.size(); i++)
218  {
219  LPTYRay aRay = new TYRay();
220  aRay->deepCopy(pOtherCalcul->_tabRays.at(i), copyId);
221  _tabRays.push_back(aRay);
222  }
223 
224  return true;
225 }
226 
227 std::string TYCalcul::toString() const
228 {
229  return "TYCalcul";
230 }
231 
233 {
234  DOM_Element domNewElem = TYElement::toXML(domElement);
235 
236  if (_upTodate)
237  {
238  domNewElem.setAttribute("isUpTodate", "1");
239  }
240  else
241  {
242  domNewElem.setAttribute("isUpTodate", "0");
243  }
244 
245  TYXMLTools::addElementIntValue(domNewElem, "numero", _numero);
246  TYXMLTools::addElementStringValue(domNewElem, "auteur", _auteur);
247  TYXMLTools::addElementStringValue(domNewElem, "dateCreation", _dateCreation);
248  TYXMLTools::addElementStringValue(domNewElem, "dateModif", _dateModif);
249  TYXMLTools::addElementStringValue(domNewElem, "comment", _comment);
250  TYXMLTools::addElementStringValue(domNewElem, "solverId", _solverId.toString());
251  TYXMLTools::addElementIntValue(domNewElem, "etat", _state); // 16/08/2005 Possibilite de bloquer un calcul
252  TYXMLTools::addElementStringValue(domNewElem, "solverParams", solverParams);
253 
254  // Ajout du site node sur lequel s'effectue le calcul
255  DOM_Document domDoc = domElement.ownerDocument();
256 
257  // Selection
258  TYListID::iterator ite;
259  DOM_Element listIDNode = domDoc.createElement("ListID");
260  domNewElem.appendChild(listIDNode);
261 
262  for (ite = _elementSelection.begin(); ite != _elementSelection.end(); ++ite)
263  {
264  DOM_Element tmpNode = domDoc.createElement("Element");
265  listIDNode.appendChild(tmpNode);
266 
267  tmpNode.setAttribute("id", (*ite).toString());
268  }
269 
270  // Etats des AccVolNodes en emission
271  TYMapPtrElementBool::iterator iter3;
272  DOM_Element emissionAccVolNodesNode = domDoc.createElement("EmissionAccVolNodes");
273  domNewElem.appendChild(emissionAccVolNodesNode);
274 
275  for (iter3 = _emitAcVolNode.begin(); iter3 != _emitAcVolNode.end(); iter3++)
276  {
277  DOM_Element tmpNode = domDoc.createElement("EmissionAccVolNode");
278  emissionAccVolNodesNode.appendChild(tmpNode);
279 
280  tmpNode.setAttribute("accVolNodeId", (*iter3).first->getID().toString());
281  tmpNode.setAttribute("state", QString(intToStr((*iter3).second).c_str()));
282  }
283 
284  // Regimes associes a chaque source
285  TYMapPtrElementInt::iterator iter4;
286  DOM_Element regimeAccElementNodesNode = domDoc.createElement("RegimeAccNode");
287  domNewElem.appendChild(regimeAccElementNodesNode);
288 
289  for (iter4 = _mapElementRegime.begin(); iter4 != _mapElementRegime.end(); iter4++)
290  {
291  DOM_Element tmpNode = domDoc.createElement("RegimeAccNode");
292  regimeAccElementNodesNode.appendChild(tmpNode);
293 
294  tmpNode.setAttribute("accVolNodeId", (*iter4).first->getID().toString());
295  tmpNode.setAttribute("state", QString(intToStr((*iter4).second).c_str()));
296  }
297 
298  // Points de controle
299  DOM_Element resuRecepteursNode = domDoc.createElement("ResuCtrlPnts");
300  domNewElem.appendChild(resuRecepteursNode);
301  TYMapIdSpectre::iterator itRec;
302  for (itRec = _mapPointCtrlSpectre.begin(); itRec != _mapPointCtrlSpectre.end(); itRec++)
303  {
304  DOM_Element tmpNode = domDoc.createElement("Recepteur");
305  resuRecepteursNode.appendChild(tmpNode);
306  tmpNode.setAttribute("receptor_id", (*itRec).first.toString());
307  (*itRec).second->toXML(tmpNode);
308  }
309 
310  // Noise maps
311  DOM_Element resuNoiseMapNode = domDoc.createElement("ResuNoiseMaps");
312  domNewElem.appendChild(resuNoiseMapNode);
313  TYMapIdTabSpectre::iterator itNM;
314  for (itNM = _noiseMapsSpectrums.begin(); itNM != _noiseMapsSpectrums.end(); itNM++)
315  {
316  DOM_Element tmpNode = domDoc.createElement("NoiseMap");
317  resuNoiseMapNode.appendChild(tmpNode);
318  tmpNode.setAttribute("noise_map_id", (*itNM).first.toString());
319  for (unsigned int i = 0; i < (*itNM).second.size(); i++)
320  {
321  (*itNM).second.at(i)->toXML(tmpNode);
322  }
323  }
324 
325  // Resultat
327  {
328  _pResultat->toXML(domNewElem);
329  }
330  else
331  {
332  TYResultat tmp;
333  tmp.toXML(domNewElem);
334  }
335 
336  // Sauvegarde de rayons (chemins acoustiques)
337  DOM_Element listRaysNode = domDoc.createElement("ListRayons");
338  domNewElem.appendChild(listRaysNode);
339  for (size_t i = 0; i < _tabRays.size(); i++)
340  {
341  _tabRays.at(i)->toXML(listRaysNode);
342  }
343 
344  return domNewElem;
345 }
346 
348 {
349  purge(); // Cleaning before loading
350 
351  TYElement::fromXML(domElement);
352 
353  bool getOk[19];
354  unsigned int i = 0;
355  for (i = 0; i < 19; i++)
356  {
357  getOk[i] = false;
358  }
359  int retVal = -1;
360  LPTYMaillageGeoNode pMaillageGeoNode = new TYMaillageGeoNode(NULL, this);
361  LPTYRay aRay = new TYRay();
362  _tabRays.clear();
363 
364  // CLM-NT33: Compatibiltité ancien format XML
365  LPTYPointControl pPointControl = new TYPointControl();
366  TYProjet* pProjet = getProjet();
367 
368  int etat = -1; // Etat du calcul
369  bool useSol = false, useEcran = false, useReflexion = false;
370  bool condFav = false, calculTrajetHorizontaux = false, interference = false;
371  float h1 = NAN, distanceSRMin = NAN;
372 
373  TYListID tempElementSelection;
374  QString strSolverId;
375 
376  int readOk = 0; // Indicateur de bonne relecture des resultats
377 
378  _upTodate = (TYXMLTools::getElementAttributeToInt(domElement, "isUpTodate") == 1);
379 
380  DOM_Element elemCur;
381  QDomNodeList childs = domElement.childNodes();
382  for (i = 0; i < childs.length(); i++)
383  {
384  elemCur = childs.item(i).toElement();
385  TYXMLTools::getElementIntValue(elemCur, "numero", _numero, getOk[0]);
386  TYXMLTools::getElementStringValue(elemCur, "auteur", _auteur, getOk[1]);
387  TYXMLTools::getElementStringValue(elemCur, "dateCreation", _dateCreation, getOk[2]);
388  TYXMLTools::getElementStringValue(elemCur, "dateModif", _dateModif, getOk[3]);
389  TYXMLTools::getElementStringValue(elemCur, "comment", _comment, getOk[4]);
390  TYXMLTools::getElementStringValue(elemCur, "solverId", strSolverId, getOk[5]);
391  TYXMLTools::getElementIntValue(elemCur, "etat", etat, getOk[6]);
392  TYXMLTools::getElementStringValue(elemCur, "solverParams", solverParams, getOk[7]);
393  // Remove spaces and carriage returns from solverParams
394  solverParams = solverParams.replace(" ", "");
395  solverParams = solverParams.replace("\r", "");
396 
397  // Gestion des évolutions des paramètres des solveurs
398  if (elemCur.nodeName() == "solverParams")
399  {
400  // Introduction des conditions de propagation mixtes en version 4.1 de Code_TYMPAN
401  QRegularExpression propaCond_reg("(PropaConditions\\s?=\\s?)(True|False)");
402  QRegularExpressionMatch match_propaCond = propaCond_reg.match(solverParams);
403 
404  if (match_propaCond.hasMatch())
405  {
406  QString propaConditions = match_propaCond.captured(2);
407  int value = 0;
408  (propaConditions == "True") ? value = 1 : value = 0;
409  solverParams.replace(propaCond_reg, "PropaConditions=" + QString::number(value));
410  }
411  // Suppression d'Anime3D entre la version 4.2 et la version 4.3
412  // 1. Renommage d'Anime3DKeepRays en KeepRays et déplacement dans le bloc DEFAULTSOLVER
413  QRegularExpression keepRays_reg("(Anime3D)(KeepRays\\s?=\\s?)(True|False)"),
414  h1parameter_reg("(H1parameter\\s?=\\s?[0-9]+.[0-9]*)");
415  QRegularExpressionMatch match_keepRays = keepRays_reg.match(solverParams);
416  if (match_keepRays.hasMatch())
417  {
418  QString keepRays = "\n" + match_keepRays.captured(2) + match_keepRays.captured(3);
419  QRegularExpressionMatch match_h1parameter_reg = h1parameter_reg.match(solverParams);
420  int insert_pos = match_h1parameter_reg.capturedEnd();
421  if (insert_pos > -1)
422  {
423  solverParams.insert(insert_pos, keepRays);
424  }
425  }
426 
427  // 2. Suppression du bloc ANIME3DSOLVER
428  QRegularExpression anime3DUnit_reg("\\[ANIME3DSOLVER\\][^\\[]*\\[{1}");
429  anime3DUnit_reg.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
430  QRegularExpressionMatch match_anime3DUnit = anime3DUnit_reg.match(solverParams);
431  if (match_anime3DUnit.hasMatch())
432  {
433  int begin_anime3D_unit = match_anime3DUnit.capturedStart();
434  int length_anime3D_unit = match_anime3DUnit.capturedLength() - 1;
435  solverParams.remove(begin_anime3D_unit, length_anime3D_unit);
436  }
437 
438  // Ajout des paramètres de réflexions multiples
439  QRegularExpression reflectionOrderParameterReg("(ReflectionOrder\\s?=\\s?[0-9]*)");
440  QRegularExpressionMatch matchReflectionOrderReg = reflectionOrderParameterReg.match(solverParams);
441  // Si on ne trouve pas les paramètres de réflexions multiples
442  if (!matchReflectionOrderReg.hasMatch())
443  {
444  // Alors on ajoute ReflectionOrder après le paramètre PropaConditions
445  QRegularExpression propaCond_reg("(PropaConditions\\s?=\\s?[0-9]*)");
446  QRegularExpressionMatch matchPropaCondReg = propaCond_reg.match(solverParams);
447  if (matchPropaCondReg.hasMatch())
448  {
449  QString newParameterStr = "\nReflectionOrder=1";
450  int insert_pos = matchPropaCondReg.capturedEnd();
451  if (insert_pos > -1)
452  {
453  solverParams.insert(insert_pos, newParameterStr);
454  }
455  }
456  // et EnableVisibilityPruning après le paramètre DSWindDirection
457  QRegularExpression dsWindDirection_reg("(DSWindDirection\\s?=\\s?[0-9]*)");
458  QRegularExpressionMatch matchDsWindDirectionReg = dsWindDirection_reg.match(solverParams);
459  if (matchDsWindDirectionReg.hasMatch())
460  {
461  QString newParameterStr = "\nEnableVisibilityPruning=True";
462  int insert_pos = matchDsWindDirectionReg.capturedEnd();
463  if (insert_pos > -1)
464  {
465  solverParams.insert(insert_pos, newParameterStr);
466  }
467  }
468  }
469  }
470 
471  // Gestion de la compatibilité avec la version 3 de Code_TYMPAN
472  TYXMLTools::getElementBoolValue(elemCur, "useSol", useSol, getOk[8]);
473  TYXMLTools::getElementBoolValue(elemCur, "useEcran", useEcran, getOk[9]);
474  TYXMLTools::getElementBoolValue(elemCur, "useReflexion", useReflexion, getOk[10]);
475  TYXMLTools::getElementBoolValue(elemCur, "interference", interference, getOk[11]);
476  TYXMLTools::getElementBoolValue(elemCur, "calculTrajetHorizontaux", calculTrajetHorizontaux,
477  getOk[12]);
478  TYXMLTools::getElementBoolValue(elemCur, "condFav", condFav, getOk[13]);
479  TYXMLTools::getElementFloatValue(elemCur, "h1", h1, getOk[14]);
480  TYXMLTools::getElementFloatValue(elemCur, "distanceSRMin", distanceSRMin, getOk[15]);
481 
482  if (elemCur.nodeName() == "distanceSRMin")
483  {
484  // Conversion des boolean recuperes en string
485  QString useSol_str, useEcran_str, useReflexion_str, interference_str, calculTrajetHorizontaux_str;
486  int condPropa = 0;
487  useSol ? useSol_str = "True" : useSol_str = "False";
488  useEcran ? useEcran_str = "True" : useEcran_str = "False";
489  useReflexion ? useReflexion_str = "True" : useReflexion_str = "False";
490  interference ? interference_str = "True" : interference_str = "False";
491  calculTrajetHorizontaux ? calculTrajetHorizontaux_str = "True"
492  : calculTrajetHorizontaux_str = "False";
493  condFav ? condPropa = 1 : condPropa = 0;
494 
495  // Creation des lignes a modifier dans le bloc de text de parametres
496  QString useRealGround = "UseRealGround=" + useSol_str;
497  QString useScreen = "UseScreen=" + useEcran_str;
498  QString useReflection = "UseReflection=" + useReflexion_str;
499  QString modSummation = "ModSummation=" + interference_str;
500  QString useLateralDiffraction = "UseLateraDiffraction=" + calculTrajetHorizontaux_str;
501  QString propaConditions = "PropaConditions=" + QString::number(condPropa);
502  QString h1parameter = "H1parameter=" + QString::number(h1);
503  QString minSRDistance = "MinSRDistance=" + QString::number(distanceSRMin);
504 
505  // Expressions regulières liées aux lignes recherchées
506  QRegularExpression useSol_reg("UseRealGround=(True|False)"),
507  useEcran_reg("UseScreen=(True|False)"), useReflexion_reg("UseReflection=(True|False)"),
508  interference_reg("ModSummation=(True|False)"),
509  calculTrajetHorizontaux_reg("UseLateraDiffraction=(True|False)"),
510  condFav_reg("PropaConditions=[0-2]"), h1parameter_reg("H1parameter=[0-9]+.[0-9]*"),
511  minSRDistance_reg("MinSRDistance=[0-9]+.[0-9]*");
512 
513  // Rechercher et remplacer
514  solverParams.replace(useSol_reg, useRealGround);
515  solverParams.replace(useEcran_reg, useScreen);
516  solverParams.replace(useReflexion_reg, useReflection);
517  solverParams.replace(interference_reg, modSummation);
518  solverParams.replace(calculTrajetHorizontaux_reg, useLateralDiffraction);
519  solverParams.replace(condFav_reg, propaConditions);
520  solverParams.replace(h1parameter_reg, h1parameter);
521  solverParams.replace(minSRDistance_reg, minSRDistance);
522  }
523 
524  // Récupérer les parametres météo de la version 3
525  if (elemCur.nodeName() == "Atmosphere")
526  {
527  double pression = 0;
528  double temperature = 0;
529  double hygrometrie = 0;
530  DOM_Element elemCur2;
531  QDomNodeList childs2 = elemCur.childNodes();
532 
533  for (unsigned int j = 0; j < childs2.length(); j++)
534  {
535  elemCur2 = childs2.item(j).toElement();
536  if (elemCur2.nodeName() == "pression")
537  {
538  TYXMLTools::getElementDoubleValue(elemCur2, "pression", pression, getOk[16]);
539  QString atmosPressure = "AtmosPressure=" + QString::number(pression);
540  QRegularExpression atmosPressure_reg("AtmosPressure=[0-9]+.[0-9]*");
541  solverParams.replace(atmosPressure_reg, atmosPressure);
542  continue;
543  }
544  if (elemCur2.nodeName() == "temperature")
545  {
546  TYXMLTools::getElementDoubleValue(elemCur2, "temperature", temperature, getOk[17]);
547  QString atmosTemperature = "AtmosTemperature=" + QString::number(temperature);
548  QRegularExpression atmosTemperature_reg("AtmosTemperature=[0-9]+.[0-9]*");
549  solverParams.replace(atmosTemperature_reg, atmosTemperature);
550  continue;
551  }
552  if (elemCur2.nodeName() == "hygrometrie")
553  {
554  TYXMLTools::getElementDoubleValue(elemCur2, "hygrometrie", hygrometrie, getOk[18]);
555  QString atmosHygrometry = "AtmosHygrometry=" + QString::number(hygrometrie);
556  QRegularExpression atmosHygrometry_reg("AtmosHygrometry=[0-9]+.[0-9]*");
557  solverParams.replace(atmosHygrometry_reg, atmosHygrometry);
558  continue;
559  }
560  }
561  }
562  // Selection
563  if (elemCur.nodeName() == "ListID")
564  {
565  DOM_Element elemCur2;
566  QDomNodeList childs2 = elemCur.childNodes();
567 
568  for (unsigned int j = 0; j < childs2.length(); j++)
569  {
570  elemCur2 = childs2.item(j).toElement();
571  if (elemCur2.nodeName() == "Element")
572  {
573  QString id = TYXMLTools::getElementAttributeToString(elemCur2, "id");
574  tempElementSelection.push_back(id);
575  }
576  }
577  }
578  else if (elemCur.nodeName() == "EtatSources") // Etats des sources
579  {
580  DOM_Element elemCur2;
581  QDomNodeList childs2 = elemCur.childNodes();
582 
583  for (unsigned int j = 0; j < childs2.length(); j++)
584  {
585  elemCur2 = childs2.item(j).toElement();
586 
587  if (elemCur2.nodeName() == "EtatSource")
588  {
589  QString srcId = TYXMLTools::getElementAttributeToString(elemCur2, "srcId");
590  bool state = TYXMLTools::getElementAttributeToInt(elemCur2, "state");
591 
592  TYElement* pSrc = TYElement::getInstance(srcId);
593 
594  if (pSrc)
595  {
596  _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pSrc, state));
597  }
598  }
599  }
600  }
601  else if (elemCur.nodeName() == "EmissionAccVolNodes") // Etats des AccVolNodes en emission
602  {
603  DOM_Element elemCur2;
604  QDomNodeList childs2 = elemCur.childNodes();
605 
606  for (unsigned int j = 0; j < childs2.length(); j++)
607  {
608  elemCur2 = childs2.item(j).toElement();
609 
610  if (elemCur2.nodeName() == "EmissionAccVolNode")
611  {
612  QString accVolNodeId = TYXMLTools::getElementAttributeToString(elemCur2, "accVolNodeId");
613  bool state = TYXMLTools::getElementAttributeToInt(elemCur2, "state");
614 
615  TYElement* pAccVolNode = TYElement::getInstance(accVolNodeId);
616 
617  if (pAccVolNode)
618  {
619  _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pAccVolNode, state));
620  }
621  }
622  }
623  }
624  else if (elemCur.nodeName() == "RegimeAccNode") // Regime associe a chaque source
625  {
626  DOM_Element elemCur2;
627  QDomNodeList childs2 = elemCur.childNodes();
628 
629  for (unsigned int j = 0; j < childs2.length(); j++)
630  {
631  elemCur2 = childs2.item(j).toElement();
632 
633  if (elemCur2.nodeName() == "RegimeAccNode")
634  {
635  QString accVolNodeId = TYXMLTools::getElementAttributeToString(elemCur2, "accVolNodeId");
636  int state = TYXMLTools::getElementAttributeToInt(elemCur2, "state");
637 
638  TYElement* pAccVolNode = TYElement::getInstance(accVolNodeId);
639 
640  if (pAccVolNode)
641  {
642  _mapElementRegime.insert(TYMapPtrElementInt::value_type(pAccVolNode, state));
643  }
644  }
645  }
646  }
647  else if (elemCur.nodeName() == "ResuCtrlPnts")
648  {
649  DOM_Element elemCur2;
650  QDomNodeList childs2 = elemCur.childNodes();
651  LPTYSpectre spectrum = new TYSpectre();
652  _hasResuCtrlPnts = true;
653 
654  for (unsigned int j = 0; j < childs2.length(); j++)
655  {
656  elemCur2 = childs2.item(j).toElement();
657  if (elemCur2.nodeName() == "Recepteur")
658  {
659  QString strReceptor_id = TYXMLTools::getElementAttributeToString(elemCur2, "receptor_id");
660  TYUUID receptor_id;
661  receptor_id.FromString(strReceptor_id);
662 
663  // Get the spectrum
664  DOM_Element elemCur3;
665  QDomNodeList childs3 = elemCur2.childNodes();
666  for (unsigned int k = 0; k < childs3.length(); k++)
667  {
668  elemCur3 = childs3.item(k).toElement();
669  if (spectrum->callFromXMLIfEqual(elemCur3, &retVal))
670  {
671  if (retVal == 1)
672  {
673  _mapPointCtrlSpectre[receptor_id] = new TYSpectre(*spectrum);
674  }
675  }
676  }
677  }
678  }
679  }
680  else if (elemCur.nodeName() == "ResuNoiseMaps")
681  {
682  DOM_Element elemCur2;
683  QDomNodeList childs2 = elemCur.childNodes();
684 
685  LPTYSpectre spectrum = new TYSpectre();
686  std::vector<LPTYSpectre> tabSpectre;
687 
688  for (unsigned int j = 0; j < childs2.length(); j++)
689  {
690  elemCur2 = childs2.item(j).toElement();
691 
692  if (elemCur2.nodeName() == "NoiseMap")
693  {
694  tabSpectre.clear();
695 
696  QString strnoise_map_id =
697  TYXMLTools::getElementAttributeToString(elemCur2, "noise_map_id");
698  TYUUID noise_map_id;
699  noise_map_id.FromString(strnoise_map_id);
700 
701  DOM_Element elemCur3;
702  QDomNodeList childs3 = elemCur2.childNodes();
703  for (unsigned int k = 0; k < childs3.length(); k++)
704  {
705  elemCur3 = childs3.item(k).toElement();
706  if (spectrum->callFromXMLIfEqual(elemCur3, &retVal))
707  {
708  if (retVal == 1)
709  {
710  tabSpectre.push_back(new TYSpectre(*spectrum));
711  }
712  }
713  }
714 
715  _noiseMapsSpectrums[noise_map_id] = tabSpectre;
716  }
717  }
718  }
719  else if (elemCur.nodeName() == "ListRayons")
720  {
721  DOM_Element elemCur2;
722  QDomNodeList childs2 = elemCur.childNodes();
723 
724  for (int j = 0; j < childs2.length(); j++)
725  {
726  elemCur2 = childs2.item(j).toElement();
727  if (aRay->callFromXMLIfEqual(elemCur2, &retVal))
728  {
729  if (retVal == 1)
730  {
731  _tabRays.push_back(aRay);
732  aRay = new TYRay();
733  }
734  }
735  }
736  }
737 
738  // CLM-NT33: Compatibilitité avec ancien format XML
739  // Points de controle
740  if (elemCur.nodeName() == "PointsControl")
741  {
742  DOM_Element elemCur2;
743  QDomNodeList childs2 = elemCur.childNodes();
744 
745  for (unsigned int j = 0; j < childs2.length(); j++)
746  {
747  elemCur2 = childs2.item(j).toElement();
748 
749  // ajoute l'attribut id du calcul au spectre
750  QDomNodeList childs3 = elemCur2.childNodes();
751  for (unsigned int k = 0; k < childs3.length(); k++)
752  {
753  DOM_Element elemCur3 = childs3.item(k).toElement();
754  if (elemCur3.nodeName() == "Spectre")
755  {
756  elemCur3.setAttribute("idCalcul", getID().toString());
757  }
758  }
759 
760  if (pPointControl->callFromXMLIfEqual(elemCur2))
761  {
762  pProjet->addPointControl(pPointControl);
763  pPointControl = new TYPointControl();
764  }
765  }
766  }
767 
769  if (pMaillageGeoNode->callFromXMLIfEqual(elemCur, &retVal))
770  {
771  if (retVal == 1)
772  {
773  pProjet->addMaillage(pMaillageGeoNode);
774  dynamic_cast<TYMaillage*>(pMaillageGeoNode->getElement())->setEtat(getID(), true);
775  pMaillageGeoNode = new TYMaillageGeoNode(NULL, this);
776  }
777  }
778 
779  // Resultat
780  _pResultat->callFromXMLIfEqual(elemCur, &readOk);
781  }
782 
783  if (getOk[5])
784  {
785  _solverId.FromString(strSolverId);
786  } // Recuperation de l'Id du solveur
787 
788  // On supprime les IDs de la selection des elements non presents dans le site
789  TYListID::iterator next = tempElementSelection.begin();
790 
791  while (next != tempElementSelection.end())
792  {
793  if (!TYElement::getInstance((*next)))
794  {
795  next = tempElementSelection.erase(next);
796  }
797  else
798  {
799  next++;
800  }
801  }
802 
803  // On ajoute ceux qui restent dans le calcul
804  for (next = tempElementSelection.begin(); next != tempElementSelection.end(); next++)
805  {
806  _elementSelection.push_back((*next));
807  }
808 
809  // Si le tableau associatif element/regime est vide (fichier 3.1), on le cree,
810  // ainsi que le tableau des etats de rayonnement
811  if (_mapElementRegime.size() == 0)
812  {
813  TYListID::iterator iter;
814  int regime = 0;
815  bool bEmit = false;
816  for (iter = _elementSelection.begin(); iter != _elementSelection.end(); iter++)
817  {
818  TYElement* pElement = TYElement::getInstance(*iter);
819  TYAcousticVolumeNode* pVolNode = dynamic_cast<TYAcousticVolumeNode*>(pElement);
820  if (pVolNode != nullptr)
821  {
822  regime = pVolNode->getCurRegime();
823  bEmit = pVolNode->getIsRayonnant();
824  }
825  else
826  {
827  TYAcousticLine* pLine = dynamic_cast<TYAcousticLine*>(pElement);
828  if (pLine != nullptr)
829  {
830  regime = pLine->getCurRegime();
831  bEmit = pLine->getIsRayonnant();
832  }
833  else if (pElement->isA("TYUserSourcePonctuelle"))
834  {
835  regime = TYUserSourcePonctuelle::safeDownCast(pElement)->getCurrentRegime();
836  bEmit = true;
837  }
838  }
839  _mapElementRegime[pElement] = regime;
840  _emitAcVolNode[pElement] = bEmit;
841 
842  regime = 0;
843  bEmit = false;
844  }
845  }
846 
847  if (etat != -1)
848  {
849  setState(etat);
850  } // Si un etat a ete relu (fichier format TYMPAN 3.3) mise a jour de l'etat
851  if (readOk == -1)
852  {
853  _pResultat->purge();
854  return readOk;
855  }
856  return 1;
857 }
858 
860 {
861  // remAllMaillage();
862  _tabRays.clear();
863 
864  _elementSelection.clear();
865 
866  _pResultat->purge();
867  _mapElementRegime.clear();
868  _emitAcVolNode.clear();
869 
870  // Cleaning control point / spectrum association
871  _mapPointCtrlSpectre.clear();
872 
873  // Cleaning noise map / spectrums association
874  _noiseMapsSpectrums.clear();
875 
876  setIsGeometryModified(true);
877 }
878 
880 {
881  TYTabLPPointControl::iterator ite;
884 
885  _pResultat->purge();
886  _tabRays.clear();
887 
888  setIsGeometryModified(true);
889 }
890 
892 {
893  TYProjet* pProjet = getProjet();
894  if (pProjet)
895  {
896  return pProjet->getSite();
897  }
898 
899  return NULL;
900 }
901 
903 {
904  _pSiteCalcul = pSite;
905 }
906 
908 {
909  bool res = false;
910 
911  if (!isInSelection(id))
912  {
913  _elementSelection.push_back(id);
914  res = true;
915  }
916 
917  return res;
918 }
919 
920 void TYCalcul::addToSelection(TYElement* pElt, bool recursif /*=true*/)
921 {
922  if (!pElt)
923  {
924  return;
925  }
926 
927  TYUUID id = pElt->getID();
928 
929  if (addToSelection(id))
930  {
931  bool etat = true;
932  if (pElt->isA("TYInfrastructure"))
933  {
934  // Si un objet est ajoute son parent l'est forcemment
935  addToSelection(pElt->getParent(), false);
936  }
937  else if (dynamic_cast<TYSiteNode*>(pElt) != nullptr)
938  {
939  // Si un objet est ajoute son parent l'est forcemment
940  addToSelection(pElt->getParent(), false);
941 
942  // Si c'est un site on n'ajoute pas systématiquement tous les enfants
943  recursif = false;
944  }
945  else if (dynamic_cast<TYAcousticVolumeNode*>(pElt) != nullptr)
946  {
947  TYAcousticVolumeNode* pVolNode = dynamic_cast<TYAcousticVolumeNode*>(pElt);
948  etat = pVolNode->getIsRayonnant();
949  _emitAcVolNode[pElt] = etat;
950  _mapElementRegime[pElt] = 0;
951 
952  // Si un objet est ajoute son parent l'est forcemment
953  addToSelection(pElt->getParent(), false);
954  }
955  else if (dynamic_cast<TYAcousticLine*>(pElt) != nullptr)
956  {
957  TYAcousticLine* pLine = dynamic_cast<TYAcousticLine*>(pElt);
958  etat = pLine->getIsRayonnant();
959  _emitAcVolNode[pElt] = etat;
960  _mapElementRegime[pElt] = 0;
961 
962  // Si un objet est ajoute son parent l'est forcemment
963  addToSelection(pElt->getParent(), false);
964  }
965  else if (dynamic_cast<TYUserSourcePonctuelle*>(pElt) != nullptr)
966  {
967  TYUserSourcePonctuelle* pSource = dynamic_cast<TYUserSourcePonctuelle*>(pElt);
968  if (pSource != nullptr)
969  {
970  etat = pSource->getIsRayonnant();
971  }
972  _emitAcVolNode[pElt] = etat;
973  _mapElementRegime[pElt] = 0;
974 
975  // Si un objet est ajoute son parent l'est forcemment
976  addToSelection(pElt->getParent(), false);
977  }
978 
979  // Informe l'element qu'il est dans le calcul courant
980  pElt->setInCurrentCalcul(true, false);
981 
982  // Si recursif on ajoute les enfants
983  if (recursif)
984  {
985  LPTYElementArray childs;
986  pElt->getChilds(childs, false);
987 
988  for (int i = 0; i < childs.size(); i++)
989  {
990  addToSelection(childs[i], recursif);
991  }
992  }
993  }
994 }
995 
997 {
998  _elementSelection.remove(id);
999  setIsGeometryModified(true);
1000  return true;
1001 }
1002 
1003 bool TYCalcul::remToSelection(TYElement* pElt, bool recursif /*=true*/)
1004 {
1005  assert(pElt);
1006  bool ret = false;
1007  TYUUID id = pElt->getID();
1008 
1009  if (isInSelection(id))
1010  {
1011  // Reset des resultats precedents (car plus valables)
1012  _pResultat->purge();
1013 
1014  // On supprime l'element lui meme des differents tableaux associatifs
1015  _elementSelection.remove(id);
1016  _emitAcVolNode.erase(pElt);
1017  _mapElementRegime.erase(pElt);
1018 
1019  // On informe l'element qu'ils ne sont plua dans le calcul
1020  pElt->setInCurrentCalcul(false, false, false);
1021 
1022  // On désactive ses enfants
1023  LPTYElementArray childs;
1024  pElt->getChilds(childs, false);
1025 
1026  for (int i = 0; i < childs.size(); i++)
1027  {
1028  remToSelection(childs[i], recursif);
1029  }
1030 
1031  pElt->setIsGeometryModified(true);
1032 
1033  ret = true;
1034  }
1035  return ret;
1036 }
1037 
1039 {
1040  bool present = false;
1041  TYListID::iterator ite;
1042 
1043  for (ite = _elementSelection.begin(); ite != _elementSelection.end(); ++ite)
1044  {
1045  if ((*ite) == id)
1046  {
1047  present = true;
1048  break;
1049  }
1050  }
1051 
1052  return present;
1053 }
1054 
1056 {
1057  // Create result map (business sources --> micro sources)
1058  TYMapElementTabSources& mapElementSources = _pResultat->getMapEmetteurSrcs();
1059  getProjet()->getSite()->getInfrastructure()->getAllSrcs(this, mapElementSources);
1060  // build sources spectra
1062 
1063  // Le calcul a proprement parler est termine
1064  // Il est necessaire de reattribuer les parents des elements du site merges
1065  getProjet()->getSite()->reparent();
1066 
1067  TYNameManager::get()->enable(true);
1068 
1069  setIsAcousticModified(true); // Les données acoustiques ont été actualisées
1070 }
1071 
1073 {
1074  unsigned int i = 0;
1075  // bool ok = true;
1076 
1077  if (getProjet()->getCurrentCalcul() != this)
1078  {
1079  return;
1080  }
1081 
1082  // Pour chaque element, 2 cas :
1083  // - il sont dans la liste des elements du calcul mais ne sont pas "inCurrentCalcul"
1084  // --> il faut les informer (setInCurrentCalcul(true))
1085  // - ils sont "inCurrentCalcul" mais ne sont pas dans la liste
1086  // --> il faut les "desactiver" (setInCurrentCalcul(false))
1087 
1088  for (i = 0; i < pSite->getInfrastructure()->getListBatiment().size(); i++)
1089  {
1090  LPTYBatiment pBatiment =
1091  TYBatiment::safeDownCast(pSite->getInfrastructure()->getListBatiment()[i]->getElement());
1092 
1093  if ((pBatiment->isInCurrentCalcul()) && (_emitAcVolNode.find(pBatiment) == _emitAcVolNode.end()))
1094  {
1095  // On l'informe qu'il ne fait pas partie du calcul
1096  pBatiment->setInCurrentCalcul(false);
1097  }
1098  else if ((!pBatiment->isInCurrentCalcul()) &&
1099  (_emitAcVolNode.find(pBatiment) != _emitAcVolNode.end()))
1100  {
1101  // On l'informe qu'il fait partie du calcul
1102  pBatiment->setInCurrentCalcul(true);
1103  }
1104  }
1105 
1106  for (i = 0; i < pSite->getInfrastructure()->getListMachine().size(); i++)
1107  {
1108  LPTYMachine pMachine =
1109  TYMachine::safeDownCast(pSite->getInfrastructure()->getListMachine()[i]->getElement());
1110 
1111  if ((pMachine->isInCurrentCalcul()) && (_emitAcVolNode.find(pMachine) == _emitAcVolNode.end()))
1112  {
1113  // On l'informe qu'il ne fait pas partie du calcul
1114  pMachine->setInCurrentCalcul(false);
1115  }
1116  else if ((!pMachine->isInCurrentCalcul()) && (_emitAcVolNode.find(pMachine) != _emitAcVolNode.end()))
1117  {
1118  // On l'informe qu'il fait partie du calcul
1119  pMachine->setInCurrentCalcul(true);
1120  }
1121  }
1122 
1123  for (i = 0; i < pSite->getInfrastructure()->getSrcs().size(); i++)
1124  {
1125  LPTYSourcePonctuelle pSrcPonct =
1126  TYSourcePonctuelle::safeDownCast(pSite->getInfrastructure()->getSrc(i)->getElement());
1127 
1128  if ((pSrcPonct->isInCurrentCalcul()) && (_emitAcVolNode.find(pSrcPonct) == _emitAcVolNode.end()))
1129  {
1130  // On l'informe qu'il ne fait pas partie du calcul
1131  pSrcPonct->setInCurrentCalcul(false);
1132  }
1133  else if ((!pSrcPonct->isInCurrentCalcul()) &&
1134  (_emitAcVolNode.find(pSrcPonct) != _emitAcVolNode.end()))
1135  {
1136  // On l'informe qu'il fait partie du calcul
1137  pSrcPonct->setInCurrentCalcul(true);
1138  }
1139  }
1140 #if WITH_NMPB
1141  for (i = 0; i < pSite->getInfrastructure()->getListRoute().size(); i++)
1142  {
1143  LPTYRoute pRoute = pSite->getInfrastructure()->getRoute(i);
1144 
1145  if ((pRoute->isInCurrentCalcul()) && (_emitAcVolNode.find(pRoute) == _emitAcVolNode.end()))
1146  {
1147  // On l'informe qu'il ne fait pas partie du calcul
1148  pRoute->setInCurrentCalcul(false);
1149  }
1150  else if ((!pRoute->isInCurrentCalcul()) && (_emitAcVolNode.find(pRoute) != _emitAcVolNode.end()))
1151  {
1152  // On l'informe qu'il fait partie du calcul
1153  pRoute->setInCurrentCalcul(true);
1154  }
1155  }
1156 #endif
1157  for (i = 0; i < pSite->getInfrastructure()->getListResTrans().size(); i++)
1158  {
1159  LPTYReseauTransport pResTrans = pSite->getInfrastructure()->getResTrans(i);
1160 
1161  if ((pResTrans->isInCurrentCalcul()) && (_emitAcVolNode.find(pResTrans) == _emitAcVolNode.end()))
1162  {
1163  // On l'informe qu'il ne fait pas partie du calcul
1164  pResTrans->setInCurrentCalcul(false);
1165  }
1166  else if ((!pResTrans->isInCurrentCalcul()) &&
1167  (_emitAcVolNode.find(pResTrans) != _emitAcVolNode.end()))
1168  {
1169  // On l'informe qu'il fait partie du calcul
1170  pResTrans->setInCurrentCalcul(true);
1171  }
1172  }
1173 }
1174 
1176 {
1177  // Create point control entry if not done
1178  TYUUID id_point = pPoint->getID();
1179  if (_mapPointCtrlSpectre.find(id_point) == _mapPointCtrlSpectre.end())
1180  {
1181  LPTYSpectre spectre = new TYSpectre();
1182  _mapPointCtrlSpectre[id_point] = spectre;
1183 
1184  // Set control point on for this calcul
1185  pPoint->setEtat(getID(), true);
1186 
1187  if (_pResultat->addRecepteur(pPoint) == true)
1188  {
1190  }
1191 
1192  return true;
1193  }
1194 
1195  return false;
1196 }
1197 
1199 {
1200  // Remove point control entry
1201  TYMapIdSpectre::iterator it = _mapPointCtrlSpectre.find(pPoint->getID());
1202  if (it != _mapPointCtrlSpectre.end())
1203  {
1204  _mapPointCtrlSpectre.erase(it);
1205  }
1206 
1207  // Set control point off for this calcul
1208  pPoint->setEtat(getID(), false);
1209 
1210  // Cleaning results
1211  _pResultat->purge();
1212 
1213  return true;
1214 }
1215 
1217 {
1218  TYMapIdSpectre::iterator it;
1219  for (it = _mapPointCtrlSpectre.begin(); it != _mapPointCtrlSpectre.end(); it++)
1220  {
1221  (*it).second = new TYSpectre();
1222  }
1223 }
1224 
1226 {
1227  TYMapIdTabSpectre::iterator it;
1228  for (it = _noiseMapsSpectrums.begin(); it != _noiseMapsSpectrums.end(); it++)
1229  {
1230  for (unsigned int i = 0; i < (*it).second.size(); i++)
1231  {
1232  (*it).second.at(i)->deepCopy(new TYSpectre());
1233  }
1234  }
1235 }
1236 
1238 {
1239  TYMapIdTabSpectre::iterator it;
1240  for (it = otherNoiseMap.begin(); it != otherNoiseMap.end(); it++)
1241  {
1242  TYUUID id = (*it).first;
1243  std::vector<LPTYSpectre> tabSpectres;
1244  for (unsigned int i = 0; i < (*it).second.size(); i++)
1245  {
1246  tabSpectres.push_back(new TYSpectre());
1247  }
1248 
1249  _noiseMapsSpectrums[id] = tabSpectres;
1250  }
1251 }
1252 
1254 {
1255  return getSpectre(pPoint->getID());
1256 }
1257 
1259 {
1260  TYSpectre* ret = new TYSpectre();
1261 
1262  TYMapIdSpectre::iterator it = _mapPointCtrlSpectre.find(id_pt);
1263 
1264  if (it != _mapPointCtrlSpectre.end())
1265  {
1266  ret = (*it).second;
1267  }
1268 
1269  return ret;
1270 }
1271 
1273 {
1274  TYMapIdSpectre::iterator it = _mapPointCtrlSpectre.find(pPoint->getID());
1275 
1276  // Add only if the control point is known from the calcul
1277  if (it != _mapPointCtrlSpectre.end())
1278  {
1279  (*it).second = pSpectre;
1280  }
1281  else // other case point is owned by a TYMaillage
1282  {
1283  if (dynamic_cast<TYMaillage*>(pPoint->getParent()))
1284  {
1285  LPTYSpectre currentSpectre = pPoint->getSpectre();
1286  currentSpectre->deepCopy(pSpectre);
1287  }
1288  }
1289 }
1290 
1291 void TYCalcul::setSpectre(const TYUUID& id_pt, TYSpectre* pSpectre)
1292 {
1293  assert(true && "NOT IMPLEMENTED");
1294 }
1295 
1297 {
1298  TYMapIdSpectre::iterator it = _mapPointCtrlSpectre.find(id_pt);
1299 
1300  if (it != _mapPointCtrlSpectre.end())
1301  {
1302  return true;
1303  }
1304 
1305  return false;
1306 }
1307 
1308 void TYCalcul::setPtCtrlStatus(const TYUUID& id_pt, bool bStatus)
1309 {
1310  // Suppression de la map des spectres aux points
1311  TYMapIdSpectre::iterator it = _mapPointCtrlSpectre.find(id_pt);
1312 
1313  if (it != _mapPointCtrlSpectre.end())
1314  {
1315  _mapPointCtrlSpectre.erase(it);
1316  }
1317 
1318  // Information du point de controle
1319  TYElement* pElem = TYElement::getInstance(id_pt);
1320  if (pElem)
1321  {
1322  TYPointControl* pPoint = dynamic_cast<TYPointControl*>(pElem);
1323  if (pPoint)
1324  {
1325  pPoint->setEtat(getID(), bStatus);
1326  }
1327  }
1328 }
1329 
1330 std::vector<LPTYSpectre>* TYCalcul::getSpectrumDatas(TYMaillage* pMaillage)
1331 {
1332  return getSpectrumDatas(pMaillage->getID());
1333 }
1334 
1336 {
1337  return _tabRays.size() > 0;
1338 }
1339 
1340 std::vector<LPTYSpectre>* TYCalcul::getSpectrumDatas(const TYUUID& id)
1341 {
1342  TYMapIdTabSpectre::iterator it = _noiseMapsSpectrums.find(id);
1343 
1344  if (it != _noiseMapsSpectrums.end())
1345  {
1346  return &(*it).second;
1347  }
1348 
1349  return nullptr;
1350 }
1351 
1353 {
1354  TYUUID id = pMaillage->getID();
1355 
1356  // Test if map is already selected for this calcul
1357  if (_noiseMapsSpectrums.find(id) != _noiseMapsSpectrums.end())
1358  {
1359  return false;
1360  }
1361 
1362  size_t nbPoints = pMaillage->getPtsCalcul().size();
1363  std::vector<LPTYSpectre> tabSpectres;
1364  for (unsigned int i = 0; i < nbPoints; i++)
1365  {
1366  tabSpectres.push_back(new TYSpectre());
1367  }
1368 
1369  _noiseMapsSpectrums[id] = tabSpectres;
1370 
1371  pMaillage->setEtat(getID(), true);
1372 
1373  return true;
1374 }
1375 
1377 {
1378  TYUUID id = pMaillage->getID();
1379 
1380  // Test if map is selected for this calcul
1381  if (_noiseMapsSpectrums.find(id) == _noiseMapsSpectrums.end())
1382  {
1383  return false;
1384  }
1385 
1386  _noiseMapsSpectrums[id].clear(); // cleaning old noise map datas
1387  size_t nbPoints = pMaillage->getPtsCalcul().size();
1388  std::vector<LPTYSpectre> tabSpectres;
1389  for (unsigned int i = 0; i < nbPoints; i++)
1390  {
1391  tabSpectres.push_back(new TYSpectre());
1392  }
1393 
1394  _noiseMapsSpectrums[id] = tabSpectres;
1395  return true;
1396 }
1397 
1399 {
1400  TYUUID id = pMaillage->getID();
1401  TYMapIdTabSpectre::iterator it = _noiseMapsSpectrums.find(id);
1402 
1403  if (it != _noiseMapsSpectrums.end())
1404  {
1405  _noiseMapsSpectrums.erase(it);
1406 
1407  pMaillage->setEtat(getID(), false);
1408 
1409  return true;
1410  }
1411 
1412  return false;
1413 }
1414 
1415 void TYCalcul::setNoiseMapSpectrums(const TYMaillage* pMaillage, TYTabLPSpectre& tabSpectrum)
1416 {
1417  TYUUID id = pMaillage->getID();
1418  setNoiseMapSpectrums(id, tabSpectrum);
1419 }
1420 
1422 {
1423  _noiseMapsSpectrums[id] = tabSpectrum;
1424 }
1425 
1427 {
1428  return _mapPointCtrlSpectre;
1429 }
QDomDocument DOM_Document
Definition: QT2DOM.h:33
QDomElement DOM_Element
Definition: QT2DOM.h:30
Representation graphique d'un calcul (fichier header)
outil IHM pour un calcul (fichier header)
TY_EXTENSION_INST(TYCalcul)
TY_EXT_GRAPHIC_INST(TYCalcul)
std::map< TYUUID, SmartPtr< TYSpectre > > TYMapIdSpectre
Tableau associant un spectre a un id (identifiant d'objet)
Definition: TYDefines.h:367
std::map< TYUUID, std::vector< SmartPtr< TYSpectre > > > TYMapIdTabSpectre
Tableau associant un id a un tableau de spectres.
Definition: TYDefines.h:370
class OGenID TYUUID
Definition: TYDefines.h:59
std::vector< LPTYSpectre > TYTabLPSpectre
Collection de TYSpectre.
Definition: TYDefines.h:337
std::list< TYUUID > TYListID
Collection d'identifiants.
Definition: TYDefines.h:331
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:344
TYGeometryNode TYMaillageGeoNode
Noeud geometrique de type TYMaillage.
Definition: TYMaillage.h:434
int id
std::map< TYElement *, TYTabSourcePonctuelleGeoNode > TYMapElementTabSources
Definition: idgen.h:28
void FromString(const char *strUuid)
Definition: idgen.h:83
const QString toString() const
Definition: idgen.h:78
virtual const char * getClassName() const
Definition: TYElement.h:248
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
bool isA(const char *className) const
Definition: TYElement.cpp:65
int getCurRegime() const
Calculation program.
Definition: TYCalcul.h:50
void copyNoiseMapSpectrums(TYMapIdTabSpectre &otherNoiseMap)
Definition: TYCalcul.cpp:1237
bool getPtCtrlStatus(const TYUUID &id_pt)
Get the status of a point for this calcul.
Definition: TYCalcul.cpp:1296
LPTYResultat _pResultat
Results.
Definition: TYCalcul.h:599
void clearResult()
Definition: TYCalcul.cpp:879
TYMapIdSpectre _mapPointCtrlSpectre
Definition: TYCalcul.h:593
void setSite(LPTYSiteNode pSite)
Definition of the site on which the calculation will be done.
Definition: TYCalcul.cpp:902
TYMapPtrElementInt _mapElementRegime
Regime of scene elements.
Definition: TYCalcul.h:590
bool addPtCtrlToResult(LPTYPointControl pPoint)
Add a checkpoint to the results array.
Definition: TYCalcul.cpp:1175
int _numero
Calculation number.
Definition: TYCalcul.h:565
TYCalcul()
Definition: TYCalcul.cpp:47
TYMapPtrElementBool _emitAcVolNode
State (radiating/non-radiating) of the elements of the scene.
Definition: TYCalcul.h:587
OGenID _solverId
Definition: TYCalcul.h:562
void purge()
Reset this calculation.
Definition: TYCalcul.cpp:859
TYCalcul & operator=(const TYCalcul &other)
Operator =.
Definition: TYCalcul.cpp:72
TYMapIdTabSpectre _noiseMapsSpectrums
Definition: TYCalcul.h:596
void setSpectre(const TYUUID &id_pt, TYSpectre *pSpectre)
Definition: TYCalcul.cpp:1291
int _state
Calculation state Active or Blocked.
Definition: TYCalcul.h:578
void setPtCtrlStatus(const TYUUID &id_pt, bool bStatus)
Set the status of a point for this calcul.
Definition: TYCalcul.cpp:1308
void getCalculElements(LPTYSiteNode pSite)
Recover all the elements of the scene which take part in the calculation.
Definition: TYCalcul.cpp:1072
void setNoiseMapSpectrums(const TYMaillage *pMaillage, TYTabLPSpectre &tabSpectrum)
set spectrum vector for a given noise map
Definition: TYCalcul.cpp:1415
bool _hasResuCtrlPnts
Definition: TYCalcul.h:606
virtual ~TYCalcul()
Destructor. Destructor of the TYCalcul class.
Definition: TYCalcul.cpp:62
QString solverParams
Definition: TYCalcul.h:482
bool _upTodate
Calculation up to date or not.
Definition: TYCalcul.h:576
bool updateMaillage(TYMaillage *pMaillage)
update a noisemap after modification
Definition: TYCalcul.cpp:1376
virtual int fromXML(DOM_Element domElement)
Definition: TYCalcul.cpp:347
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYCalcul.cpp:232
bool remMaillage(TYMaillage *pMaillage)
Remove a maillage from calcul.
Definition: TYCalcul.cpp:1398
bool remToSelection(TYUUID id)
Removes the item from the selection of this Calculation.
Definition: TYCalcul.cpp:996
bool isInSelection(TYUUID id)
Tests if the element is present in the selection of this Calculation.
Definition: TYCalcul.cpp:1038
TYTabRay _tabRays
Definition: TYCalcul.h:602
LPTYSpectre getSpectre(const TYUUID &id_pt)
Definition: TYCalcul.cpp:1258
bool operator==(const TYCalcul &other) const
Operator ==.
Definition: TYCalcul.cpp:99
LPTYSiteNode _pSiteCalcul
Site on which the calculation will be carried out.
Definition: TYCalcul.h:581
void clearNoiseMapsSpectrums()
Definition: TYCalcul.cpp:1225
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYCalcul.cpp:177
bool addMaillage(TYMaillage *pMaillage)
Add this maillage to calcul.
Definition: TYCalcul.cpp:1352
QString _auteur
Author name.
Definition: TYCalcul.h:567
TYListID _elementSelection
Array of IDs of elements present in the scene.
Definition: TYCalcul.h:584
bool remPtCtrlFromResult(LPTYPointControl pPoint)
Deletes a checkpoint from the results table.
Definition: TYCalcul.cpp:1198
void setState(int state)
Set editable attribute.
Definition: TYCalcul.h:406
QString _dateCreation
Creation date.
Definition: TYCalcul.h:569
void goPostprocessing()
Definition: TYCalcul.cpp:1055
TYMapIdSpectre getMapPointCtrlSpectre()
Returns map of control points with spectrum.
Definition: TYCalcul.cpp:1426
virtual std::string toString() const
Definition: TYCalcul.cpp:227
QString _comment
Comments.
Definition: TYCalcul.h:573
TYProjet * getProjet()
Definition: TYCalcul.cpp:67
void clearCtrlPointsSpectrums()
Definition: TYCalcul.cpp:1216
bool operator!=(const TYCalcul &other) const
Operator !=.
Definition: TYCalcul.cpp:172
QString _dateModif
Modification date.
Definition: TYCalcul.h:571
bool getKeepRays() const
Returns if computation contains rays or not \ returns true if computation contains rays else returns ...
Definition: TYCalcul.cpp:1335
LPTYSiteNode getSite()
Get calculation site.
Definition: TYCalcul.cpp:891
bool addToSelection(TYUUID id)
Adds the item to the selection of this Calculation.
Definition: TYCalcul.cpp:907
std::vector< LPTYSpectre > * getSpectrumDatas(const TYUUID &id)
Return spectrums for a given noise map.
Definition: TYCalcul.cpp:1340
TYElement * getParent() const
Definition: TYElement.h:706
virtual bool isInCurrentCalcul()
Definition: TYElement.h:539
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:305
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:366
QString _name
Nom courant de l'element.
Definition: TYElement.h:965
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:263
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:542
const TYUUID & getID() const
Definition: TYElement.cpp:176
TYElement * _pParent
Reference sur l'element parent.
Definition: TYElement.h:968
virtual void setInCurrentCalcul(bool state, bool recurschild=true, bool recursparent=true)
Definition: TYElement.cpp:408
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYElement.h:530
void setParent(TYElement *pParent)
Definition: TYElement.h:699
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:379
virtual void setIsAcousticModified(bool isModified)
Definition: TYElement.cpp:248
static TYElement * getInstance(TYUUID uuid)
Definition: TYElement.cpp:158
virtual void setIsGeometryModified(bool isModified)
Definition: TYElement.cpp:253
TYElement * getElement() const
TYTabBatimentGeoNode & getListBatiment()
LPTYUserSourcePonctuelleGeoNode getSrc(int index)
LPTYReseauTransport getResTrans(int index)
TYTabMachineGeoNode & getListMachine()
void getAllSrcs(const TYCalcul *pCalcul, TYMapElementTabSources &mapElementSrcs)
Classe de definition d'un maillage.
Definition: TYMaillage.h:51
TYTabLPPointCalcul & getPtsCalcul()
Set/Get de la liste des points de calcul.
Definition: TYMaillage.h:123
virtual void setEtat(const TYUUID &id_calc, bool etat)
Definition: TYMaillage.cpp:611
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
void enable(bool enable)
Active la generation de nom.
Definition: TYNameManager.h:64
static TYNameManager * get()
Retourne l'instance singleton.
Classe de definition d'un point de calcul.C'est une classe derivee a TYPoint avec en plus un spectrep...
Definition: TYPointCalcul.h:33
virtual LPTYSpectre getSpectre()
Get du spectre resultat d'un calcul donne.
Classe de definition d'un point de controle.Le point de controle est un point de calcul avec une haut...
virtual void setEtat(const TYUUID &id_calc, bool etat)
classe de definition d'un projet.
Definition: TYProjet.h:45
bool addMaillage(LPTYMaillageGeoNode pMaillageGeoNode)
Ajout d'un maillage.
Definition: TYProjet.cpp:837
bool addPointControl(LPTYPointControl pPointControl)
Definition: TYProjet.cpp:448
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
static bool gSaveValues
Definition: TYProjet.h:624
Classe decrivant un rayon acoustique gere par un lancer de rayon. Cette classe doit permettre la mode...
Definition: TYRay.h:35
Classe qui Permet de centraliser les resultats d'un calcul acoustique.
Definition: TYResultat.h:48
void buildMatrix()
Construit la matrice resultat a partir des sources et recepteurs entres.
Definition: TYResultat.cpp:427
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYResultat.cpp:91
void buildMapSourceSpectre()
Build and store powerSpectrum of all sources in calcul.
Definition: TYResultat.cpp:878
void purge()
Reinitialise la matrice resultat.
Definition: TYResultat.cpp:317
bool addRecepteur(TYElement *pRecepteur)
Ajoute un recepteur et indique s'il faut reconstruire la matrice.
Definition: TYResultat.cpp:384
TYMapElementTabSources & getMapEmetteurSrcs()
Retourne le tableau associatif "emetteur/Liste de sources".
Definition: TYResultat.h:253
virtual void reparent()
Definition: TYSiteNode.cpp:569
LPTYInfrastructure getInfrastructure()
Definition: TYSiteNode.h:174
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYSpectre.cpp:142
static int getElementAttributeToInt(DOM_Element parentElem, DOMString attName, bool *ok=NULL)
Definition: TYXMLTools.cpp:293
static bool getElementBoolValue(DOM_Element parentElem, DOMString nodeName, bool &nodeValue)
Definition: TYXMLTools.cpp:179
static bool getElementStringValue(DOM_Element parentElem, DOMString nodeName, QString &nodeValue)
Definition: TYXMLTools.cpp:93
static QString getElementAttributeToString(DOM_Element parentElem, DOMString attName)
Definition: TYXMLTools.cpp:276
static void addElementIntValue(DOM_Element &parentElem, DOMString nodeName, int nodeValue)
Definition: TYXMLTools.cpp:72
static bool getElementFloatValue(DOM_Element parentElem, DOMString nodeName, float &nodeValue)
Definition: TYXMLTools.cpp:211
static bool getElementIntValue(DOM_Element parentElem, DOMString nodeName, int &nodeValue)
Definition: TYXMLTools.cpp:129
static bool getElementDoubleValue(DOM_Element parentElem, DOMString nodeName, double &nodeValue)
Definition: TYXMLTools.cpp:243
static void addElementStringValue(DOM_Element &parentElem, DOMString nodeName, DOMString nodeValue)
Definition: TYXMLTools.cpp:24
std::string intToStr(int val)
Definition: macros.h:158