68 if (TYElement::operator!=(other))
97 DOM_Element listSrc = domDoc.createElement(
"ListSources");
98 domNewElem.appendChild(listSrc);
100 TYMapElementIndex ::iterator iteSrc;
103 DOM_Element resultEntry = domDoc.createElement(
"Source");
104 listSrc.appendChild(resultEntry);
107 resultEntry.setAttribute(
"srcId", (*iteSrc).first->getID().toString());
108 resultEntry.setAttribute(
"index", QString(
intToStr((*iteSrc).second).c_str()));
111 DOM_Element listRec = domDoc.createElement(
"ListRecepteurs");
112 domNewElem.appendChild(listRec);
114 TYMapElementIndex::iterator iteRec;
117 DOM_Element resultEntry = domDoc.createElement(
"Recepteur");
118 listRec.appendChild(resultEntry);
121 resultEntry.setAttribute(
"recId", (*iteRec).first->getID().toString());
122 resultEntry.setAttribute(
"index", QString(
intToStr((*iteRec).second).c_str()));
125 DOM_Element listSp = domDoc.createElement(
"ListSpectres");
126 domNewElem.appendChild(listSp);
131 for (
unsigned int i = 0; i < nbMatrixRcpts; i++)
133 for (
unsigned int j = 0; j < nbMatrixSrcs; j++)
135 DOM_Element resultEntry = domDoc.createElement(
"SpectreInd");
136 listSp.appendChild(resultEntry);
139 resultEntry.setAttribute(
"indexRec",
intToStr(i).data());
140 resultEntry.setAttribute(
"indexSrc",
intToStr(j).data());
143 spectre.
toXML(resultEntry);
148 DOM_Element listLw = domDoc.createElement(
"ListLw");
149 domNewElem.appendChild(listLw);
151 std::map<TYElement*, LPTYSpectre>::iterator it;
154 DOM_Element lwEntry = domDoc.createElement(
"SourceLw");
155 listLw.appendChild(lwEntry);
158 lwEntry.setAttribute(
"srcId", (*it).first->getID().toString());
161 (*it).second->toXML(lwEntry);
178 QDomNodeList childs = domElement.childNodes();
179 for (i = 0; i < childs.length(); i++)
181 elemCur = childs.item(i).toElement();
183 if (elemCur.nodeName() ==
"ListSources")
187 QDomNodeList childs2 = elemCur.childNodes();
188 for (
unsigned int j = 0; j < childs2.length(); j++)
190 elemCur2 = childs2.item(j).toElement();
191 if (elemCur2.nodeName() ==
"Source")
205 else if (elemCur.nodeName() ==
"ListRecepteurs")
209 QDomNodeList childs2 = elemCur.childNodes();
210 for (
unsigned int j = 0; j < childs2.length(); j++)
212 elemCur2 = childs2.item(j).toElement();
213 if (elemCur2.nodeName() ==
"Recepteur")
226 QString message =
"One or more receptor(s) not found";
240 for (i = 0; i < childs.length(); i++)
242 elemCur = childs.item(i).toElement();
244 if (elemCur.nodeName() ==
"ListSpectres")
249 QDomNodeList childs2 = elemCur.childNodes();
251 for (
unsigned int j = 0; j < childs2.length(); j++)
253 elemCur2 = childs2.item(j).toElement();
254 int indSrc = 0, indRec = 0;
255 if (elemCur2.nodeName() ==
"SpectreInd")
261 QDomNodeList childs3 = elemCur2.childNodes();
262 for (
unsigned int k = 0; k < childs3.length(); k++)
264 elemCur3 = childs3.item(k).toElement();
269 loadOk &=
setSpectre(indRec, indSrc, *pSpectre);
275 else if (elemCur.nodeName() ==
"ListLw")
279 QDomNodeList childs3 = elemCur.childNodes();
280 for (
unsigned int j = 0; j < childs3.length(); j++)
282 elemCur3 = childs3.item(j).toElement();
284 if (elemCur3.nodeName() ==
"SourceLw")
291 QDomNodeList childs4 = elemCur3.childNodes();
292 for (
unsigned int k = 0; k < childs4.length(); k++)
294 elemCur4 = childs4.item(k).toElement();
334 int idx =
static_cast<int>(
_sources.size());
341 for (
unsigned int i = 0; i < sources.size(); i++)
350 std::vector<SmartPtr<TYElement>> listSources;
351 listSources.reserve(
_sources.size());
352 std::map<TYElement*, int>::iterator it;
363 std::vector<SmartPtr<TYElement>> listReceptors;
365 std::map<TYElement*, int>::iterator it;
371 return listReceptors;
377 for (
unsigned int j = 0; j < recepteurs.size(); j++)
388 bool need_to_rebuild(
false);
391 TYMapElementIndex::iterator it =
_recepteurs.find(pRecepteur);
396 need_to_rebuild =
true;
402 return need_to_rebuild;
409 bool need_to_rebuild(
false);
410 TYMapElementIndex::iterator it =
_recepteurs.find(pRecepteur);
414 need_to_rebuild =
true;
418 unsigned int index = 0;
421 (*it).second = index;
424 return need_to_rebuild;
439 int indexSource =
_sources[pSource];
454 matrix(indexRecepteur, indexSource) =
Spectre;
468 int indexSource =
_sources[pSource];
472 return getSpectre(indexRecepteur, indexSource);
477 return _matrix(indexRecepteur, indexSource);
508 TYMapElementIndex::iterator iter;
512 while (((*iter).second != indexSource) && (iter !=
_sources.end()))
529 TYMapElementIndex::iterator iter;
533 while (((*iter).second != indexSource) && (iter !=
_backupSources.end()))
550 TYMapElementIndex::iterator iter;
554 while ((iter !=
_recepteurs.end()) && ((*iter).second != indexRecepteur))
571 QFile outputFile(filename);
573 if (outputFile.open(QFile::WriteOnly))
575 QTextStream outStream(&outputFile);
576 outStream.setRealNumberPrecision(2);
577 outStream.setRealNumberNotation(QTextStream::FixedNotation);
582 int nbSpectre = nbSources;
584 std::vector<OSpectre> tabSpectre;
585 tabSpectre.reserve(nbSpectre);
588 for (
int col = 0; col < nbRecepteurs; ++col)
603 if (pSubstCalcul != NULL)
610 tabSpectre.push_back(spectre);
613 for (
int row = 0; row < nbSources; ++row)
621 spectre = spectre.
toDB();
623 tabSpectre.push_back(spectre);
627 for (
int i = 0; i < 31; ++i)
630 outStream <<
tabFreq[i] <<
";";
632 for (
unsigned int j = 0; j < tabSpectre.size(); j++)
634 outStream << tabSpectre[j].getTabValReel()[i] <<
";";
659 str <<
"Calcul" <<
';';
661 str << pCalcul->
getName() <<
';';
680 return spectre.
sumdB(substSpectre);
685 const double& BdF = val2;
686 const double& bP = val1;
689 return bruitAmbiant - BdF;
694 const double& BdF = val2;
695 const double& bP = val1;
696 return 10.0 * ::log10(::pow(10.0, (bP / 10.0)) + ::pow(10.0, (BdF / 10.0)));
701 QFile outputFile(filename);
702 if (outputFile.open(QFile::WriteOnly))
704 QTextStream outStream(&outputFile);
705 outStream.setRealNumberPrecision(2);
706 outStream.setRealNumberNotation(QTextStream::FixedNotation);
718 outStream <<
"dBZ" <<
';';
721 outStream <<
"dB(" << freq <<
"Hz)" <<
';';
725 outStream <<
"dBA" <<
';';
728 outStream <<
"LW" <<
';';
732 for (col = 0; col < nbRecepteurs; ++col)
745 outStream <<
"Synthese" <<
';' <<
';';
746 for (col = 0; col < nbRecepteurs; ++col)
772 std::list<SortElement> sortArray;
773 for (
int row = 0; row < nbSources; ++row)
778 if (pSource !=
nullptr)
785 if (pVolNode !=
nullptr)
815 sortArray.push_back(pair);
820 for (std::list<SortElement>::iterator it = sortArray.begin(); it != sortArray.end(); ++it)
823 outStream << it->value <<
';';
824 for (col = 0; col < nbRecepteurs; ++col)
828 spectre = spectre.
toDB();
861 std::map<TYElement*, int>::iterator it;
866 if (pSource !=
nullptr)
873 if (pVolNode !=
nullptr)
QDomDocument DOM_Document
std::vector< LPTYPointCalculGeoNode > TYTabPointCalculGeoNode
Collection de noeuds geometriques de type TYPointCalcul.
Representation graphique des resultats (fichier header)
TY_EXTENSION_INST(TYResultat)
TY_EXT_GRAPHIC_INST(TYResultat)
const std::vector< double > tabFreq
std::vector< LPTYSourcePonctuelleGeoNode > TYTabSourcePonctuelleGeoNode
Collection de noeuds geometriques de type TYSourcePonctuelle.
OTabFreq TYTabFreq
Collection des frequences.
virtual void error(const char *message,...)
static OMessageManager * get()
virtual const char * getClassName() const
static OPrototype * safeDownCast(OPrototype *pObject)
OSpectreAbstract & subst(const OSpectreAbstract &spectre) const
Arithmetic subtraction of two spectrums in one-third Octave.
double valGlobDBA() const
Compute the global value dB[A] of a one-third Octave spectrum.
double valGlobDBLin() const
Compute the global value dB[Lin] of a one-third Octave spectrum.
void setType(TYSpectreType type)
Set the spectrum type.
void setValid(const bool &valid=true)
OSpectreAbstract & toDB() const
Converts to dB.
bool isValid() const
Check the spectrum validity. Invalidity is caused by: corrupted data, impossible calculation.
OSpectreAbstract & sumdB(const OSpectreAbstract &spectre) const
Energetic sum of two spectrums.
double getValueReal(double freq)
T * _pObj
The real pointer, must derived IRefCount.
virtual LPTYSpectre getRealPowerSpectrum()
virtual LPTYSpectre getRealPowerSpectrum()
LPTYSpectre getSpectre(const TYUUID &id_pt)
TYElement * getParent() const
static void setLogInstances(bool log)
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
virtual QString getName() const
virtual int fromXML(DOM_Element domElement)
virtual void setIsAcousticModified(bool isModified)
static TYElement * getInstance(TYUUID uuid)
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
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...
Classe qui Permet de centraliser les resultats d'un calcul acoustique.
std::vector< LPTYElement > getSources()
return the list of all sources (business sources)
void buildMatrix()
Construit la matrice resultat a partir des sources et recepteurs entres.
std::map< TYElement *, LPTYSpectre > _mapElementSpectre
Les spectres de puissance associe a chaque source.
void addSource(TYElement *pSource)
Ajoute une source.
LPTYPointCalcul getRecepteur(const int &indexRecepteur)
Retourne le recepteur corresponadnt a l'indice passe.
virtual ~TYResultat()
Destructeur. Le destructeur de la classe TYResultat .
virtual DOM_Element toXML(DOM_Element &domElement)
void buildSources(const TYTabSourcePonctuelleGeoNode &sources)
Construit la liste des sources.
bool remRecepteur(TYPointCalcul *pRecepteur)
Supprime un recepteur du tableau et indique s'il faut reconstruire la matrice.
void setPartialState(const bool &bPartial)
Get/Set du parametre de conservation de la matrice brut _bPartial.
size_t getNbOfRecepteurs() const
Retourne le nombre de recepteurs.
tympan::SpectrumMatrix _matrix
La matrice de resultat.
bool _bPartial
Sauvegarde de la matrice brute.
void saveValue(const QString &filename, const int &affichage, double freq=100)
Sauvegarde des valeurs dans un fichier affichage : false -> dBA et true -> dBLin.
bool operator==(const TYResultat &other) const
Operateur ==.
void buildMapSourceSpectre()
Build and store powerSpectrum of all sources in calcul.
LPTYElement getSource(const int &indexSource)
Retourne la source correspondant a l'indice passe.
void saveSpectre(const QString &filename, TYCalcul *pSubstCalcul=NULL)
Sauvegarde des spectres dans un fichier.
void purge()
Reinitialise la matrice resultat.
OSpectre getEmergence(OSpectre &spectre, OSpectre &substSpectre)
Renvoit la difference entre 2 resultats de calcul (spectre)
bool setSpectre(TYElement *pRecepteur, TYElement *pSource, OSpectre &Spectre)
Assigne un spectre a un couple S-R.
bool addRecepteur(TYElement *pRecepteur)
Ajoute un recepteur et indique s'il faut reconstruire la matrice.
TYResultat()
Constructeur. Le constructeur de la classe TYResultat.
TYMapElementIndex _recepteurs
Les recepteurs contenus dans la matrice resultat.
bool operator!=(const TYResultat &other) const
Operateur !=.
LPTYElement getElementSource(const int &indexSource)
Retourne la source elementaire correspondant a l'indice passe.
tympan::SpectrumMatrix _backupMatrix
OSpectre getAmbiant(OSpectre &spectre, OSpectre &substSpectre)
Renvoi du bruit ambiant.
TYMapElementIndex _backupSources
TYMapElementTabSources _mapEmetteurSources
Tableau associatif "emetteur"/liste des sources de l'emetteur.
void remSpectres(TYPointCalcul *pRecepteur)
Efface les spectres d'un recepteur donne.
void buildRecepteurs(const TYTabPointCalculGeoNode &sources)
Construit la liste des sources.
TYMapElementIndex _sources
Les sources contenues dans la matrice resultat.
bool _hideLW
Show / hide power spectrum in result matrix.
void saveParamValue(QTextStream &ofs, TYCalcul *pCalcul)
virtual std::string toString() const
std::vector< LPTYElement > getReceptors()
return the list of all sources (business sources)
TYResultat & operator=(const TYResultat &other)
Operateur =.
OTabSpectre getSpectres(TYPointCalcul *pRecepteur)
Retourne les spectres pour un recepteur donne.
OSpectre getSpectre(TYElement *pRecepteur, TYElement *pSource)
Retourne un spectre pour un couple S-R.
const OSpectre & getElementSpectre(int indexRecepteur, int indexSource) const
Retourne le spectre de la matrice brute (avant condensation)pour un couple S-R (S = Source elementair...
size_t getNbOfSources() const
Retourne le nombre de sources.
virtual int fromXML(DOM_Element domElement)
virtual DOM_Element toXML(DOM_Element &domElement)
static const TYTabFreq getTabFreqNorm(TYSpectreForm form=SPECTRE_FORM_TIERS)
LPTYSpectre getRealPowerSpectrum()
Spectrum matrix N*M used to store results. N is the number of receptors. M is the number of sources.
const std::vector< Spectrum > & by_receptor(size_t receptor_idx) const
Return a vector of Spectrum for a receptor.
void clear()
Clear the matrix.
size_t nb_sources() const
Number of columns (sources) of the matrix.
void clearReceptor(size_t receptor_idx)
Clear the matrix for the a given receptor.
size_t nb_receptors() const
Number of rows (receptors) of the matrix.
std::string intToStr(int val)
std::vector< OSpectre > OTabSpectre
Spectrums vector.
bool operator<(const SortElement &rhs)