17 #pragma warning(disable : 4786)
31 #include "Tympan/models/business/DefaultSolverConfig.h"
43 #define TR(id) OLocalizator::getString("OMessageManager", (id))
45 #define MAX_SOURCES 1024
46 #define MAX_RECEPTEURS 131072
49 : solverParams(DEFAULT_SOLVER_CONFIG), _solverId(
OGenID(
"{A98B320C-44C4-47a9-B689-1DD352DAA8B2}")),
50 _numero(1), _auteur(
"Auteur"), _dateCreation(
"2001-10-01"), _dateModif(
"2001-10-01"),
51 _comment(
"Commentaire"), _upTodate(true), _state(
TYCalcul::Actif), _pResultat(new
TYResultat()),
52 _hasResuCtrlPnts(false)
104 if (TYElement::operator!=(other))
218 for (
unsigned int i = 0; i < pOtherCalcul->
_tabRays.size(); i++)
221 aRay->deepCopy(pOtherCalcul->
_tabRays.at(i), copyId);
239 domNewElem.setAttribute(
"isUpTodate",
"1");
243 domNewElem.setAttribute(
"isUpTodate",
"0");
259 TYListID::iterator ite;
260 DOM_Element listIDNode = domDoc.createElement(
"ListID");
261 domNewElem.appendChild(listIDNode);
265 DOM_Element tmpNode = domDoc.createElement(
"Element");
266 listIDNode.appendChild(tmpNode);
268 tmpNode.setAttribute(
"id", (*ite).toString());
272 TYMapPtrElementBool::iterator iter3;
273 DOM_Element emissionAccVolNodesNode = domDoc.createElement(
"EmissionAccVolNodes");
274 domNewElem.appendChild(emissionAccVolNodesNode);
278 DOM_Element tmpNode = domDoc.createElement(
"EmissionAccVolNode");
279 emissionAccVolNodesNode.appendChild(tmpNode);
281 tmpNode.setAttribute(
"accVolNodeId", (*iter3).first->getID().toString());
282 tmpNode.setAttribute(
"state", QString(
intToStr((*iter3).second).c_str()));
286 TYMapPtrElementInt::iterator iter4;
287 DOM_Element regimeAccElementNodesNode = domDoc.createElement(
"RegimeAccNode");
288 domNewElem.appendChild(regimeAccElementNodesNode);
292 DOM_Element tmpNode = domDoc.createElement(
"RegimeAccNode");
293 regimeAccElementNodesNode.appendChild(tmpNode);
295 tmpNode.setAttribute(
"accVolNodeId", (*iter4).first->getID().toString());
296 tmpNode.setAttribute(
"state", QString(
intToStr((*iter4).second).c_str()));
300 DOM_Element resuRecepteursNode = domDoc.createElement(
"ResuCtrlPnts");
301 domNewElem.appendChild(resuRecepteursNode);
302 TYMapIdSpectre::iterator itRec;
305 DOM_Element tmpNode = domDoc.createElement(
"Recepteur");
306 resuRecepteursNode.appendChild(tmpNode);
307 tmpNode.setAttribute(
"receptor_id", (*itRec).first.toString());
308 (*itRec).second->toXML(tmpNode);
312 DOM_Element resuNoiseMapNode = domDoc.createElement(
"ResuNoiseMaps");
313 domNewElem.appendChild(resuNoiseMapNode);
314 TYMapIdTabSpectre::iterator itNM;
317 DOM_Element tmpNode = domDoc.createElement(
"NoiseMap");
318 resuNoiseMapNode.appendChild(tmpNode);
319 tmpNode.setAttribute(
"noise_map_id", (*itNM).first.toString());
320 for (
unsigned int i = 0; i < (*itNM).second.size(); i++)
322 (*itNM).second.at(i)->toXML(tmpNode);
334 tmp.
toXML(domNewElem);
338 DOM_Element listRaysNode = domDoc.createElement(
"ListRayons");
339 domNewElem.appendChild(listRaysNode);
340 for (
size_t i = 0; i <
_tabRays.size(); i++)
342 _tabRays.at(i)->toXML(listRaysNode);
356 for (i = 0; i < 19; i++)
370 bool useSol =
false, useEcran =
false, useReflexion =
false;
371 bool condFav =
false, calculTrajetHorizontaux =
false, interference =
false;
372 float h1 = NAN, distanceSRMin = NAN;
382 QDomNodeList childs = domElement.childNodes();
383 for (i = 0; i < childs.length(); i++)
385 elemCur = childs.item(i).toElement();
399 if (elemCur.nodeName() ==
"solverParams")
402 QRegExp propaCond_reg(
"(PropaConditions\\s?=\\s?)(True|False)");
406 QString propaConditions = propaCond_reg.cap(2);
408 (propaConditions ==
"True") ? value = 1 : value = 0;
409 solverParams.replace(propaCond_reg,
"PropaConditions=" + QString::number(value));
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())
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();
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())
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);
449 if (elemCur.nodeName() ==
"distanceSRMin")
452 QString useSol_str, useEcran_str, useReflexion_str, interference_str, calculTrajetHorizontaux_str;
454 useSol ? useSol_str =
"True" : useSol_str =
"False";
455 useEcran ? useEcran_str =
"True" : useEcran_str =
"False";
456 useReflexion ? useReflexion_str =
"True" : useReflexion_str =
"False";
457 interference ? interference_str =
"True" : interference_str =
"False";
458 calculTrajetHorizontaux ? calculTrajetHorizontaux_str =
"True"
459 : calculTrajetHorizontaux_str =
"False";
460 condFav ? condPropa = 1 : condPropa = 0;
463 QString useRealGround =
"UseRealGround=" + useSol_str;
464 QString useScreen =
"UseScreen=" + useEcran_str;
465 QString useReflection =
"UseReflection=" + useReflexion_str;
466 QString modSummation =
"ModSummation=" + interference_str;
467 QString useLateralDiffraction =
"UseLateraDiffraction=" + calculTrajetHorizontaux_str;
468 QString propaConditions =
"PropaConditions=" + QString::number(condPropa);
469 QString h1parameter =
"H1parameter=" + QString::number(h1);
470 QString minSRDistance =
"MinSRDistance=" + QString::number(distanceSRMin);
473 QRegExp useSol_reg(
"UseRealGround=(True|False)"), useEcran_reg(
"UseScreen=(True|False)"),
474 useReflexion_reg(
"UseReflection=(True|False)"), interference_reg(
"ModSummation=(True|False)"),
475 calculTrajetHorizontaux_reg(
"UseLateraDiffraction=(True|False)"),
476 condFav_reg(
"PropaConditions=[0-2]"), h1parameter_reg(
"H1parameter=[0-9]+.[0-9]*"),
477 minSRDistance_reg(
"MinSRDistance=[0-9]+.[0-9]*");
484 solverParams.replace(calculTrajetHorizontaux_reg, useLateralDiffraction);
490 if (elemCur.nodeName() ==
"Atmosphere")
493 double temperature = 0;
494 double hygrometrie = 0;
496 QDomNodeList childs2 = elemCur.childNodes();
498 for (
unsigned int j = 0; j < childs2.length(); j++)
500 elemCur2 = childs2.item(j).toElement();
501 if (elemCur2.nodeName() ==
"pression")
504 QString atmosPressure =
"AtmosPressure=" + QString::number(pression);
505 QRegExp atmosPressure_reg(
"AtmosPressure=[0-9]+.[0-9]*");
509 if (elemCur2.nodeName() ==
"temperature")
512 QString atmosTemperature =
"AtmosTemperature=" + QString::number(temperature);
513 QRegExp atmosTemperature_reg(
"AtmosTemperature=[0-9]+.[0-9]*");
514 solverParams.replace(atmosTemperature_reg, atmosTemperature);
517 if (elemCur2.nodeName() ==
"hygrometrie")
520 QString atmosHygrometry =
"AtmosHygrometry=" + QString::number(hygrometrie);
521 QRegExp atmosHygrometry_reg(
"AtmosHygrometry=[0-9]+.[0-9]*");
522 solverParams.replace(atmosHygrometry_reg, atmosHygrometry);
528 if (elemCur.nodeName() ==
"ListID")
531 QDomNodeList childs2 = elemCur.childNodes();
533 for (
unsigned int j = 0; j < childs2.length(); j++)
535 elemCur2 = childs2.item(j).toElement();
536 if (elemCur2.nodeName() ==
"Element")
539 tempElementSelection.push_back(
id);
543 else if (elemCur.nodeName() ==
"EtatSources")
546 QDomNodeList childs2 = elemCur.childNodes();
548 for (
unsigned int j = 0; j < childs2.length(); j++)
550 elemCur2 = childs2.item(j).toElement();
552 if (elemCur2.nodeName() ==
"EtatSource")
561 _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pSrc, state));
566 else if (elemCur.nodeName() ==
"EmissionAccVolNodes")
569 QDomNodeList childs2 = elemCur.childNodes();
571 for (
unsigned int j = 0; j < childs2.length(); j++)
573 elemCur2 = childs2.item(j).toElement();
575 if (elemCur2.nodeName() ==
"EmissionAccVolNode")
584 _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pAccVolNode, state));
589 else if (elemCur.nodeName() ==
"RegimeAccNode")
592 QDomNodeList childs2 = elemCur.childNodes();
594 for (
unsigned int j = 0; j < childs2.length(); j++)
596 elemCur2 = childs2.item(j).toElement();
598 if (elemCur2.nodeName() ==
"RegimeAccNode")
612 else if (elemCur.nodeName() ==
"ResuCtrlPnts")
615 QDomNodeList childs2 = elemCur.childNodes();
619 for (
unsigned int j = 0; j < childs2.length(); j++)
621 elemCur2 = childs2.item(j).toElement();
622 if (elemCur2.nodeName() ==
"Recepteur")
626 receptor_id.FromString(strReceptor_id);
630 QDomNodeList childs3 = elemCur2.childNodes();
631 for (
unsigned int k = 0; k < childs3.length(); k++)
633 elemCur3 = childs3.item(k).toElement();
645 else if (elemCur.nodeName() ==
"ResuNoiseMaps")
648 QDomNodeList childs2 = elemCur.childNodes();
651 std::vector<LPTYSpectre> tabSpectre;
653 for (
unsigned int j = 0; j < childs2.length(); j++)
655 elemCur2 = childs2.item(j).toElement();
657 if (elemCur2.nodeName() ==
"NoiseMap")
661 QString strnoise_map_id =
664 noise_map_id.FromString(strnoise_map_id);
667 QDomNodeList childs3 = elemCur2.childNodes();
668 for (
unsigned int k = 0; k < childs3.length(); k++)
670 elemCur3 = childs3.item(k).toElement();
675 tabSpectre.push_back(
new TYSpectre(*spectrum));
684 else if (elemCur.nodeName() ==
"ListRayons")
687 QDomNodeList childs2 = elemCur.childNodes();
689 for (
int j = 0; j < childs2.length(); j++)
691 elemCur2 = childs2.item(j).toElement();
692 if (aRay->callFromXMLIfEqual(elemCur2, &retVal))
705 if (elemCur.nodeName() ==
"PointsControl")
708 QDomNodeList childs2 = elemCur.childNodes();
710 for (
unsigned int j = 0; j < childs2.length(); j++)
712 elemCur2 = childs2.item(j).toElement();
715 QDomNodeList childs3 = elemCur2.childNodes();
716 for (
unsigned int k = 0; k < childs3.length(); k++)
718 DOM_Element elemCur3 = childs3.item(k).toElement();
719 if (elemCur3.nodeName() ==
"Spectre")
754 TYListID::iterator next = tempElementSelection.begin();
756 while (next != tempElementSelection.end())
760 next = tempElementSelection.erase(next);
769 for (next = tempElementSelection.begin(); next != tempElementSelection.end(); next++)
778 TYListID::iterator iter;
785 if (pVolNode !=
nullptr)
793 if (pLine !=
nullptr)
798 else if (pElement->
isA(
"TYUserSourcePonctuelle"))
846 TYTabLPPointControl::iterator ite;
897 if (pElt->
isA(
"TYInfrastructure"))
902 else if (
dynamic_cast<TYSiteNode*
>(pElt) !=
nullptr)
933 if (pSource !=
nullptr)
953 for (
int i = 0; i < childs.size(); i++)
991 for (
int i = 0; i < childs.size(); i++)
1005 bool present =
false;
1006 TYListID::iterator ite;
1042 if (
getProjet()->getCurrentCalcul() !=
this)
1118 pRoute->setInCurrentCalcul(
true);
1129 pResTrans->setInCurrentCalcul(
false);
1131 else if ((!pResTrans->isInCurrentCalcul()) &&
1135 pResTrans->setInCurrentCalcul(
true);
1183 TYMapIdSpectre::iterator it;
1192 TYMapIdTabSpectre::iterator it;
1195 for (
unsigned int i = 0; i < (*it).second.size(); i++)
1197 (*it).second.at(i)->deepCopy(
new TYSpectre());
1204 TYMapIdTabSpectre::iterator it;
1205 for (it = otherNoiseMap.begin(); it != otherNoiseMap.end(); it++)
1208 std::vector<LPTYSpectre> tabSpectres;
1209 for (
unsigned int i = 0; i < (*it).second.size(); i++)
1244 (*it).second = pSpectre;
1251 currentSpectre->
deepCopy(pSpectre);
1258 assert(
true &&
"NOT IMPLEMENTED");
1306 return &(*it).second;
1323 std::vector<LPTYSpectre> tabSpectres;
1324 for (
unsigned int i = 0; i < nbPoints; i++)
1348 std::vector<LPTYSpectre> tabSpectres;
1349 for (
unsigned int i = 0; i < nbPoints; i++)
QDomDocument DOM_Document
Representation graphique d'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)
std::map< TYUUID, std::vector< SmartPtr< TYSpectre > > > TYMapIdTabSpectre
Tableau associant un id a un tableau de spectres.
std::vector< LPTYSpectre > TYTabLPSpectre
Collection de TYSpectre.
std::list< TYUUID > TYListID
Collection d'identifiants.
std::vector< LPTYElement > LPTYElementArray
TYGeometryNode TYMaillageGeoNode
Noeud geometrique de type TYMaillage.
std::map< TYElement *, TYTabSourcePonctuelleGeoNode > TYMapElementTabSources
void FromString(const char *strUuid)
const QString toString() const
virtual const char * getClassName() const
static OPrototype * safeDownCast(OPrototype *pObject)
bool isA(const char *className) const
void copyNoiseMapSpectrums(TYMapIdTabSpectre &otherNoiseMap)
bool getPtCtrlStatus(const TYUUID &id_pt)
Get the status of a point for this calcul.
LPTYResultat _pResultat
Results.
TYMapIdSpectre _mapPointCtrlSpectre
void setSite(LPTYSiteNode pSite)
Definition of the site on which the calculation will be done.
TYMapPtrElementInt _mapElementRegime
Regime of scene elements.
bool addPtCtrlToResult(LPTYPointControl pPoint)
Add a checkpoint to the results array.
int _numero
Calculation number.
TYMapPtrElementBool _emitAcVolNode
State (radiating/non-radiating) of the elements of the scene.
void purge()
Reset this calculation.
TYCalcul & operator=(const TYCalcul &other)
Operator =.
TYMapIdTabSpectre _noiseMapsSpectrums
void setSpectre(const TYUUID &id_pt, TYSpectre *pSpectre)
int _state
Calculation state Active or Blocked.
void setPtCtrlStatus(const TYUUID &id_pt, bool bStatus)
Set the status of a point for this calcul.
void getCalculElements(LPTYSiteNode pSite)
Recover all the elements of the scene which take part in the calculation.
void setNoiseMapSpectrums(const TYMaillage *pMaillage, TYTabLPSpectre &tabSpectrum)
set spectrum vector for a given noise map
virtual ~TYCalcul()
Destructor. Destructor of the TYCalcul class.
bool _upTodate
Calculation up to date or not.
bool updateMaillage(TYMaillage *pMaillage)
update a noisemap after modification
virtual int fromXML(DOM_Element domElement)
virtual DOM_Element toXML(DOM_Element &domElement)
bool remMaillage(TYMaillage *pMaillage)
Remove a maillage from calcul.
bool remToSelection(TYUUID id)
Removes the item from the selection of this Calculation.
bool isInSelection(TYUUID id)
Tests if the element is present in the selection of this Calculation.
LPTYSpectre getSpectre(const TYUUID &id_pt)
bool operator==(const TYCalcul &other) const
Operator ==.
LPTYSiteNode _pSiteCalcul
Site on which the calculation will be carried out.
void clearNoiseMapsSpectrums()
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
bool addMaillage(TYMaillage *pMaillage)
Add this maillage to calcul.
QString _auteur
Author name.
TYListID _elementSelection
Array of IDs of elements present in the scene.
bool remPtCtrlFromResult(LPTYPointControl pPoint)
Deletes a checkpoint from the results table.
void setState(int state)
Set editable attribute.
QString _dateCreation
Creation date.
TYMapIdSpectre getMapPointCtrlSpectre()
Returns map of control points with spectrum.
virtual std::string toString() const
QString _comment
Comments.
void clearCtrlPointsSpectrums()
bool operator!=(const TYCalcul &other) const
Operator !=.
QString _dateModif
Modification date.
LPTYSiteNode getSite()
Get calculation site.
bool addToSelection(TYUUID id)
Adds the item to the selection of this Calculation.
std::vector< LPTYSpectre > * getSpectrumDatas(const TYUUID &id)
Return spectrums for a given noise map.
TYElement * getParent() const
virtual bool isInCurrentCalcul()
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual DOM_Element toXML(DOM_Element &domElement)
QString _name
Nom courant de l'element.
TYElement & operator=(const TYElement &other)
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
const TYUUID & getID() const
TYElement * _pParent
Reference sur l'element parent.
virtual void setInCurrentCalcul(bool state, bool recurschild=true, bool recursparent=true)
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
void setParent(TYElement *pParent)
virtual int fromXML(DOM_Element domElement)
virtual void setIsAcousticModified(bool isModified)
static TYElement * getInstance(TYUUID uuid)
virtual void setIsGeometryModified(bool isModified)
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.
TYTabLPPointCalcul & getPtsCalcul()
Set/Get de la liste des points de calcul.
virtual void setEtat(const TYUUID &id_calc, bool etat)
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
void enable(bool enable)
Active la generation de nom.
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...
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.
bool addMaillage(LPTYMaillageGeoNode pMaillageGeoNode)
Ajout d'un maillage.
bool addPointControl(LPTYPointControl pPointControl)
LPTYSiteNode getSite()
Get du site.
Classe decrivant un rayon acoustique gere par un lancer de rayon. Cette classe doit permettre la mode...
Classe qui Permet de centraliser les resultats d'un calcul acoustique.
void buildMatrix()
Construit la matrice resultat a partir des sources et recepteurs entres.
virtual DOM_Element toXML(DOM_Element &domElement)
void buildMapSourceSpectre()
Build and store powerSpectrum of all sources in calcul.
void purge()
Reinitialise la matrice resultat.
bool addRecepteur(TYElement *pRecepteur)
Ajoute un recepteur et indique s'il faut reconstruire la matrice.
TYMapElementTabSources & getMapEmetteurSrcs()
Retourne le tableau associatif "emetteur/Liste de sources".
LPTYInfrastructure getInfrastructure()
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
std::string intToStr(int val)