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);
439 QRegularExpression reflectionOrderParameterReg(
"(ReflectionOrder\\s?=\\s?[0-9]*)");
440 QRegularExpressionMatch matchReflectionOrderReg = reflectionOrderParameterReg.match(
solverParams);
442 if (!matchReflectionOrderReg.hasMatch())
445 QRegularExpression propaCond_reg(
"(PropaConditions\\s?=\\s?[0-9]*)");
446 QRegularExpressionMatch matchPropaCondReg = propaCond_reg.match(
solverParams);
447 if (matchPropaCondReg.hasMatch())
449 QString newParameterStr =
"\nReflectionOrder=1";
450 int insert_pos = matchPropaCondReg.capturedEnd();
457 QRegularExpression dsWindDirection_reg(
"(DSWindDirection\\s?=\\s?[0-9]*)");
458 QRegularExpressionMatch matchDsWindDirectionReg = dsWindDirection_reg.match(
solverParams);
459 if (matchDsWindDirectionReg.hasMatch())
461 QString newParameterStr =
"\nEnableVisibilityPruning=True";
462 int insert_pos = matchDsWindDirectionReg.capturedEnd();
482 if (elemCur.nodeName() ==
"distanceSRMin")
485 QString useSol_str, useEcran_str, useReflexion_str, interference_str, calculTrajetHorizontaux_str;
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;
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);
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]*");
518 solverParams.replace(calculTrajetHorizontaux_reg, useLateralDiffraction);
525 if (elemCur.nodeName() ==
"Atmosphere")
528 double temperature = 0;
529 double hygrometrie = 0;
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() ==
"pression")
539 QString atmosPressure =
"AtmosPressure=" + QString::number(pression);
540 QRegularExpression atmosPressure_reg(
"AtmosPressure=[0-9]+.[0-9]*");
544 if (elemCur2.nodeName() ==
"temperature")
547 QString atmosTemperature =
"AtmosTemperature=" + QString::number(temperature);
548 QRegularExpression atmosTemperature_reg(
"AtmosTemperature=[0-9]+.[0-9]*");
549 solverParams.replace(atmosTemperature_reg, atmosTemperature);
552 if (elemCur2.nodeName() ==
"hygrometrie")
555 QString atmosHygrometry =
"AtmosHygrometry=" + QString::number(hygrometrie);
556 QRegularExpression atmosHygrometry_reg(
"AtmosHygrometry=[0-9]+.[0-9]*");
557 solverParams.replace(atmosHygrometry_reg, atmosHygrometry);
563 if (elemCur.nodeName() ==
"ListID")
566 QDomNodeList childs2 = elemCur.childNodes();
568 for (
unsigned int j = 0; j < childs2.length(); j++)
570 elemCur2 = childs2.item(j).toElement();
571 if (elemCur2.nodeName() ==
"Element")
574 tempElementSelection.push_back(
id);
578 else if (elemCur.nodeName() ==
"EtatSources")
581 QDomNodeList childs2 = elemCur.childNodes();
583 for (
unsigned int j = 0; j < childs2.length(); j++)
585 elemCur2 = childs2.item(j).toElement();
587 if (elemCur2.nodeName() ==
"EtatSource")
596 _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pSrc, state));
601 else if (elemCur.nodeName() ==
"EmissionAccVolNodes")
604 QDomNodeList childs2 = elemCur.childNodes();
606 for (
unsigned int j = 0; j < childs2.length(); j++)
608 elemCur2 = childs2.item(j).toElement();
610 if (elemCur2.nodeName() ==
"EmissionAccVolNode")
619 _emitAcVolNode.insert(TYMapPtrElementBool::value_type(pAccVolNode, state));
624 else if (elemCur.nodeName() ==
"RegimeAccNode")
627 QDomNodeList childs2 = elemCur.childNodes();
629 for (
unsigned int j = 0; j < childs2.length(); j++)
631 elemCur2 = childs2.item(j).toElement();
633 if (elemCur2.nodeName() ==
"RegimeAccNode")
647 else if (elemCur.nodeName() ==
"ResuCtrlPnts")
650 QDomNodeList childs2 = elemCur.childNodes();
654 for (
unsigned int j = 0; j < childs2.length(); j++)
656 elemCur2 = childs2.item(j).toElement();
657 if (elemCur2.nodeName() ==
"Recepteur")
661 receptor_id.FromString(strReceptor_id);
665 QDomNodeList childs3 = elemCur2.childNodes();
666 for (
unsigned int k = 0; k < childs3.length(); k++)
668 elemCur3 = childs3.item(k).toElement();
680 else if (elemCur.nodeName() ==
"ResuNoiseMaps")
683 QDomNodeList childs2 = elemCur.childNodes();
686 std::vector<LPTYSpectre> tabSpectre;
688 for (
unsigned int j = 0; j < childs2.length(); j++)
690 elemCur2 = childs2.item(j).toElement();
692 if (elemCur2.nodeName() ==
"NoiseMap")
696 QString strnoise_map_id =
699 noise_map_id.FromString(strnoise_map_id);
702 QDomNodeList childs3 = elemCur2.childNodes();
703 for (
unsigned int k = 0; k < childs3.length(); k++)
705 elemCur3 = childs3.item(k).toElement();
710 tabSpectre.push_back(
new TYSpectre(*spectrum));
719 else if (elemCur.nodeName() ==
"ListRayons")
722 QDomNodeList childs2 = elemCur.childNodes();
724 for (
int j = 0; j < childs2.length(); j++)
726 elemCur2 = childs2.item(j).toElement();
727 if (aRay->callFromXMLIfEqual(elemCur2, &retVal))
740 if (elemCur.nodeName() ==
"PointsControl")
743 QDomNodeList childs2 = elemCur.childNodes();
745 for (
unsigned int j = 0; j < childs2.length(); j++)
747 elemCur2 = childs2.item(j).toElement();
750 QDomNodeList childs3 = elemCur2.childNodes();
751 for (
unsigned int k = 0; k < childs3.length(); k++)
753 DOM_Element elemCur3 = childs3.item(k).toElement();
754 if (elemCur3.nodeName() ==
"Spectre")
789 TYListID::iterator next = tempElementSelection.begin();
791 while (next != tempElementSelection.end())
795 next = tempElementSelection.erase(next);
804 for (next = tempElementSelection.begin(); next != tempElementSelection.end(); next++)
813 TYListID::iterator iter;
820 if (pVolNode !=
nullptr)
828 if (pLine !=
nullptr)
833 else if (pElement->
isA(
"TYUserSourcePonctuelle"))
881 TYTabLPPointControl::iterator ite;
932 if (pElt->
isA(
"TYInfrastructure"))
937 else if (
dynamic_cast<TYSiteNode*
>(pElt) !=
nullptr)
968 if (pSource !=
nullptr)
988 for (
int i = 0; i < childs.size(); i++)
1026 for (
int i = 0; i < childs.size(); i++)
1040 bool present =
false;
1041 TYListID::iterator ite;
1077 if (
getProjet()->getCurrentCalcul() !=
this)
1153 pRoute->setInCurrentCalcul(
true);
1164 pResTrans->setInCurrentCalcul(
false);
1166 else if ((!pResTrans->isInCurrentCalcul()) &&
1170 pResTrans->setInCurrentCalcul(
true);
1218 TYMapIdSpectre::iterator it;
1227 TYMapIdTabSpectre::iterator it;
1230 for (
unsigned int i = 0; i < (*it).second.size(); i++)
1232 (*it).second.at(i)->deepCopy(
new TYSpectre());
1239 TYMapIdTabSpectre::iterator it;
1240 for (it = otherNoiseMap.begin(); it != otherNoiseMap.end(); it++)
1243 std::vector<LPTYSpectre> tabSpectres;
1244 for (
unsigned int i = 0; i < (*it).second.size(); i++)
1279 (*it).second = pSpectre;
1286 currentSpectre->
deepCopy(pSpectre);
1293 assert(
true &&
"NOT IMPLEMENTED");
1346 return &(*it).second;
1363 std::vector<LPTYSpectre> tabSpectres;
1364 for (
unsigned int i = 0; i < nbPoints; i++)
1388 std::vector<LPTYSpectre> tabSpectres;
1389 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)