17 #pragma warning(disable : 4786)
30 #include "Tympan/models/business/DefaultSolverConfig.h"
42 #define TR(id) OLocalizator::getString("OMessageManager", (id))
44 #define MAX_SOURCES 1024
45 #define MAX_RECEPTEURS 131072
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)
103 if (TYElement::operator!=(other))
217 for (
unsigned int i = 0; i < pOtherCalcul->
_tabRays.size(); i++)
220 aRay->deepCopy(pOtherCalcul->
_tabRays.at(i), copyId);
238 domNewElem.setAttribute(
"isUpTodate",
"1");
242 domNewElem.setAttribute(
"isUpTodate",
"0");
258 TYListID::iterator ite;
259 DOM_Element listIDNode = domDoc.createElement(
"ListID");
260 domNewElem.appendChild(listIDNode);
264 DOM_Element tmpNode = domDoc.createElement(
"Element");
265 listIDNode.appendChild(tmpNode);
267 tmpNode.setAttribute(
"id", (*ite).toString());
271 TYMapPtrElementBool::iterator iter3;
272 DOM_Element emissionAccVolNodesNode = domDoc.createElement(
"EmissionAccVolNodes");
273 domNewElem.appendChild(emissionAccVolNodesNode);
277 DOM_Element tmpNode = domDoc.createElement(
"EmissionAccVolNode");
278 emissionAccVolNodesNode.appendChild(tmpNode);
280 tmpNode.setAttribute(
"accVolNodeId", (*iter3).first->getID().toString());
281 tmpNode.setAttribute(
"state", QString(
intToStr((*iter3).second).c_str()));
285 TYMapPtrElementInt::iterator iter4;
286 DOM_Element regimeAccElementNodesNode = domDoc.createElement(
"RegimeAccNode");
287 domNewElem.appendChild(regimeAccElementNodesNode);
291 DOM_Element tmpNode = domDoc.createElement(
"RegimeAccNode");
292 regimeAccElementNodesNode.appendChild(tmpNode);
294 tmpNode.setAttribute(
"accVolNodeId", (*iter4).first->getID().toString());
295 tmpNode.setAttribute(
"state", QString(
intToStr((*iter4).second).c_str()));
299 DOM_Element resuRecepteursNode = domDoc.createElement(
"ResuCtrlPnts");
300 domNewElem.appendChild(resuRecepteursNode);
301 TYMapIdSpectre::iterator itRec;
304 DOM_Element tmpNode = domDoc.createElement(
"Recepteur");
305 resuRecepteursNode.appendChild(tmpNode);
306 tmpNode.setAttribute(
"receptor_id", (*itRec).first.toString());
307 (*itRec).second->toXML(tmpNode);
311 DOM_Element resuNoiseMapNode = domDoc.createElement(
"ResuNoiseMaps");
312 domNewElem.appendChild(resuNoiseMapNode);
313 TYMapIdTabSpectre::iterator itNM;
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++)
321 (*itNM).second.at(i)->toXML(tmpNode);
333 tmp.
toXML(domNewElem);
337 DOM_Element listRaysNode = domDoc.createElement(
"ListRayons");
338 domNewElem.appendChild(listRaysNode);
339 for (
size_t i = 0; i <
_tabRays.size(); i++)
341 _tabRays.at(i)->toXML(listRaysNode);
355 for (i = 0; i < 19; i++)
369 bool useSol =
false, useEcran =
false, useReflexion =
false;
370 bool condFav =
false, calculTrajetHorizontaux =
false, interference =
false;
371 float h1 = NAN, distanceSRMin = NAN;
381 QDomNodeList childs = domElement.childNodes();
382 for (i = 0; i < childs.length(); i++)
384 elemCur = childs.item(i).toElement();
398 if (elemCur.nodeName() ==
"solverParams")
401 QRegularExpression propaCond_reg(
"(PropaConditions\\s?=\\s?)(True|False)");
402 QRegularExpressionMatch match_propaCond = propaCond_reg.match(
solverParams);
404 if (match_propaCond.hasMatch())
406 QString propaConditions = match_propaCond.captured(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 QRegularExpression useSol_reg(
"UseRealGround=(True|False)"),
474 useEcran_reg(
"UseScreen=(True|False)"), useReflexion_reg(
"UseReflection=(True|False)"),
475 interference_reg(
"ModSummation=(True|False)"),
476 calculTrajetHorizontaux_reg(
"UseLateraDiffraction=(True|False)"),
477 condFav_reg(
"PropaConditions=[0-2]"), h1parameter_reg(
"H1parameter=[0-9]+.[0-9]*"),
478 minSRDistance_reg(
"MinSRDistance=[0-9]+.[0-9]*");
485 solverParams.replace(calculTrajetHorizontaux_reg, useLateralDiffraction);
491 if (elemCur.nodeName() ==
"Atmosphere")
494 double temperature = 0;
495 double hygrometrie = 0;
497 QDomNodeList childs2 = elemCur.childNodes();
499 for (
unsigned int j = 0; j < childs2.length(); j++)
501 elemCur2 = childs2.item(j).toElement();
502 if (elemCur2.nodeName() ==
"pression")
505 QString atmosPressure =
"AtmosPressure=" + QString::number(pression);
506 QRegularExpression atmosPressure_reg(
"AtmosPressure=[0-9]+.[0-9]*");
510 if (elemCur2.nodeName() ==
"temperature")
513 QString atmosTemperature =
"AtmosTemperature=" + QString::number(temperature);
514 QRegularExpression atmosTemperature_reg(
"AtmosTemperature=[0-9]+.[0-9]*");
515 solverParams.replace(atmosTemperature_reg, atmosTemperature);
518 if (elemCur2.nodeName() ==
"hygrometrie")
521 QString atmosHygrometry =
"AtmosHygrometry=" + QString::number(hygrometrie);
522 QRegularExpression atmosHygrometry_reg(
"AtmosHygrometry=[0-9]+.[0-9]*");
523 solverParams.replace(atmosHygrometry_reg, atmosHygrometry);
529 if (elemCur.nodeName() ==
"ListID")
532 QDomNodeList childs2 = elemCur.childNodes();
534 for (
unsigned int j = 0; j < childs2.length(); j++)
536 elemCur2 = childs2.item(j).toElement();
537 if (elemCur2.nodeName() ==
"Element")
540 tempElementSelection.push_back(
id);
544 else if (elemCur.nodeName() ==
"EtatSources")
547 QDomNodeList childs2 = elemCur.childNodes();
549 for (
unsigned int j = 0; j < childs2.length(); j++)
551 elemCur2 = childs2.item(j).toElement();
553 if (elemCur2.nodeName() ==
"EtatSource")
562 _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pSrc, state));
567 else if (elemCur.nodeName() ==
"EmissionAccVolNodes")
570 QDomNodeList childs2 = elemCur.childNodes();
572 for (
unsigned int j = 0; j < childs2.length(); j++)
574 elemCur2 = childs2.item(j).toElement();
576 if (elemCur2.nodeName() ==
"EmissionAccVolNode")
585 _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pAccVolNode, state));
590 else if (elemCur.nodeName() ==
"RegimeAccNode")
593 QDomNodeList childs2 = elemCur.childNodes();
595 for (
unsigned int j = 0; j < childs2.length(); j++)
597 elemCur2 = childs2.item(j).toElement();
599 if (elemCur2.nodeName() ==
"RegimeAccNode")
613 else if (elemCur.nodeName() ==
"ResuCtrlPnts")
616 QDomNodeList childs2 = elemCur.childNodes();
620 for (
unsigned int j = 0; j < childs2.length(); j++)
622 elemCur2 = childs2.item(j).toElement();
623 if (elemCur2.nodeName() ==
"Recepteur")
627 receptor_id.FromString(strReceptor_id);
631 QDomNodeList childs3 = elemCur2.childNodes();
632 for (
unsigned int k = 0; k < childs3.length(); k++)
634 elemCur3 = childs3.item(k).toElement();
646 else if (elemCur.nodeName() ==
"ResuNoiseMaps")
649 QDomNodeList childs2 = elemCur.childNodes();
652 std::vector<LPTYSpectre> tabSpectre;
654 for (
unsigned int j = 0; j < childs2.length(); j++)
656 elemCur2 = childs2.item(j).toElement();
658 if (elemCur2.nodeName() ==
"NoiseMap")
662 QString strnoise_map_id =
665 noise_map_id.FromString(strnoise_map_id);
668 QDomNodeList childs3 = elemCur2.childNodes();
669 for (
unsigned int k = 0; k < childs3.length(); k++)
671 elemCur3 = childs3.item(k).toElement();
676 tabSpectre.push_back(
new TYSpectre(*spectrum));
685 else if (elemCur.nodeName() ==
"ListRayons")
688 QDomNodeList childs2 = elemCur.childNodes();
690 for (
int j = 0; j < childs2.length(); j++)
692 elemCur2 = childs2.item(j).toElement();
693 if (aRay->callFromXMLIfEqual(elemCur2, &retVal))
706 if (elemCur.nodeName() ==
"PointsControl")
709 QDomNodeList childs2 = elemCur.childNodes();
711 for (
unsigned int j = 0; j < childs2.length(); j++)
713 elemCur2 = childs2.item(j).toElement();
716 QDomNodeList childs3 = elemCur2.childNodes();
717 for (
unsigned int k = 0; k < childs3.length(); k++)
719 DOM_Element elemCur3 = childs3.item(k).toElement();
720 if (elemCur3.nodeName() ==
"Spectre")
755 TYListID::iterator next = tempElementSelection.begin();
757 while (next != tempElementSelection.end())
761 next = tempElementSelection.erase(next);
770 for (next = tempElementSelection.begin(); next != tempElementSelection.end(); next++)
779 TYListID::iterator iter;
786 if (pVolNode !=
nullptr)
794 if (pLine !=
nullptr)
799 else if (pElement->
isA(
"TYUserSourcePonctuelle"))
847 TYTabLPPointControl::iterator ite;
898 if (pElt->
isA(
"TYInfrastructure"))
903 else if (
dynamic_cast<TYSiteNode*
>(pElt) !=
nullptr)
934 if (pSource !=
nullptr)
954 for (
int i = 0; i < childs.size(); i++)
992 for (
int i = 0; i < childs.size(); i++)
1006 bool present =
false;
1007 TYListID::iterator ite;
1043 if (
getProjet()->getCurrentCalcul() !=
this)
1119 pRoute->setInCurrentCalcul(
true);
1130 pResTrans->setInCurrentCalcul(
false);
1132 else if ((!pResTrans->isInCurrentCalcul()) &&
1136 pResTrans->setInCurrentCalcul(
true);
1184 TYMapIdSpectre::iterator it;
1193 TYMapIdTabSpectre::iterator it;
1196 for (
unsigned int i = 0; i < (*it).second.size(); i++)
1198 (*it).second.at(i)->deepCopy(
new TYSpectre());
1205 TYMapIdTabSpectre::iterator it;
1206 for (it = otherNoiseMap.begin(); it != otherNoiseMap.end(); it++)
1209 std::vector<LPTYSpectre> tabSpectres;
1210 for (
unsigned int i = 0; i < (*it).second.size(); i++)
1245 (*it).second = pSpectre;
1252 currentSpectre->
deepCopy(pSpectre);
1259 assert(
true &&
"NOT IMPLEMENTED");
1312 return &(*it).second;
1329 std::vector<LPTYSpectre> tabSpectres;
1330 for (
unsigned int i = 0; i < nbPoints; i++)
1354 std::vector<LPTYSpectre> tabSpectres;
1355 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.
bool getKeepRays() const
Returns if computation contains rays or not \ returns true if computation contains rays else returns ...
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)