Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYProjet.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #include "Tympan/core/logging.h"
22 
23 #include "TYProjet.h"
24 
25 #if TY_USE_IHM
28 #endif
29 
32 
33 #define TR(id) OLocalizator::getString("OMessageManager", (id))
34 
35 bool TYProjet::gSaveValues = true;
36 
38  : _auteur(""), _dateCreation("2001-10-01"), _dateModif("2001-10-01"), _comment(""),
39  _pSite(new TYSiteNode()), _pCurrentCalcul(new TYCalcul()), _delaunayTolerance(0.0001),
40  _maxDistBetweenPoints(200.0), _useDefaultGeomVal(true), _bStatusSolver(true)
41 {
43 
44  _pSite->setParent(this);
45  _pSite->setRoot(true);
47  _pSite->setProjet(this); // Definit le projet courant
48 
50  _listCalcul.push_back(_pCurrentCalcul);
51 
52  // Ajout du site au calcul courant
54 
56 }
57 
59 {
60  *this = other;
61 }
62 
64 {
65  remAllCalcul();
66 }
67 
69 {
70  if (this != &other)
71  {
72  TYElement::operator=(other);
73  _auteur = other._auteur;
75  _dateModif = other._dateModif;
76  _comment = other._comment;
77  _pSite = other._pSite;
80  _listCalcul = other._listCalcul;
84  }
85 
87 
88  return *this;
89 }
90 
91 bool TYProjet::operator==(const TYProjet& other) const
92 {
93  if (this != &other)
94  {
95  if (TYElement::operator!=(other))
96  {
97  return false;
98  }
99  if (_auteur != other._auteur)
100  {
101  return false;
102  }
103  if (_dateCreation != other._dateCreation)
104  {
105  return false;
106  }
107  if (_dateModif != other._dateModif)
108  {
109  return false;
110  }
111  if (_comment != other._comment)
112  {
113  return false;
114  }
115  if (_pSite != other._pSite)
116  {
117  return false;
118  }
119  if (_pointsControl != other._pointsControl)
120  {
121  return false;
122  }
123  if (_pCurrentCalcul != other._pCurrentCalcul)
124  {
125  return false;
126  }
127  if (!(_listCalcul == other._listCalcul))
128  {
129  return false;
130  }
132  {
133  return false;
134  }
136  {
137  return false;
138  }
140  {
141  return false;
142  }
143  }
144  return true;
145 }
146 
147 bool TYProjet::operator!=(const TYProjet& other) const
148 {
149  return !operator==(other);
150 }
151 
152 std::string TYProjet::toString() const
153 {
154  return "TYProjet";
155 }
156 
158 {
159  DOM_Element domNewElem = TYElement::toXML(domElement);
160 
161  TYXMLTools::addElementStringValue(domNewElem, "auteur", _auteur);
162  TYXMLTools::addElementStringValue(domNewElem, "dateCreation", _dateCreation);
163  TYXMLTools::addElementStringValue(domNewElem, "dateModif", _dateModif);
164  TYXMLTools::addElementStringValue(domNewElem, "comment", _comment);
165  TYXMLTools::addElementDoubleValue(domNewElem, "delaunayTolerence", _delaunayTolerance);
166  TYXMLTools::addElementDoubleValue(domNewElem, "distMaxBetweenPoints", _maxDistBetweenPoints);
167  TYXMLTools::addElementBoolValue(domNewElem, "useDefGeomVal", _useDefaultGeomVal);
168 
169  if (_pCurrentCalcul)
170  {
171  TYXMLTools::addElementStringValue(domNewElem, "currentCalculID", _pCurrentCalcul->getID().toString());
172  }
173 
174  // Ajout du site node sur lequel s'effectue le calcul
175  DOM_Document domDoc = domElement.ownerDocument();
176 
177  // Site
178  _pSite->toXML(domNewElem);
179 
180  // Points de controle
181  DOM_Element pointsControlNode = domDoc.createElement("PointsControl");
182  domNewElem.appendChild(pointsControlNode);
183  for (unsigned int i = 0; i < _pointsControl.size(); i++)
184  {
185  _pointsControl[i]->toXML(pointsControlNode);
186  }
187 
188  // Noise Maps
189  DOM_Element noiseMapsNode = domDoc.createElement("NoiseMaps");
190  domNewElem.appendChild(noiseMapsNode);
191  for (unsigned int i = 0; i < _maillages.size(); i++)
192  {
193  _maillages[i]->toXML(noiseMapsNode);
194  }
195 
196  // Calculs
197  for (unsigned int i = 0; i < _listCalcul.size(); i++)
198  {
199  _listCalcul.at(i)->toXML(domNewElem);
200  }
201 
202  return domNewElem;
203 }
204 
206 {
207  TYElement::fromXML(domElement);
208 
209  _pCurrentCalcul = nullptr;
210 
211  remAllCalcul();
212 
213  bool auteurOk = false;
214  bool dateCreationOk = false;
215  bool dateModifOk = false;
216  bool commentOk = false;
217  bool currentCalculIDOk = false;
218  bool delaunayOk = false;
219  bool dMaxOk = false;
220  bool useDefaultOk = false;
221 
222  QString currentCalculID;
223  LPTYCalcul pCalcul = new TYCalcul();
224  int readOk = 0; // Indicateur de bonne relecture du calcul
225  int i = 0;
226 
227  DOM_Element elemCur;
228 
229  QDomNodeList childs = domElement.childNodes();
230  int childcount = childs.length();
231  for (i = 0; i < childcount; i++)
232  {
233  elemCur = childs.item(i).toElement();
234  OMessageManager::get()->info("Charge element du projet %d/%d.", i + 1, childcount);
235 
236  TYXMLTools::getElementStringValue(elemCur, "auteur", _auteur, auteurOk);
237  TYXMLTools::getElementStringValue(elemCur, "dateCreation", _dateCreation, dateCreationOk);
238  TYXMLTools::getElementStringValue(elemCur, "dateModif", _dateModif, dateModifOk);
239  TYXMLTools::getElementStringValue(elemCur, "comment", _comment, commentOk);
240  TYXMLTools::getElementStringValue(elemCur, "currentCalculID", currentCalculID, currentCalculIDOk);
241 
242  TYXMLTools::getElementDoubleValue(elemCur, "delaunayTolerence", _delaunayTolerance, delaunayOk);
243  TYXMLTools::getElementDoubleValue(elemCur, "distMaxBetweenPoints", _maxDistBetweenPoints, dMaxOk);
244  TYXMLTools::getElementBoolValue(elemCur, "useDefGeomVal", _useDefaultGeomVal, useDefaultOk);
245 
246  if (_pSite->callFromXMLIfEqual(elemCur))
247  {
249  }
250 
251  // Points de controle
252  LPTYPointControl pPointControl = new TYPointControl();
253  if (elemCur.nodeName() == "PointsControl")
254  {
255  DOM_Element elemCur2;
256  QDomNodeList childs2 = elemCur.childNodes();
257 
258  for (unsigned int j = 0; j < childs2.length(); j++)
259  {
260  elemCur2 = childs2.item(j).toElement();
261  if (pPointControl->callFromXMLIfEqual(elemCur2))
262  {
263  addPointControl(pPointControl);
264  pPointControl = new TYPointControl();
265  }
266  }
267  }
268 
269  // Noise maps
270  LPTYGeometryNode pGeoNode = new TYGeometryNode();
271  if (elemCur.nodeName() == "NoiseMaps")
272  {
273  DOM_Element elemCur2;
274  QDomNodeList childs2 = elemCur.childNodes();
275 
276  for (unsigned int j = 0; j < childs2.length(); j++)
277  {
278  elemCur2 = childs2.item(j).toElement();
279  if (pGeoNode->callFromXMLIfEqual(elemCur2))
280  {
281  addMaillage(pGeoNode);
282  pGeoNode = new TYGeometryNode();
283  }
284  }
285  }
286 
287  // Calculs
288  pCalcul->setParent(this);
289  if (pCalcul->callFromXMLIfEqual(elemCur, &readOk))
290  {
291  // Insure compatibility when loading Code_TYMPAN T310 projects
292  // Enforce pCalcul->_mapPointCtrlSpectre consistency
293  if (pCalcul->getMapPointCtrlSpectre().empty() && !pCalcul->hasResuCtrlPoints())
294  {
295  OMessageManager::get()->info("T310 project migration : enforce receptors configuration "
296  "consistency in calculation settings");
297  for (unsigned int i = 0; i < _pointsControl.size(); i++)
298  {
299  pCalcul->addPtCtrlToResult(_pointsControl[i]);
300  }
301  }
302  addCalcul(pCalcul);
303  pCalcul = new TYCalcul();
304  }
305  }
306 
307  // Mise a jour des parametre pour la triangulation du site
309 
310  // Update TYCalcul control point spectrum if needed
311  // --> compatibility with previous TYPointControl management paradigm (see CS 0a6aab520874@EDF_RD)
312  for (unsigned int i = 0; i < _pointsControl.size(); i++)
313  {
314  if (_pointsControl[i].getRealPointer()->getAllUses() != nullptr)
315  {
316  std::map<TYUUID, LPTYSpectre>* compatibilityVector =
317  static_cast<map<TYUUID, LPTYSpectre>*>(_pointsControl[i].getRealPointer()->getAllUses());
318  std::map<TYUUID, LPTYSpectre>::iterator it;
319  for (it = compatibilityVector->begin(); it != compatibilityVector->end(); it++)
320  {
321  TYCalcul* pCalc = dynamic_cast<TYCalcul*>(getInstance((*it).first));
322  if (pCalc == nullptr)
323  {
324  continue;
325  }
326 
327  TYSpectre* pSpectre = (*it).second;
329  pCalc->setSpectre(_pointsControl[i].getRealPointer(), pSpectre);
330  }
331 
332  // Cleaning map after use
333  compatibilityVector->clear();
334  _pointsControl[i].getRealPointer()->cleanAllUses();
335  compatibilityVector = nullptr;
336  }
337  }
338 
339  // update TYCalcul noise map spectrums if needed
340  // --> compatibility with previous TYMaillage management paradigm
341  for (unsigned int i = 0; i < _maillages.size(); i++)
342  {
343  TYMaillage* pMaillage = dynamic_cast<TYMaillage*>(_maillages[i]->getElement());
344  if (pMaillage->getAllUses() != nullptr)
345  {
346  TYTabLPSpectre* compatibilityVector = static_cast<TYTabLPSpectre*>(pMaillage->getAllUses());
347 
348  // Balayage de tous les calculs
349  for (unsigned j = 0; j < _listCalcul.size(); j++)
350  {
351  if (pMaillage->etat(_listCalcul[j]) == true)
352  {
353  _listCalcul[j]->setNoiseMapSpectrums(pMaillage, *compatibilityVector);
354  }
355  }
356 
357  // Cleaning map after use
358  compatibilityVector->clear();
359  pMaillage->cleanAllUses();
360  compatibilityVector = nullptr;
361  }
362  }
363 
364  // Identification du calcul courant
365  bool bCurrentCalculFound = false;
366  for (i = 0; i < (int)_listCalcul.size(); i++)
367  {
368  if (_listCalcul[i]->getID().toString() == currentCalculID)
369  {
371  bCurrentCalculFound = true;
372  break;
373  }
374  }
375 
376  if (!bCurrentCalculFound && (_listCalcul.size() > 0))
377  {
379  }
380 
381  if (readOk == -1)
382  {
383  return readOk;
384  }
385 
386  // A REVOIR _pElement ne devrait pas renvoyer le projet dans showsources/TYModelerFrame...
387  if (_pSite)
388  {
389  _pSite->update(_pSite);
390  }
391  return 1;
392 }
393 
395 {
396  assert(pPointControl);
397 
398  pPointControl->setParent(this);
399  _pointsControl.push_back(pPointControl);
400 
401  if (getCurrentCalcul()) // Uniquement pour la creation depuis un modeleur
402  {
404  pPointControl); // Le point de controle est actif dans le calcul courant
405  }
406 
407  setIsGeometryModified(true);
408 
409  return true;
410 }
411 
413 {
414  bool ret = false;
415  assert(pPointControl);
416  TYTabLPPointControl::iterator ite;
417 
418  for (ite = _pointsControl.begin(); ite != _pointsControl.end(); ite++)
419  {
420  if ((*ite) == pPointControl)
421  {
422  // Nettoyage des calculs concernes
423  for (unsigned int i = 0; i < this->_listCalcul.size(); i++)
424  {
425  if ((*ite)->etat(_listCalcul[i]) == true)
426  {
427  _listCalcul[i]->remPtCtrlFromResult((*ite));
428  }
429  }
430  _pointsControl.erase(ite);
431  ret = true;
432  setIsGeometryModified(true);
433  break;
434  }
435  }
436 
437  return ret;
438 }
439 
441 {
442  assert(pPoint);
443 
444  // Duplication du point
445  LPTYPointControl pPointCopy = new TYPointControl(*pPoint);
446 
447  // Ajout a la liste des points du projet
448  addPointControl(pPointCopy);
449 
450  return pPointCopy;
451 }
452 
454 {
455  _pointsControl.clear();
456  setIsGeometryModified(true);
457 
458  return true;
459 }
460 
462 {
463  assert(pCalcul);
464 
465  pCalcul->setParent(this);
466  _listCalcul.push_back(pCalcul);
467 
468  return true;
469 }
470 
471 bool TYProjet::remCalcul(const LPTYCalcul pCalcul)
472 {
473  assert(pCalcul);
474  bool ret = false;
475 
476  // On ne peut detruire le calcul courant
477  if (pCalcul == getCurrentCalcul())
478  {
479  return false;
480  }
481 
482  TYTabLPCalcul::iterator ite;
483 
484  for (ite = _listCalcul.begin(); ite != _listCalcul.end(); ite++)
485  {
486  if ((*ite) == pCalcul)
487  {
488  // remove calcul from noise map and control point status list
489  cleanReceptorsStatus((*ite));
490 
491  // Remove calcul from list
492  _listCalcul.erase(ite);
493  ret = true;
494  break;
495  }
496  }
497 
498  return ret;
499 }
500 
501 bool TYProjet::remCalcul(QString idCalcul)
502 {
503  bool ret = false;
504  TYTabLPCalcul::iterator ite;
505 
506  for (ite = _listCalcul.begin(); ite != _listCalcul.end(); ite++)
507  {
508  if ((*ite)->getID().toString() == idCalcul)
509  {
510  return remCalcul((*ite));
511  }
512  }
513 
514  return ret;
515 }
516 
518 {
519  _listCalcul.clear();
520 }
521 
523 {
524  _pSite = NULL;
525 }
526 
528 {
529  assert(pCurCalcul);
530 
531  // On test si le calcul est present dans la liste
532 
533  // Statut solveur ok par defaut
534  _bStatusSolver = true;
535 
536  // Calcul courant
537  _pCurrentCalcul = pCurCalcul;
538 
539  // Test si le solveur du calcul est bien disponible
541  {
542  _bStatusSolver = false;
543  }
544 
545  if (_pSite)
546  {
547  // Le site root associe au projet est obligatoirement actif dans le calcul courant
549  _pSite->setInCurrentCalcul(true, false);
551  _pSite->updateCurrentCalcul(aTYListID, true);
552  }
553 
554  // Mise jour des maillages
555  for (unsigned int i = 0; i < _maillages.size(); i++)
556  {
557  dynamic_cast<TYMaillage*>(_maillages.at(i)->getElement())->updateFromCalcul(_pCurrentCalcul);
558  }
559 
560 #if TY_USE_IHM
561  updateGraphic();
562 #endif
563  setIsGeometryModified(true);
564  setIsAcousticModified(true);
565 }
566 
568 {
569  assert(pPtControl);
570  assert(pAlti);
571 
572  bool modified = true;
573 
574  // On va modifier le point de contrele (l'altitude seulement)
575  // (Utile pour l'update du GraphicObject du maillage)
576  pPtControl->setIsGeometryModified(true);
577 
578  // Init
579  OPoint3D pt;
580 
581  pt._x = pPtControl->_x;
582  pt._y = pPtControl->_y;
583  pt._z = 0.0;
584 
585  // Recherche de l'altitude
586  modified = pAlti->updateAltitude(pt);
587 
588  // Ajout de l'offset en Z
589  pt._z += pPtControl->getHauteur();
590 
591  pPtControl->_z = pt._z;
592 
593  // Le point est maintenant up to date
594  pPtControl->setIsGeometryModified(false);
595 
596  return modified;
597 }
598 
600 {
601  TYAltimetrie* pAlti = getSite()->getAltimetry()._pObj;
602  return updateAltiRecepteurs(pAlti);
603 }
604 
606 {
607  assert(pAlti);
608  bool bNoPbAlti = true;
609  bool modified = false;
610 
611  // Mise a jour de l'altitude pour les points de controle
612  unsigned int i = 0;
613  for (i = 0; i < _pointsControl.size(); i++)
614  {
615  // XXX See ticket https://extranet.logilab.fr/ticket/1484180
616  // The coordinates of the problematic point need to be properly reported
617  // or idealy an exception should be thrown.
618  modified |= updateAltiPointControle(getPointControl(i), pAlti);
619  bNoPbAlti &= modified;
620  }
621 
622  // XXX See ticket https://extranet.logilab.fr/ticket/1484180:
623  // Why handling of PointControle and Recepteur are so different ?
624 
625  // Mise a jour de l'altitude pour les recepteurs du calcul
626  for (unsigned int i = 0; i < _maillages.size(); i++)
627  {
628  updateAltiMaillage(_maillages.at(i), pAlti);
629  }
630 
631  // Done
632  if (!bNoPbAlti)
633  {
634  OMessageManager::get()->info(TR("msg_pbalti"));
635  }
636 
637  setIsGeometryModified(modified);
638  return bNoPbAlti;
639 }
640 
642 {
643  assert(pCalcul);
644 
645  LPTYCalcul pCalculCopy = new TYCalcul();
646 
647  // Duplication
648  // On dit qu'on copie aussi l'ID pour que les ID des elements
649  // composant le calcul soit copiees
650  pCalculCopy->deepCopy(pCalcul, false);
651 
652  // On incremente aussi le numero du calcul
653  pCalculCopy->setNumero(pCalculCopy->getNumero() + 1);
654 
655  // Duplication de l'etat des points de controle
656  duplicatePtCalcState(pCalcul, pCalculCopy);
657 
658  // Duplication de l'tat des cartographies
659  duplicateNoiseMapState(pCalcul, pCalculCopy);
660 
661  // Ajout
662  addCalcul(pCalculCopy);
663 
664  return pCalculCopy;
665 }
666 
667 void TYProjet::duplicatePtCalcState(const TYCalcul* pCalculRef, TYCalcul* pCalculNew)
668 {
669  QString idCalculRef = pCalculRef->getID().toString();
670  QString idCalculNew = pCalculNew->getID().toString();
671 
672  for (unsigned int i = 0; i < _pointsControl.size(); i++)
673  {
674  _pointsControl[i]->duplicateEtat(idCalculRef, idCalculNew);
675  }
676 }
677 
678 void TYProjet::duplicateNoiseMapState(const TYCalcul* pCalculRef, TYCalcul* pCalculNew)
679 {
680  QString idCalculRef = pCalculRef->getID().toString();
681  QString idCalculNew = pCalculNew->getID().toString();
682 
683  for (unsigned int i = 0; i < _maillages.size(); i++)
684  {
685  dynamic_cast<TYMaillage*>(_maillages[i]->getElement())->duplicateEtat(idCalculRef, idCalculNew);
686  }
687 }
688 
690 {
691  for (unsigned int i = 0; i < _listCalcul.size(); i++)
692  {
693  _listCalcul[i]->remToSelection(pElement);
694  }
695 }
696 
697 void TYProjet::remTabElmtFromCalculs(vector<LPTYGeometryNode> tabGeoNode)
698 {
699  for (unsigned int i = 0; i < tabGeoNode.size(); i++)
700  {
701  remElmtFromCalculs(tabGeoNode[i]->getElement());
702  }
703 }
704 
706 {
707 
711 
713 }
714 
716 {
720 }
721 
723 {
724  double delaunay = 0.0001;
725 
726 #if TY_USE_IHM
727  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "DelaunayTolerance"))
728  {
729  delaunay = TYPreferenceManager::getDouble(TYDIRPREFERENCEMANAGER, "DelaunayTolerance");
730  }
731  else
732  {
733  TYPreferenceManager::setDouble(TYDIRPREFERENCEMANAGER, "DelaunayTolerance", delaunay);
734  }
735 #endif
736 
737  return delaunay;
738 }
739 
740 const double TYProjet::getDefaultDMax() const
741 {
742  double DMax = 100.0;
743 
744 #if TY_USE_IHM
745  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "DistMinPtCrbNiv"))
746  {
747  DMax = TYPreferenceManager::getDouble(TYDIRPREFERENCEMANAGER, "DistMinPtCrbNiv");
748  }
749  else
750  {
751  TYPreferenceManager::setDouble(TYDIRPREFERENCEMANAGER, "DistMinPtCrbNiv", DMax);
752  }
753 #endif
754 
755  return DMax;
756 }
757 
758 void TYProjet::setDMax(const double& val)
759 {
760  _maxDistBetweenPoints = val;
762 }
763 
765 {
766  assert(pSite);
767  _pSite = pSite;
768  _pSite->setParent(this);
769  _pSite->setProjet(this);
770  _pSite->setRoot(true); // Ce site est forcemment le site racine
771  _pSite->addToCalcul();
772  setIsGeometryModified(true);
773 }
774 
776 {
777  for (unsigned int i = 0; i < _listCalcul.size(); i++)
778  {
779  _listCalcul[i]->updateMaillage(pMaillage);
780  }
781 }
782 
784 {
785  assert(pMaillageGeoNode);
786  assert(pMaillageGeoNode->getElement());
787 
788  pMaillageGeoNode->setParent(this);
789  pMaillageGeoNode->getElement()->setParent(this);
790 
791  _maillages.push_back(pMaillageGeoNode);
792 
793  // Set in current calcul
794  if (getCurrentCalcul() != nullptr)
795  {
796  getCurrentCalcul()->addMaillage(dynamic_cast<TYMaillage*>(pMaillageGeoNode->getElement()));
797  }
798 
799  setIsGeometryModified(true);
800 
801  return true;
802 }
803 
805 {
806  return addMaillage(new TYMaillageGeoNode((LPTYElement)pMaillage));
807 }
808 
809 bool TYProjet::remMaillage(const LPTYMaillage pMaillage)
810 {
811  assert(pMaillage);
812 
813  TYGeometryNode* pNode = TYGeometryNode::GetGeoNode(dynamic_cast<TYElement*>(pMaillage._pObj));
814 
815  return remMaillage(pNode);
816 }
817 
818 bool TYProjet::remMaillage(const LPTYMaillageGeoNode pMaillageGeoNode)
819 {
820  assert(pMaillageGeoNode);
821  bool ret = false;
822 
823  // Suppression dans tous les calculs
824  for (unsigned int i = 0; i < _listCalcul.size(); i++)
825  {
826  _listCalcul.at(i)->remMaillage(dynamic_cast<TYMaillage*>(pMaillageGeoNode->getElement()));
827  }
828 
829  // Suppression de la liste des maillages du projet
830  TYTabMaillageGeoNode::iterator ite;
831 
832  for (ite = _maillages.begin(); ite != _maillages.end(); ite++)
833  {
834  if ((*ite) == pMaillageGeoNode)
835  {
836  _maillages.erase(ite);
837  ret = true;
838  setIsGeometryModified(true);
839  break;
840  }
841  }
842 
843  return ret;
844 }
845 
846 bool TYProjet::remMaillage(QString idMaillage)
847 {
848  bool ret = false;
849  TYTabMaillageGeoNode::iterator ite;
850 
851  for (ite = _maillages.begin(); ite != _maillages.end(); ite++)
852  {
853  if ((*ite)->getElement()->getID().toString() == idMaillage)
854  {
855  _maillages.erase(ite);
856  ret = true;
857  setIsGeometryModified(true);
858  break;
859  }
860  }
861 
862  return ret;
863 }
864 
866 {
867  _maillages.clear();
868  setIsGeometryModified(true);
869 
870  return true;
871 }
872 
874 {
875  assert(pMaillage);
876  TYTabMaillageGeoNode::iterator ite;
877 
878  for (ite = _maillages.begin(); ite != _maillages.end(); ite++)
879  {
880  if (TYMaillage::safeDownCast((*ite)->getElement()) == pMaillage)
881  {
882  return (*ite);
883  }
884  }
885 
886  return NULL;
887 }
888 
890 {
891 #if TY_USE_IHM
892  for (unsigned int i = 0; i < getMaillages().size(); i++)
893  {
894  TYMaillage* pMaillage = getMaillage(i);
895  pMaillage->getGraphicObject()->update();
896  }
897 #endif
898 }
899 
901 {
902  TYAltimetrie* pAlti = getSite()->getAltimetry()._pObj;
903  return updateAltiMaillage(pMaillageGeoNode, pAlti);
904 }
905 
906 bool TYProjet::updateAltiMaillage(TYMaillageGeoNode* pMaillageGeoNode, const TYAltimetrie* pAlti)
907 {
908  assert(pMaillageGeoNode);
909  assert(pAlti);
910 
911  bool modified = true;
912 
913  if (pMaillageGeoNode == NULL)
914  {
915  return false;
916  }
917 
918  TYPoint pt;
919  TYMaillage* pMaillage = TYMaillage::safeDownCast(pMaillageGeoNode->getElement());
920 
921  if (pMaillage == NULL)
922  {
923  return false;
924  }
925 
926  OMatrix matrix = pMaillageGeoNode->getMatrix();
927  OMatrix matrixinv = matrix.getInvert();
928  TYTabLPPointCalcul& tabpoint = pMaillage->getPtsCalcul();
929 
930  bool bNoPbAlti = true; // Permet de tester si tous les points sont altimtriss correctement.
931 
932  if (pMaillage->getComputeAlti()) // Cas des maillages rectangulaires et lineaires horizontaux
933  {
934 
935 #if TY_USE_IHM
936  TYProgressManager::setMessage("Calcul des altitudes des points de maillage");
937  TYProgressManager::set(static_cast<uint32>(tabpoint.size()));
938 #endif // TY_USE_IHM
939 
940  for (unsigned int i = 0; i < tabpoint.size(); i++)
941  {
942 
943 #if TY_USE_IHM
944  bool cancel = false;
945  TYProgressManager::step(cancel);
946  if (cancel)
947  {
948  break;
949  }
950 #endif // TY_USE_IHM
951 
952  pt = *tabpoint[i];
953  // Passage au repere du site
954  pt = matrix * pt;
955  pt._z = 0;
956 
957  // Recherche de l'altitude
958  bNoPbAlti &= pAlti->updateAltitude(pt);
959 
960  // Retour au repere d'origine
961  pt = matrixinv * pt;
962 
963  // Ajout de l'offset en Z
964  pt._z += pMaillage->getHauteur();
965 
966  // Application du calcul
967  tabpoint[i]->_x = pt._x;
968  tabpoint[i]->_y = pt._y;
969  tabpoint[i]->_z = pt._z;
970  }
971 
972 #if TY_USE_IHM
974 #endif // TY_USE_IHM
975  }
976  else // Cas des maillages verticaux
977  {
978  // Init
979  pt = pMaillageGeoNode->getORepere3D()._origin;
980  pt._z = 0.0;
981 
982  // Recherche de l'altitude
983  bNoPbAlti &= pAlti->updateAltitude(pt);
984 
985  // Ajout de l'offset en Z
986  pt._z += pMaillage->getHauteur();
987 
988  if (pMaillage->isA("TYRectangularMaillage"))
989  {
990  // Ajout d'un offset de la demi-hauteur (maillages verticaux)
991  pt._z += ((TYRectangularMaillage*)pMaillage)->getRectangle()->getSizeY() / 2.0;
992  }
993 
994  pMaillageGeoNode->getORepere3D()._origin._z = pt._z;
995 
996  modified = true;
997  }
998 
999  if (!bNoPbAlti) // Certains point pas altimetrises
1000  {
1001  OMessageManager::get()->info(TR("msg_pbalti"));
1002  }
1003 
1004  // Done
1005  if (modified)
1006  {
1007 #if TY_USE_IHM
1008  pMaillage->updateGraphicTree();
1009 #endif
1010  setIsGeometryModified(true);
1011  }
1012 
1013  return modified;
1014 }
1015 
1017 {
1018  int i = 0, j = 0;
1019 
1020  // Recuperation des volumes
1021  TYInfrastructure* pInfra = pSite->getInfrastructure();
1022  TYTabAcousticVolumeNodeGeoNode tabVolNodeGeoNode;
1023 
1024  // On commence par recuperer la liste des machines et des btiments
1025  // Batiments
1026  for (j = 0; j < static_cast<int>(pInfra->getListBatiment().size()); j++)
1027  {
1028  // Si ce batiment est actif pour le calcul
1029  if (TYBatiment::safeDownCast(pInfra->getBatiment(j)->getElement())->isInCurrentCalcul())
1030  {
1031  tabVolNodeGeoNode.push_back((LPTYAcousticVolumeNodeGeoNode&)pInfra->getListBatiment()[j]);
1032  }
1033  }
1034 
1035  // Machines
1036  for (j = 0; j < static_cast<int>(pInfra->getListMachine().size()); j++)
1037  {
1038  // Si cette machine est active pour le calcul
1039  if (TYMachine::safeDownCast(pInfra->getMachine(j)->getElement())->isInCurrentCalcul())
1040  {
1041  tabVolNodeGeoNode.push_back((LPTYAcousticVolumeNodeGeoNode&)pInfra->getListMachine()[j]);
1042  }
1043  }
1044 
1045  // Ensuite, on verifie si des points du maillage ne sont pas a l'interieur
1046  vector<OPoint3D> tabPts;
1047 
1048  for (i = 0; i < static_cast<int>(getMaillages().size()); i++)
1049  {
1050  TYMaillage* pMaillage = getMaillage(i);
1051  TYMaillageGeoNode* pMaillageGeoNode = getMaillages()[i];
1052 
1053  // Matrice pour la position de ce maillage
1054  OMatrix matrixMaillage = pMaillageGeoNode->getMatrix();
1055  // Nb de points de calcul dans ce maillage
1056  size_t nbPtsCalcul = pMaillage->getPtsCalcul().size();
1057 
1058  tabPts.reserve(nbPtsCalcul); // Reservation du nombre de points pour eviter les mouvements memoire
1059 
1060  for (j = 0; (int)j < nbPtsCalcul; j++)
1061  {
1062  pMaillage->getPtsCalcul()[j]->setEtat(true);
1063  tabPts.push_back(matrixMaillage * (*(pMaillage->getPtsCalcul()[j])));
1064  }
1065 
1066  // Detection des points a l'interieur de volumes
1067  OPoint3D pt;
1068  for (j = 0; j < tabVolNodeGeoNode.size(); j++)
1069  {
1070  OMatrix matrixVolNode = tabVolNodeGeoNode[j]->getMatrix();
1071  matrixVolNode.invert();
1072 
1073  LPTYAcousticVolumeNode pVolumeNode =
1074  TYAcousticVolumeNode::safeDownCast(tabVolNodeGeoNode[j]->getElement());
1075  for (int k = 0; k < nbPtsCalcul; k++)
1076  {
1077  // Passage au repere du volume
1078  pt = matrixVolNode * tabPts[k];
1079 
1080  // Si le point se trouve a l'interieur de ce volume
1081  if (pVolumeNode->isInside(pt))
1082  {
1083  // Desactivation de ce point de calcul
1084  pMaillage->getPtsCalcul()[k]->setEtat(false);
1085  }
1086  }
1087  }
1088 
1089  // Le maillage et son GeoNode sont maintenant up to date
1090  pMaillage->setIsGeometryModified(false);
1091  pMaillageGeoNode->setIsGeometryModified(false);
1092 
1093  // Vidage du tableau de points
1094  tabPts.clear();
1095  }
1096 
1097  tabVolNodeGeoNode.clear();
1098 }
1099 
1101 {
1102  for (unsigned int i = 0; i < _pointsControl.size(); i++)
1103  {
1104  _pointsControl[i]->remEtat(pCalcul);
1105  }
1106 
1107  for (unsigned int i = 0; i < _maillages.size(); i++)
1108  {
1109  dynamic_cast<TYMaillage*>(_maillages[i]->getElement())->remEtat(pCalcul);
1110  }
1111 }
1112 
1114 {
1116  TYElement::updateGraphic();
1117 }
QDomDocument DOM_Document
Definition: QT2DOM.h:33
QDomElement DOM_Element
Definition: QT2DOM.h:30
std::vector< LPTYAcousticVolumeNodeGeoNode > TYTabAcousticVolumeNodeGeoNode
Collection de noeuds geometriques de type TYAcousticVolumeNode.
std::vector< LPTYPointCalcul > TYTabLPPointCalcul
Collection de pointeurs de TYPointCalcul.
Definition: TYDefines.h:358
std::vector< LPTYSpectre > TYTabLPSpectre
Collection de TYSpectre.
Definition: TYDefines.h:337
std::list< TYUUID > TYListID
Collection d'identifiants.
Definition: TYDefines.h:331
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
TYGeometryNode TYMaillageGeoNode
Noeud geometrique de type TYMaillage.
Definition: TYMaillage.h:434
Representation graphique d'un projet (fichier header)
outil IHM pour un projet (fichier header)
TY_EXTENSION_INST(TYProjet)
TY_EXT_GRAPHIC_INST(TYProjet)
#define TR(id)
Definition: TYProjet.cpp:33
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
The 4x4 matrix class.
Definition: 3d.h:625
int invert()
Matrix inversion.
Definition: 3d.cpp:792
OMatrix getInvert(int *ok=0) const
Return the inverse matrix of this matrix.
Definition: 3d.cpp:813
static OMessageManager * get()
Definition: logging.cpp:108
virtual void info(const char *message,...)
Definition: logging.cpp:143
The 3D point class.
Definition: 3d.h:487
virtual const char * getClassName() const
Definition: TYElement.h:249
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
bool isA(const char *className) const
Definition: TYElement.cpp:65
OPoint3D _origin
The origin point.
Definition: 3d.h:1279
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
virtual int isInside(const TYPoint &pt) const
Assigne une altitude a chaque point de l'espace.
Definition: TYAltimetrie.h:35
bool updateAltitude(OPoint3D &pt) const
Modifie l'altitude d'un point donn�. Si le point est hors de la zone dans laquelle l'altim�trie e...
Calculation program.
Definition: TYCalcul.h:50
void setSite(LPTYSiteNode pSite)
Definition of the site on which the calculation will be done.
Definition: TYCalcul.cpp:867
bool addPtCtrlToResult(LPTYPointControl pPoint)
Add a checkpoint to the results array.
Definition: TYCalcul.cpp:1140
TYListID getElementSelection() const
Get the selection of active elements in this Calculation.
Definition: TYCalcul.h:256
bool hasResuCtrlPoints()
Method used for migrating T310 project \ returns true if ResuCtrlPnts exists in xml project else retu...
Definition: TYCalcul.h:543
void setSpectre(const TYUUID &id_pt, TYSpectre *pSpectre)
Definition: TYCalcul.cpp:1256
int getNumero() const
Get the number.
Definition: TYCalcul.h:146
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYCalcul.cpp:178
const OGenID getSolverId() const
Get solver ID.
Definition: TYCalcul.h:465
bool addMaillage(TYMaillage *pMaillage)
Add this maillage to calcul.
Definition: TYCalcul.cpp:1312
void setNumero(int num)
Set the number.
Definition: TYCalcul.h:155
TYMapIdSpectre getMapPointCtrlSpectre()
Returns map of control points with spectrum.
Definition: TYCalcul.cpp:1386
bool addToSelection(TYUUID id)
Adds the item to the selection of this Calculation.
Definition: TYCalcul.cpp:872
static double setDefaultDistMax()
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:368
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
void cleanAllUses()
Definition: TYElement.h:940
void * getAllUses()
Definition: TYElement.h:932
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:265
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:544
const TYUUID & getID() const
Definition: TYElement.cpp:176
virtual void setInCurrentCalcul(bool state, bool recurschild=true, bool recursparent=true)
Definition: TYElement.cpp:410
void setParent(TYElement *pParent)
Definition: TYElement.h:692
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:381
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
const ORepere3D & getORepere3D() const
TYElement * getElement() const
OMatrix getMatrix() const
static TYGeometryNode * GetGeoNode(TYElement *pElement)
TYTabBatimentGeoNode & getListBatiment()
LPTYMachineGeoNode getMachine(int index)
LPTYBatimentGeoNode getBatiment(int index)
TYTabMachineGeoNode & getListMachine()
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
double getHauteur() const
Definition: TYMaillage.h:187
virtual bool etat()
Definition: TYMaillage.cpp:647
bool getComputeAlti() const
Get de l'indicateur de calcul de l'altitude des points de ce maillage.
Definition: TYMaillage.h:207
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
static LPTYPluginManager get()
Classe de definition d'un point de controle.Le point de controle est un point de calcul avec une haut...
double getHauteur() const
Get de la hauteur de ce point par rapport au sol (a l'altimetrie en fait).
static void set(int totalSteps, int stepSize=1)
static void stepToEnd()
classe de definition d'un projet.
Definition: TYProjet.h:45
virtual std::string toString() const
Definition: TYProjet.cpp:152
bool _bStatusSolver
Definition: TYProjet.h:621
TYProjet & operator=(const TYProjet &other)
Operateur =.
Definition: TYProjet.cpp:68
QString _dateCreation
Date de creation.
Definition: TYProjet.h:594
QString _dateModif
Date de modification.
Definition: TYProjet.h:596
void forceUseDefault()
Force l'utilisation des parametres par defaut.
Definition: TYProjet.cpp:715
QString _comment
Commentaires.
Definition: TYProjet.h:598
bool addMaillage(LPTYMaillageGeoNode pMaillageGeoNode)
Ajout d'un maillage.
Definition: TYProjet.cpp:783
TYTabMaillageGeoNode & getMaillages()
Get de la collection de maillages.
Definition: TYProjet.h:261
TYTabLPPointControl _pointsControl
Liste des points de controles.
Definition: TYProjet.h:607
bool operator==(const TYProjet &other) const
Operateur ==.
Definition: TYProjet.cpp:91
TYTabLPCalcul _listCalcul
Liste des Calcul.
Definition: TYProjet.h:604
const double getDefaultDMax() const
Relecture de la distance minimale entre deux points par defaut.
Definition: TYProjet.cpp:740
bool addPointControl(LPTYPointControl pPointControl)
Definition: TYProjet.cpp:394
LPTYCalcul _pCurrentCalcul
Un pointeur sur le Calcul courant.
Definition: TYProjet.h:613
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYProjet.cpp:157
void remElmtFromCalculs(TYElement *pElement)
Supprime un element de tous les calculs.
Definition: TYProjet.cpp:689
bool updateAltiMaillage(TYMaillageGeoNode *pMaillageGeoNode, const TYAltimetrie *pAlti)
Met a niveau l'altimetrie d'un maillage.
Definition: TYProjet.cpp:906
LPTYMaillageGeoNode findMaillage(const LPTYMaillage pMaillage)
Retrouve le GeoNode associe a un maillage.
Definition: TYProjet.cpp:873
bool remAllPointControl()
Definition: TYProjet.cpp:453
void setCurrentCalcul(LPTYCalcul pCurCalcul)
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.cpp:527
void duplicateNoiseMapState(const TYCalcul *pCalculRef, TYCalcul *pCalculNew)
copie l'etat des points de controle pour un calcul pour un autre calcul
Definition: TYProjet.cpp:678
void cleanReceptorsStatus(TYCalcul *pCalcul)
clean status of control points and noise maps
Definition: TYProjet.cpp:1100
QString _auteur
Nom de l'auteur.
Definition: TYProjet.h:592
void selectActivePoint(const LPTYSiteNode pSite)
Selectionne les points actifs du maillage.
Definition: TYProjet.cpp:1016
bool updateAltiRecepteurs()
Definition: TYProjet.cpp:599
void verifGeometricParam()
verification des parametres de geometrisation (si necessaire)
Definition: TYProjet.cpp:705
TYProjet()
Constructeur. Le constructeur de la classe TYProjet.
Definition: TYProjet.cpp:37
TYTabMaillageGeoNode _maillages
Collections de Maillages.
Definition: TYProjet.h:610
bool remPointControl(LPTYPointControl pPointControl)
Definition: TYProjet.cpp:412
const double getDefaultDelaunayTolerence() const
Relecture de la valeur de tolerence de Delaunay par defaut.
Definition: TYProjet.cpp:722
bool remMaillage(const LPTYMaillageGeoNode pMaillageGeoNode)
Suppression d'un maillage.
Definition: TYProjet.cpp:818
bool remAllMaillage()
Suppression de tous les maillages.
Definition: TYProjet.cpp:865
virtual ~TYProjet()
Destructeur Le destructeur de la classe TYProjet .
Definition: TYProjet.cpp:63
double _delaunayTolerance
Parametres de geometrisation.
Definition: TYProjet.h:616
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
LPTYPointControl getPointControl(int index)
Definition: TYProjet.h:232
void setSite(const LPTYSiteNode pSite)
Set du site.
Definition: TYProjet.cpp:764
bool updateAltiPointControle(TYPointControl *pPtControl, const TYAltimetrie *pAlti)
Definition: TYProjet.cpp:567
void remTabElmtFromCalculs(vector< LPTYGeometryNode > tabGeoNode)
Supprime un ensemble d'elements des calculs.
Definition: TYProjet.cpp:697
LPTYSiteNode _pSite
Site.
Definition: TYProjet.h:601
void updateCalculsWithMaillage(TYMaillage *pMaillage)
Definition: TYProjet.cpp:775
bool _useDefaultGeomVal
Definition: TYProjet.h:618
void unsetSite()
Supprime la liaison avec le site.
Definition: TYProjet.cpp:522
double _maxDistBetweenPoints
Definition: TYProjet.h:617
void setDMax(const double &val)
Get/set de la distance max entre les points.
Definition: TYProjet.cpp:758
void duplicatePtCalcState(const TYCalcul *pCalculRef, TYCalcul *pCalculNew)
copie l'etat des points de controle pour un calcul pour un autre calcul
Definition: TYProjet.cpp:667
LPTYMaillage getMaillage(int index)
Retourne un maillage a partir de son index.
Definition: TYProjet.h:318
bool addCalcul(LPTYCalcul pCalcul)
Ajout d'un Calcul a la liste des Calcul.
Definition: TYProjet.cpp:461
LPTYCalcul duplicateCalcul(const LPTYCalcul pCalcul)
Duplique pCalcul.
Definition: TYProjet.cpp:641
virtual void updateGraphic()
Definition: TYProjet.cpp:1113
bool operator!=(const TYProjet &other) const
Operateur !=.
Definition: TYProjet.cpp:147
virtual int fromXML(DOM_Element domElement)
Definition: TYProjet.cpp:205
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:426
static bool gSaveValues
Definition: TYProjet.h:587
LPTYPointControl duplicatePointControl(const LPTYPointControl &pPoint)
Duplique pPoint.
Definition: TYProjet.cpp:440
bool remCalcul(const LPTYCalcul pCalcul)
Suppression d'un Calcul a la liste des Calcul.
Definition: TYProjet.cpp:471
void remAllCalcul()
Suppression de tous les elements.
Definition: TYProjet.cpp:517
void updateGraphicMaillage()
Mets a jour l'objet graphique des maillage apres calcul.
Definition: TYProjet.cpp:889
Classe de definition d'un maillage rectangulaire.
void setProjet(const LPTYProjet pProjet)
Definition: TYSiteNode.cpp:478
LPTYAltimetrie getAltimetry() const
virtual void updateCurrentCalcul(TYListID &listID, bool recursif=true)
Definition: TYSiteNode.cpp:462
virtual void setChildsNotInCurrentCalcul()
void setUseEmpriseAsCrbNiv(bool b)
Definition: TYSiteNode.h:130
LPTYInfrastructure getInfrastructure()
Definition: TYSiteNode.h:173
void update(const bool &force=false)
void setRoot(bool b)
Definition: TYSiteNode.h:319
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYSiteNode.cpp:268
virtual bool addToCalcul()
Definition: TYSiteNode.cpp:429
static void addElementDoubleValue(DOM_Element &parentElem, DOMString nodeName, double nodeValue)
Definition: TYXMLTools.cpp:87
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 bool getElementDoubleValue(DOM_Element parentElem, DOMString nodeName, double &nodeValue)
Definition: TYXMLTools.cpp:243
static void addElementBoolValue(DOM_Element &parentElem, DOMString nodeName, bool nodeValue)
Definition: TYXMLTools.cpp:77
static void addElementStringValue(DOM_Element &parentElem, DOMString nodeName, DOMString nodeValue)
Definition: TYXMLTools.cpp:24
unsigned int uint32
Definition: defines.h:60