Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYSiteNode.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #include <cstdlib>
17 #include <cassert>
18 #include <locale.h>
19 
20 #if TY_USE_IHM
23 #endif
24 
33 #include "Tympan/core/logging.h"
34 #include "Tympan/core/config.h"
35 #include <QDir>
36 
37 #include "TYSiteNode.h"
38 
39 #define TR(id) OLocalizator::getString("OMessageManager", (id))
40 
43 
44 bool almost_equal(double a, double b, double precision);
45 
46 #include <cstdio>
47 #include <QString>
48 
49 /*static*/ const QString& TYSiteNode::getTopoFilePath()
50 {
51  return _topoFilePath;
52 }
53 
54 /*static*/ void TYSiteNode::setTopoFilePath(const QString& path)
55 {
56  _topoFilePath = path;
57 }
58 
60 {
61  return _meshFilePath;
62 }
63 
64 void TYSiteNode::setMeshFilePath(const QString& path)
65 {
66  _meshFilePath = path;
67 }
68 
69 QString TYSiteNode::_topoFilePath = "";
70 
72  : _pProjet(NULL), _bEmpriseAsCrbNiv(false), _altiEmprise(0.0), _useTopoFile(0), _topoFileName(""),
73  _meshFilePath(""), _topoFileExtension(""), _echelle(1.0f), _nbFaceInfra(0), _root(false),
74  _SIGType(TYMPAN), _SIG_X(0.0), _SIG_Y(0.0), _SIG_OFFSET(0.0), _isTopoFileModified(false)
75 {
77 
78 #ifdef _WIN32
79  // CLM-NT35: Pb en debug avec string cast
80  QByteArray id = getStringID().toLatin1();
81  _topoFile = getTopoFilePath() + "/image_" + id.constData();
82 #else
83  _topoFile = getTopoFilePath() + "/image_" + getStringID().toLatin1().data();
84 #endif
85 
87  _pTopographie->setParent(this);
90 }
91 
93 {
94  *this = other;
95 }
96 
98 {
99  _listSiteNode.clear();
100 }
101 
103 {
104  if (this != &other)
105  {
106  TYElement::operator=(other);
107  _echelle = other._echelle;
109  _altiEmprise = other._altiEmprise;
111  _topoFile = other._topoFile;
115  _useTopoFile = other._useTopoFile;
118  _orientation = other._orientation;
119  _position = other._position;
120  _root = other._root;
122  _SIGType = other._SIGType;
123  _SIG_X = other._SIG_X;
124  _SIG_Y = other._SIG_Y;
125  _SIG_OFFSET = other._SIG_OFFSET;
126  }
127  return *this;
128 }
129 
130 bool TYSiteNode::operator==(const TYSiteNode& other) const
131 {
132  if (this != &other)
133  {
134  if (TYElement::operator!=(other))
135  {
136  return false;
137  }
138  if (_echelle != other._echelle)
139  {
140  return false;
141  }
143  {
144  return false;
145  }
146  if (_altiEmprise != other._altiEmprise)
147  {
148  return false;
149  }
150  if (_pTopographie != other._pTopographie)
151  {
152  return false;
153  }
154  if (_topoFile != other._topoFile)
155  {
156  return false;
157  }
158  if (_topoFileName != other._topoFileName)
159  {
160  return false;
161  }
162  if (_meshFilePath != other._meshFilePath)
163  {
164  return false;
165  }
167  {
168  return false;
169  }
170  if (_useTopoFile != other._useTopoFile)
171  {
172  return false;
173  }
175  {
176  return false;
177  }
178  if (_pInfrastructure != other._pInfrastructure)
179  {
180  return false;
181  }
182  if (_orientation != other._orientation)
183  {
184  return false;
185  }
186  if (_position != other._position)
187  {
188  return false;
189  }
190  if (_root != other._root)
191  {
192  return false;
193  }
194  if (!(_listSiteNode == other._listSiteNode))
195  {
196  return false;
197  }
198  if (_SIGType != other._SIGType)
199  {
200  return false;
201  }
202  if (_SIG_X != other._SIG_X)
203  {
204  return false;
205  }
206  if (_SIG_Y != other._SIG_Y)
207  {
208  return false;
209  }
210  if (_SIG_OFFSET != other._SIG_OFFSET)
211  {
212  return false;
213  }
214  }
215  return true;
216 }
217 
218 bool TYSiteNode::operator!=(const TYSiteNode& other) const
219 {
220  return !operator==(other);
221 }
222 
223 bool TYSiteNode::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
224 {
225  if (!TYElement::deepCopy(pOther, copyId))
226  {
227  return false;
228  }
229 
230  TYSiteNode* pOtherSite = (TYSiteNode*)pOther;
231 
232  _echelle = pOtherSite->_echelle;
233  _bEmpriseAsCrbNiv = pOtherSite->_bEmpriseAsCrbNiv;
234  _altiEmprise = pOtherSite->_altiEmprise;
235  _topoFile = pOtherSite->_topoFile;
236  _topoFileName = pOtherSite->_topoFileName;
237  _meshFilePath = pOtherSite->_meshFilePath;
239  _useTopoFile = pOtherSite->_useTopoFile;
241  _pTopographie->deepCopy(pOtherSite->_pTopographie, copyId);
242  _pTopographie->setParent(this);
243  _pInfrastructure->deepCopy(pOtherSite->_pInfrastructure, copyId);
245  _orientation.deepCopy(&pOtherSite->_orientation, copyId);
246  _position.deepCopy(&pOtherSite->_position, copyId);
247  _root = pOtherSite->_root;
248  _SIGType = pOtherSite->_SIGType;
249  _SIG_X = pOtherSite->_SIG_X;
250  _SIG_Y = pOtherSite->_SIG_Y;
251  _SIG_OFFSET = pOtherSite->_SIG_OFFSET;
252 
253  _listSiteNode.clear();
254  for (unsigned int i = 0; i < pOtherSite->_listSiteNode.size(); i++)
255  {
256  LPTYSiteNodeGeoNode pSiteNodeGeoNode = new TYSiteNodeGeoNode(NULL, this);
257  pSiteNodeGeoNode->deepCopy(pOtherSite->_listSiteNode[i], copyId);
258  pSiteNodeGeoNode->getElement()->setParent(this);
259  pSiteNodeGeoNode->setParent(this);
260  _listSiteNode.push_back(pSiteNodeGeoNode);
261  }
262 
263  return true;
264 }
265 
266 std::string TYSiteNode::toString() const
267 {
268  return "TYSiteNode";
269 }
270 
272 {
273  DOM_Element domNewElem = TYElement::toXML(domElement);
274 
275  TYXMLTools::addElementFloatValue(domNewElem, "echelle", _echelle);
276  TYXMLTools::addElementBoolValue(domNewElem, "useEmpriseAsCrbNiv", _bEmpriseAsCrbNiv);
277  TYXMLTools::addElementBoolValue(domNewElem, "useTopoFile", _useTopoFile);
278 
279  if (TYXMLManager::getSavedFileName() == QString(""))
280  {
281  TYXMLTools::addElementStringValue(domNewElem, "topoFile", _topoFileName);
282  TYXMLTools::addElementStringValue(domNewElem, "meshFile", _meshFilePath);
283  }
284  else // si non, on ecrit le chemin relatif
285  {
286  QString xmlFile = TYXMLManager::getSavedFileName().replace('\\', '/');
287  QDir xmlFileDir = QDir(xmlFile.left(xmlFile.lastIndexOf('/')));
288  if (xmlFileDir.exists())
289  {
290  TYXMLTools::addElementStringValue(domNewElem, "topoFile",
291  xmlFileDir.relativeFilePath(_topoFileName));
292  TYXMLTools::addElementStringValue(domNewElem, "meshFile",
293  xmlFileDir.relativeFilePath(_meshFilePath));
294  }
295  else
296  {
297  TYXMLTools::addElementStringValue(domNewElem, "topoFile", _topoFileName);
298  TYXMLTools::addElementStringValue(domNewElem, "topoFile", _meshFilePath);
299  }
300  }
301 
302  TYXMLTools::addElementDoubleValue(domNewElem, "altiEmprise", _altiEmprise);
303 
304  _orientation.toXML(domNewElem);
305  _position.toXML(domNewElem);
306 
307  _pTopographie->toXML(domNewElem);
308  _pInfrastructure->toXML(domNewElem);
309 
310  TYXMLTools::addElementIntValue(domNewElem, "root", _root);
311  TYXMLTools::addElementIntValue(domNewElem, "repere", _SIGType);
312  TYXMLTools::addElementDoubleValue(domNewElem, "SIG_X", _SIG_X);
313  TYXMLTools::addElementDoubleValue(domNewElem, "SIG_Y", _SIG_Y);
314  TYXMLTools::addElementDoubleValue(domNewElem, "SIG_OFFSET", _SIG_OFFSET);
315 
316  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
317  {
318  _listSiteNode[i]->toXML(domNewElem);
319  }
320 
321  return domNewElem;
322 }
323 
325 {
326  TYElement::fromXML(domElement);
327 
328  bool echelleOk = false;
329  QString topoFile;
330  QString meshFile;
331  bool topoFileOk = false;
332  bool meshFileOk = false;
333  bool empriseAsCrbNivOk = false;
334  bool altiEmpriseOk = false;
335  bool useTopoFileOk = false;
336  DOM_Element elemCur;
337 
338  QDomNodeList childs = domElement.childNodes();
339  unsigned int childcount = childs.length();
340  for (unsigned int i = 0; i < childcount; i++)
341  {
342  elemCur = childs.item(i).toElement();
343  OMessageManager::get()->info("Charge element de site %d/%d.", i + 1, childcount);
344 
345  TYXMLTools::getElementFloatValue(elemCur, "echelle", _echelle, echelleOk);
346  TYXMLTools::getElementBoolValue(elemCur, "useEmpriseAsCrbNiv", _bEmpriseAsCrbNiv, empriseAsCrbNivOk);
347  TYXMLTools::getElementBoolValue(elemCur, "useTopoFile", _useTopoFile, useTopoFileOk);
348  TYXMLTools::getElementStringValue(elemCur, "topoFile", topoFile, topoFileOk);
349  TYXMLTools::getElementStringValue(elemCur, "meshFile", meshFile, meshFileOk);
350  TYXMLTools::getElementDoubleValue(elemCur, "altiEmprise", _altiEmprise, altiEmpriseOk);
351 
353  _position.callFromXMLIfEqual(elemCur);
354 
357  }
358 
359  purge(); // On vide le tableau des sous-sites
360 
361  bool rootOk = false;
362  bool repereOk = false;
363  bool SIG_XOk = false;
364  bool SIG_YOk = false;
365  bool SIG_OFFSETOk = false;
366  int SIGType = 0;
367 
368  LPTYSiteNodeGeoNode pSiteNodeGeoNode = new TYSiteNodeGeoNode(NULL, this);
369  // DOM_Element elemCur;
370 
371  // QDomNodeList childs = domElement.childNodes();
372  for (unsigned int i = 0; i < childs.length(); i++)
373  {
374  elemCur = childs.item(i).toElement();
375  TYXMLTools::getElementBoolValue(elemCur, "root", _root, rootOk);
376  TYXMLTools::getElementIntValue(elemCur, "repere", SIGType, repereOk);
377  TYXMLTools::getElementDoubleValue(elemCur, "SIG_X", _SIG_X, SIG_XOk);
378  TYXMLTools::getElementDoubleValue(elemCur, "SIG_Y", _SIG_Y, SIG_YOk);
379  TYXMLTools::getElementDoubleValue(elemCur, "SIG_OFFSET", _SIG_OFFSET, SIG_OFFSETOk);
380 
381  if (pSiteNodeGeoNode->callFromXMLIfEqual(elemCur))
382  {
383  addSiteNode(pSiteNodeGeoNode);
384  pSiteNodeGeoNode = new TYSiteNodeGeoNode(NULL, this);
385  }
386  }
387 
388  _SIGType = (systemSIG)SIGType;
389 
390  if (_useTopoFile && topoFileOk)
391  {
392  _topoFileName = topoFile;
395  }
397  if (meshFileOk)
398  {
399  // 1) Normalisation et traces d’entrée
400  const QString meshFileNorm = QDir::fromNativeSeparators(meshFile);
401 
402  // 2) Récupération du dossier du XML
403  QString xmlDir;
404  const QString saved = QDir::fromNativeSeparators(TYXMLManager::getSavedFileName());
405 
406  if (!saved.isEmpty())
407  {
408  const QFileInfo sfi(saved);
409  const bool savedIsDir = sfi.isDir();
410  const QString candidate = savedIsDir ? sfi.absoluteFilePath() : sfi.absolutePath();
411  const bool candidateExists = QDir(candidate).exists();
412 
413  if (candidateExists)
414  {
415  xmlDir = candidate;
416  }
417  }
418 
419  // 3) Décision du chemin mesh : absolu VS relatif
420  const QFileInfo mfi(meshFileNorm);
421  const bool isAbs = mfi.isAbsolute();
422  if (isAbs)
423  {
424  _meshFilePath = mfi.absoluteFilePath();
425  }
426  else if (!xmlDir.isEmpty())
427  {
428  _meshFilePath = QDir(xmlDir).filePath(meshFileNorm);
429  }
430  else
431  {
432  _meshFilePath = meshFileNorm;
433  }
434 
435  // 4) Lancement de la lecture + traces tailles
436  std::deque<OPoint3D> points;
437  std::deque<OTriangle> triangles;
438  std::deque<LPTYSol> materials;
439 
440  logger->debug("[DBG][fromXML] Appel readMesh(...) avec _meshFilePath = %s",
441  qUtf8Printable(_meshFilePath));
442  if (readMesh(points, triangles, materials, _meshFilePath))
443  {
444  logger->debug("[DBG][fromXML] readMesh terminé: points=%zu, triangles=%zu, materials=%zu",
445  points.size(), triangles.size(), materials.size());
446 
447  // 5) Suite du pipeline + traces d’état
448  getAltimetry()->plugBackTriangulation(points, triangles, materials);
449  setIsGeometryModified(false);
450  getAltimetry()->setIsUpToDate(true);
451  }
452  else
453  {
454  logger->debug("[DBG][fromXML] Echec readMesh(...) avec _meshFilePath = %s",
455  qUtf8Printable(_meshFilePath));
456  _meshFilePath = QString{};
457  getAltimetry()->setIsUpToDate(false);
458  }
459  }
460  else
461  {
462  logger->info("[DBG][fromXML] meshFileOk=false -> pas de lecture");
463  _meshFilePath = QString{};
464  getAltimetry()->setIsUpToDate(false);
465  }
466 
467  return 1;
468 }
469 
470 void TYSiteNode::getChilds(LPTYElementArray& childs, bool recursif /*=true*/)
471 {
472  TYElement::getChilds(childs, recursif);
473 
474  childs.push_back(_pTopographie);
475  childs.push_back(_pInfrastructure);
476 
477  if (recursif)
478  {
479  _pTopographie->getChilds(childs, recursif);
480  _pInfrastructure->getChilds(childs, recursif);
481  }
482 
483  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
484  {
485  childs.push_back(_listSiteNode[i]);
486  childs.push_back(_listSiteNode[i]->getElement());
487  }
488 
489  if (recursif)
490  {
491  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
492  {
493  _listSiteNode[i]->getChilds(childs, recursif);
494  }
495  }
496 }
497 
499 {
501 
502  if (!_root && _pParent)
503  {
504  _pParent->setIsGeometryModified(isModified);
505  }
506 }
507 
509 {
510  bool res = _pInfrastructure->addToCalcul(); // Ajoute les elements du site lui-meme dans le calcul
511  res = res && (_pInfrastructure->addToCalcul());
512 
513  if (res && _listSiteNode.size())
514  {
515  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
516  {
517  res = res && (TYSiteNode::safeDownCast(_listSiteNode[i]->getElement()))->addToCalcul();
518  }
519  }
520 
521  return res;
522 }
523 
525 {
526  bool res = _pInfrastructure->remFromCalcul();
527  res = res && _pInfrastructure->remFromCalcul();
528  ;
529 
530  if (res && _listSiteNode.size())
531  {
532  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
533  {
534  res = res && (TYSiteNode::safeDownCast(_listSiteNode[i]->getElement()))->remFromCalcul();
535  }
536  }
537 
538  return res;
539 }
540 
541 void TYSiteNode::updateCurrentCalcul(TYListID& listID, bool recursif) //=true
542 {
543  if (recursif) // On parcours les enfants si besoin est...
544  {
545  // Collecte des childs
546  LPTYElementArray childs;
547  getChilds(childs, false);
548  for (int i = 0; i < childs.size(); i++)
549  {
550  childs[i]->updateCurrentCalcul(listID, recursif);
551  }
552  }
553 
554  TYElement::updateCurrentCalcul(listID, false);
555 }
556 
558 {
559  _pProjet = pProjet;
560  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
561  {
562  TYSiteNode::safeDownCast(_listSiteNode[i]->getElement())->setProjet(pProjet);
563  }
564 }
565 
567 {
570 
571  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
572  {
573  TYSiteNode::safeDownCast(_listSiteNode[i]->getElement())->reparent();
574  }
575 }
576 
577 void TYSiteNode::loadTopoFile(const QString& fileName)
578 {
579  _topoFileName = fileName;
580  loadTopoFile();
581 }
582 
584 {
585  QFile file(_topoFileName);
587  logger.info("Charge fichier topographique %s", qUtf8Printable(_topoFileName));
588 
589  // Open the file
590  if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
591  {
592  logger.error("Erreur durant l'ouverture du fichier %s", qUtf8Printable(_topoFileName));
593  return;
594  }
595 
596  // Read all data from the file
597  QByteArray buffer = file.readAll();
598 
599  // Close the file
600  file.close();
601 
602  // Check if the file read was successful
603  if (buffer.isEmpty())
604  {
605  logger.error("Erreur durant la lecture du fichier %s", qUtf8Printable(_topoFileName));
606  return;
607  }
608 
609  // Convert QByteArray to char*
610  const char* data = buffer.constData();
611  size_t dataSize = buffer.size();
612 
613  /* the whole file is now loaded in the memory buffer. */
614 
615  // Mise a jour du flag.
616  _isTopoFileModified = true;
617 
618  // On conserve l'extension de l'image = son type
619  QFileInfo topoFileInfo(_topoFileName);
620  _topoFileExtension = topoFileInfo.suffix();
621 
622  setIsGeometryModified(true);
623 }
624 
625 /*virtual*/ bool TYSiteNode::updateAltimetrie(QString resultMeshFilePath)
626 {
627  std::ostringstream msg;
629  try
630  {
631  do_updateAltimetrie(resultMeshFilePath);
632  return true;
633  }
634  catch (const tympan::exception& exc)
635  {
636  msg << boost::diagnostic_information(exc);
637  logger.error("An error prevented to update the altimetry (set log level to debug for diagnostic)");
638  logger.debug(msg.str().c_str());
639  return false;
640  }
641 }
642 
643 /*virtual*/ void TYSiteNode::do_updateAltimetrie(QString resultMeshFilePath)
644 {
646 
647  // disables element names automatic generation (subsites fusion etc)
648  TYNameManager::get()->enable(false);
649 
650  logger.info("Mise a jour altimetrie...");
651 
652  // Is the debug option "TYMPAN_DEBUG=keep_tmp_files" enabled?
653  bool keep_tmp_files = must_keep_tmp_files();
654  // Will be used to export the current site topography/infrastructure
655  QTemporaryFile current_project;
656  current_project.setFileTemplate(QDir::tempPath() + QString("/XXXXXX.xml"));
657  // Here will go the mesh result in a PLY Polygon formatted file
658  //(see http://www.cs.virginia.edu/~gfx/Courses/2001/Advanced.spring.01/plylib/Ply.txt)
659  if (!init_tmp_file(current_project, keep_tmp_files))
660  {
661  logger.error(
662  "Creation de fichier temporaire impossible. Veuillez verifier l'espace disque disponible.");
664  }
665  try
666  {
667  tympan::save_project(current_project.fileName().toUtf8().data(), _pProjet);
668  }
669  catch (const tympan::invalid_data& exc)
670  {
671  std::ostringstream msg;
672  msg << boost::diagnostic_information(exc);
673  logger.error("Impossible d'exporter le projet courant pour calculer l'altimetrie.");
674  TYNameManager::get()->enable(true);
675  throw;
676  }
677  if (keep_tmp_files)
678  {
679  logger.debug("Le calcul va s'executer en mode debug.\nLes fichiers temporaires ne seront pas "
680  "supprimes une fois le calcul termine.\nProjet courant non calcule: %s Projet avec les "
681  "resultats du calcul: %s.",
682  current_project.fileName().toStdString().c_str());
683  }
684 
685  // Call python script "process_site_altimetry.py" with: the name of the file
686  // containing the site description, and the name of the file where to record
687  // the result
688  QStringList args;
689  QString absolute_pyscript_path(QCoreApplication::applicationDirPath());
690  absolute_pyscript_path.append("/");
691  absolute_pyscript_path.append(ALTIMETRY_PYSCRIPT);
692  args << absolute_pyscript_path << current_project.fileName() << resultMeshFilePath;
693 
694  // Altimetry parameters
695  QString parameters = _pProjet->getCurrentCalcul()->solverParams;
696  QRegularExpression altimetry_size_criterion_reg("(MeshElementSizeMax\\s?=\\s?)([0-9]+.[0-9]*)");
697  QRegularExpression altimetry_refine_mesh_reg("(RefineMesh\\s?=\\s?)(True|False)");
698  QRegularExpression altimetry_use_volumes_landtakes_reg("(UseVolumesLandtake\\s?=\\s?)(True|False)");
699  QRegularExpressionMatch match_size = altimetry_size_criterion_reg.match(parameters);
700  QRegularExpressionMatch match_refi = altimetry_refine_mesh_reg.match(parameters);
701  QRegularExpressionMatch match_land = altimetry_use_volumes_landtakes_reg.match(parameters);
702  if (match_size.hasMatch() && match_refi.hasMatch() && match_land.hasMatch())
703  {
704  QString altimetry_size_criterion = match_size.captured(2);
705  QString altimetry_refine_mesh = match_refi.captured(2);
706  QString altimetry_use_volumes_landtakes = match_land.captured(2);
707  args << altimetry_size_criterion << altimetry_refine_mesh << altimetry_use_volumes_landtakes;
708  }
709 
710  logger.info("Lancement d'un sous-processus python pour calculer l'altimetrie avec le script: %s",
711  absolute_pyscript_path.toStdString().c_str());
712  std::string error_msg;
713  if (!python(args, error_msg))
714  {
715  logger.error("Echec du calcul de l'altimetrie: %s", error_msg.c_str());
716  TYNameManager::get()->enable(true);
718  }
719  std::deque<OPoint3D> points;
720  std::deque<OTriangle> triangles;
721  std::deque<LPTYSol> materials;
722  readMesh(points, triangles, materials, resultMeshFilePath);
723  setMeshFilePath(resultMeshFilePath);
724  getAltimetry()->plugBackTriangulation(points, triangles, materials);
725  setIsGeometryModified(false); // L'altimetrie est a jour
727  OMessageManager::get()->info("Mise a jour altimetrie terminee.");
728  TYNameManager::get()->enable(true);
729 }
730 
731 bool TYSiteNode::readMesh(std::deque<OPoint3D>& points, std::deque<OTriangle>& triangles,
732  std::deque<LPTYSol>& materials, const QString& meshFilePath)
733 {
734  // CAUTION: reader uses rply C library which calls strtod (stdlib) to read float
735  // and double values. strtod is locale dependent. It means that if decimal
736  // separator is set to ',' instead of '.' in LC_NUMERIC, float values from
737  // the ply file won't be read. To make sure this doesn't happen, temporarily
738  // set the locale and then put back the original value after file reading.
739  char* saved_locale = setlocale(LC_NUMERIC, "C");
740  FILE* fp = tympan::AltimetryPLYReader::openFileForReading(meshFilePath);
742  if (!fp)
743  {
744  logger.error("Echec d'ouverture du fichier ply : %s", qUtf8Printable(meshFilePath));
745  return false;
746  }
747  logger.debug("Ouverture du fichier ply reussie : %s", qUtf8Printable(meshFilePath));
748  tympan::AltimetryPLYReader reader(fp);
749  reader.read();
750  setlocale(LC_NUMERIC, saved_locale);
751  points = reader.points();
752  triangles = reader.faces();
753  std::deque<std::string> material_ids = reader.materials();
754  uuid2tysol(material_ids, materials);
755  return true;
756 }
757 
758 void TYSiteNode::uuid2tysol(const std::deque<std::string>& material_ids, std::deque<LPTYSol>& materials)
759 {
761  TYSol* ground = nullptr;
762  for (int i = 0; i < material_ids.size(); i++)
763  {
764  ground = dynamic_cast<TYSol*>(TYElement::getInstance(OGenID(QString(material_ids[i].c_str()))));
765  if (ground != NULL)
766  {
767  materials.push_back(ground);
768  }
769  else
770  {
771  logger.debug(
772  "Unknown material retrieved from altimetry mesh: id = %s. Using default material instead",
773  material_ids[i].c_str());
774  materials.push_back(_pTopographie->getDefTerrain()->getSol());
775  }
776  }
777 }
778 
779 // TODO : Split the huge method based on the type of infrastructure
780 // See https://extranet.logilab.fr/ticket/1508248
782 {
783  TYNameManager::get()->enable(false);
784 
785  TYAltimetrie* pAlti = getAltimetry();
786  bool modified = false;
787  OPoint3D pt;
788  unsigned int i = 0, j = 0;
789 
790  bool bNoPbAlti = true;
791 
792  // If the site node isn't a root site, compute its global transform matrix
793  // to look for the altitudes at the right place
794  OMatrix globalMatrix = getGlobalMatrix();
795 
796 #if WITH_NMPB
797  // Mise a jour de l'altitude pour les points des routes
798  for (j = 0; j < _pInfrastructure->getListRoute().size(); j++)
799  {
800  // La route
801  LPTYRouteGeoNode pGeoNode = _pInfrastructure->getListRoute()[j];
802  TYRoute* pRoute = _pInfrastructure->getRoute(j);
803 
804  bNoPbAlti &= pRoute->updateAltitudes(*pAlti, pGeoNode, globalMatrix);
805  modified = true; // As long as there is a road, it will be updated anyways.
806  }
807 #endif
808  // Mise a jour de l'altitude pour les points des reseaux transport
809  for (j = 0; j < _pInfrastructure->getListResTrans().size(); j++)
810  {
812 
813  // Hauteur au sol du reseau de transport
814  double hauteur = pResTrans->getHauteurMoyenne();
815 
816  // Matrice pour la position de cette element
817  OMatrix matrix = globalMatrix * _pInfrastructure->getListResTrans()[j]->getMatrix();
818  OMatrix matrixinv = matrix.getInvert();
819 
820  for (i = 0; i < pResTrans->getTabPoint().size(); i++)
821  {
822  // Passage au repere du site
823  pt = matrix * pResTrans->getTabPoint()[i];
824 
825  // Init
826  pt._z = 0.0;
827 
828  // Recherche de l'altitude
829  bNoPbAlti &= pAlti->updateAltitude(pt);
830 
831  // Ajout de la hauteur du reseau de transport
832  pt._z += hauteur;
833 
834  // Retour au repere d'origine
835  pResTrans->getTabPoint()[i] = matrixinv * pt;
836 
837  modified = true;
838  }
839 
840  pResTrans->setIsGeometryModified(false);
841  }
842 
843  // Mise a jour de l'altitude pour les batiments
844  for (j = 0; j < _pInfrastructure->getListBatiment().size(); j++)
845  {
847  TYBatiment* pBat = TYBatiment::safeDownCast(pBatGeoNode->getElement());
848 
849  // Recuperation de l'origine de l'element
850  pt = globalMatrix * pBatGeoNode->getORepere3D()._origin;
851 
852  // Hauteur par rapport au sol
853  double hauteur = pBatGeoNode->getHauteur();
854 
855  // Init
856  pt._z = 0.0;
857 
858  // Recherche de l'altitude
859  bNoPbAlti &= pAlti->updateAltitude(pt);
860 
861  ORepere3D repere3D = pBatGeoNode->getORepere3D();
862  repere3D._origin._z = pt._z + hauteur;
863  pBatGeoNode->setRepere(repere3D);
864 
865  pBat->setIsGeometryModified(false);
866  pBat = NULL;
867  modified = true;
868  }
869 
870  // Mise a jour de l'altitude pour les machines
871  for (j = 0; j < _pInfrastructure->getListMachine().size(); j++)
872  {
873  TYMachineGeoNode* pMachineGeoNode = _pInfrastructure->getListMachine()[j];
874  TYMachine* pMachine = TYMachine::safeDownCast(pMachineGeoNode->getElement());
875 
876  // Recuperation de l'origine de l'element
877  pt = globalMatrix * pMachineGeoNode->getORepere3D()._origin;
878 
879  // Hauteur par rapport au sol
880  double hauteur = pMachineGeoNode->getHauteur();
881 
882  // Init
883  pt._z = 0.0;
884 
885  // Recherche de l'altitude
886  bNoPbAlti &= pAlti->updateAltitude(pt);
887 
888  ORepere3D repere3D = pMachineGeoNode->getORepere3D();
889  repere3D._origin._z = pt._z + hauteur;
890  pMachineGeoNode->setRepere(repere3D);
891 
892  pMachine->setIsGeometryModified(false);
893  pMachine = NULL;
894  modified = true;
895  }
896 
897  // Mise a jour de l'altitude pour les sources utilisateur
898  for (j = 0; j < _pInfrastructure->getSrcs().size(); j++)
899  {
900  // La source
903 
904  // Matrice pour la position de cette element
905  OMatrix matrix = globalMatrix * _pInfrastructure->getSrcs()[j]->getMatrix();
906  OMatrix matrixinv = matrix.getInvert();
907 
908  // Passage au repere du site
909  pt = matrix * *pSrc->getPos();
910 
911  // Init
912  pt._z = 0.0;
913 
914  // Recherche de l'altitude
915  bNoPbAlti &= pAlti->updateAltitude(pt);
916 
917  // Ajout de la hauteur
918  pt._z += pSrc->getHauteur();
919 
920  // Retour au repere d'origine
921  pt = matrixinv * pt;
922  pSrc->getPos()->_z = pt._z;
923 
924  // On va modifier la route (l'altitude seulement)
925  pSrc->setIsGeometryModified(false);
926 
927  modified = true;
928  }
929 
930  // Mise a jour de l'altitude pour les points des cours d'eau
931  for (j = 0; j < _pTopographie->getListCrsEau().size(); j++)
932  {
933  TYCoursEau* pCrsEau = _pTopographie->getCrsEau(j);
934 
935  // Matrice pour la position de cette element
936  OMatrix matrix = globalMatrix * _pTopographie->getListCrsEau()[j]->getMatrix();
937  OMatrix matrixinv = matrix.getInvert();
938 
939  for (i = 0; i < pCrsEau->getTabPoint().size(); i++)
940  {
941  // Passage au repere du site
942  pt = matrix * pCrsEau->getTabPoint()[i];
943 
944  // Init
945  pt._z = 0.0;
946 
947  // Recherche de l'altitude
948  bNoPbAlti &= pAlti->updateAltitude(pt);
949 
950  // Retour au repere d'origine
951  pCrsEau->getTabPoint()[i] = matrixinv * pt;
952 
953  modified = true;
954  }
955 
956  pCrsEau->setIsGeometryModified(false);
957  }
958 
959  // Mise a jour de l'altitude pour les points des terrains
960  for (j = 0; j < _pTopographie->getListTerrain().size(); j++)
961  {
962  TYTerrain* pTerrain = _pTopographie->getTerrain(j);
963 
964  // Matrice pour la position de cette element
965  OMatrix matrix = globalMatrix * _pTopographie->getListTerrain()[j]->getMatrix();
966  OMatrix matrixinv = matrix.getInvert();
967 
968  for (i = 0; i < pTerrain->getListPoints().size(); i++)
969  {
970  // Passage au repere du site
971  pt = matrix * pTerrain->getListPoints()[i];
972 
973  // Init
974  pt._z = 0.0;
975 
976  // Recherche de l'altitude
977  bNoPbAlti &= pAlti->updateAltitude(pt);
978 
979  // Retour au repere d'origine
980  pTerrain->getListPoints()[i] = matrixinv * pt;
981 
982  modified = true;
983  }
984 
985  pTerrain->setIsGeometryModified(false);
986  }
987 
988  // Warning if an object is not correctly altimetrized
989  if (!bNoPbAlti)
990  {
991  OMessageManager::get()->info(TR("msg_pbalti"));
992  }
993 
994  if (modified)
995  {
998  setIsGeometryModified(false);
999  }
1000 
1001  OMessageManager::get()->info("Mise a jour altimetrie des infrastructures terminee.");
1002 
1003  TYNameManager::get()->enable(true);
1004 }
1005 
1006 void TYSiteNode::updateAcoustique(const bool& force)
1007 {
1008  if (_pProjet)
1009  {
1010  TYCalcul* pCalcul = _pProjet->getCurrentCalcul()._pObj;
1011  assert(pCalcul);
1012  _pInfrastructure->updateAcoustic(pCalcul, force);
1013  }
1014 
1015  for (unsigned short i = 0; i < _listSiteNode.size(); i++)
1016  {
1017  TYSiteNode* pSite = TYSiteNode::safeDownCast(_listSiteNode[i]->getElement());
1018 
1019  if (pSite && pSite->isInCurrentCalcul())
1020  {
1021  pSite->updateAcoustique(force);
1022  }
1023  }
1024 }
1025 
1027 {
1028  if (_pProjet)
1029  {
1030  return _pProjet->getDelaunayTolerence();
1031  }
1032 
1033  double delaunay(0.0001);
1034 #if TY_USE_IHM
1035  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "DelaunayTolerance"))
1036  {
1037  delaunay = TYPreferenceManager::getDouble(TYDIRPREFERENCEMANAGER, "DelaunayTolerance");
1038  }
1039  else
1040  {
1041  TYPreferenceManager::setDouble(TYDIRPREFERENCEMANAGER, "DelaunayTolerance", delaunay);
1042  }
1043 #endif
1044 
1045  delaunay = delaunay <= 0.0 ? 0.0001 : delaunay;
1046  return delaunay > 0.05 ? 0.05 : delaunay;
1047 }
1048 
1049 // az++ (revoir les faces des ecrans; il vaudrait mieux en ajouter proprement):
1050 // tableau d'index des faces ecrans
1051 // According to ticket https://extranet.logilab.fr/ticket/1459658 the notion
1052 // of ecran is obsolete
1053 // TODO remove cleanly related stuff
1054 std::vector<bool> EstUnIndexDeFaceEcran;
1055 
1056 void TYSiteNode::getListFacesWithoutFloor(TYTabAcousticSurfaceGeoNode& tabFaces, unsigned int& nbFaceInfra,
1057  std::vector<bool>& EstUnIndexDeFaceEcran,
1058  std::vector<std::pair<int, int>>& indices,
1059  std::vector<int>& etages) const
1060 {
1061  std::ofstream file;
1062  file.open("logsChargement.txt", std::ios::out | std::ios::trunc);
1063  file << "Chargement de la liste des faces." << std::endl;
1064 
1065  EstUnIndexDeFaceEcran.clear();
1066 
1067  unsigned int j = 0, i = 0;
1068  int compteurFace = 0;
1069  int compteurInfra = 0;
1071 
1072  tabFaces.clear();
1073 
1074  // Batiments
1075  for (i = 0; i < _pInfrastructure->getListBatiment().size(); i++)
1076  {
1077  file << "Chargement du batiment " << i << std::endl;
1078  // Si ce batiment est actif pour le calcul
1079  LPTYBatiment pBatiment = TYBatiment::safeDownCast(_pInfrastructure->getBatiment(i)->getElement());
1080 
1081  if (pBatiment && pBatiment->isInCurrentCalcul())
1082  {
1083  tabTmp.clear();
1084 
1085  // Matrice de changement de repere pour ce batiment
1086  OMatrix matrix = _pInfrastructure->getListBatiment()[i]->getMatrix();
1087 
1088  for (j = 0; j < pBatiment->getTabAcousticVol().size(); j++)
1089  {
1090  // Attempt to cast volume to a TYEtage
1091  LPTYEtage pEtage = TYEtage::safeDownCast(pBatiment->getAcousticVol(j));
1092  OMatrix matriceEtage = pBatiment->getTabAcousticVol().at(j)->getMatrix();
1093  if (pEtage)
1094  {
1095  // Récupération des faces des murs
1096  for (unsigned int k = 0; k < pEtage->getTabMur().size(); k++)
1097  {
1098  TYMur* mur = TYMur::safeDownCast(pEtage->getTabMur().at(k)->getElement());
1099  OMatrix matriceMur = pEtage->getTabMur().at(k)->getMatrix();
1100  if (mur)
1101  {
1102  file << "Récupération d'un mur rectangulaire." << std::endl;
1104  mur->getTabAcousticSurf().at(0)->getElement());
1105  if (pRect)
1106  {
1107  // Conversion de la face du mur en AcousticSurfaceGeoNode
1108  file << "Récupération d'un rectangle." << std::endl;
1109  file << "Ajout de la face " << compteurFace << ", etage " << j
1110  << ", batiment " << i << std::endl;
1112  new TYAcousticSurfaceGeoNode(pRect, matriceEtage * matriceMur));
1113  tabTmp.push_back(newNode);
1114  indices.push_back(std::pair<int, int>(compteurFace++, compteurInfra));
1115  etages.push_back(j);
1116  }
1117  }
1118  }
1119 
1120  // Recovery of the upper floor only
1122  LPTYAcousticSurfaceGeoNode newNode =
1123  LPTYAcousticSurfaceGeoNode(new TYAcousticSurfaceGeoNode(poly, matriceEtage));
1124  tabTmp.push_back(newNode);
1125  indices.push_back(std::pair<int, int>(compteurFace++, (int)i));
1126  etages.push_back(j);
1127  }
1128  else
1129  {
1130  // try to cast as a screen (TYEcran)
1131  LPTYEcran pEcran = TYEcran::safeDownCast(pBatiment->getAcousticVol(j));
1132 
1133  if (pEcran)
1134  {
1136  tabTmp2 = pEcran->acousticFaces();
1137  for (unsigned k = 0; k < tabTmp2.size(); k++)
1138  {
1139  tabTmp2[k]->setMatrix(matriceEtage * tabTmp2[k]->getMatrix());
1140  tabTmp.push_back(tabTmp2[k]);
1141  indices.push_back(std::pair<int, int>(compteurFace++, compteurInfra));
1142  etages.push_back(j);
1143  }
1144  }
1145  }
1146  }
1147 
1148  LPTYEtage pEtage = TYEtage::safeDownCast(pBatiment->getAcousticVol(0));
1149  bool bEtageEcran = false;
1150  if (pEtage)
1151  {
1152  bEtageEcran = !pEtage->getClosed();
1153  }
1154  if (bEtageEcran)
1155  {
1156  pEtage->setacousticFacesPourCalcul(true);
1157  }
1158 
1159  // L'ensemble des faces de ce batiment
1160  // tabTmp =
1161  // TYBatiment::safeDownCast(_pInfrastructure->getBatiment(i)->getElement())->acousticFaces();
1162 
1163  bool bEcran = false; // element de type TYEcran
1164  // Next 3 lines commented, may be invalid (a building can't be a floor)
1165  // if (_pInfrastructure->getBatiment(i)->getElement()->isA("TYEcran"))
1166  //{
1167  // bEcran = true;
1168  //}
1169 
1170  // Pour chacune de ces faces
1171  for (j = 0; j < tabTmp.size(); j++)
1172  {
1173  // On concatene les matrices
1174  tabTmp[j]->setMatrix(matrix * tabTmp[j]->getMatrix());
1175 
1176  // Ajout de la face
1177  tabFaces.push_back(tabTmp[j]);
1178  EstUnIndexDeFaceEcran.push_back(bEtageEcran || bEcran);
1179  }
1180  if (bEtageEcran)
1181  {
1182  pEtage->setacousticFacesPourCalcul(false);
1183  }
1184  }
1185 
1186  compteurInfra++;
1187  }
1188 
1189  // Machines
1190  for (i = 0; i < _pInfrastructure->getListMachine().size(); i++)
1191  {
1192  // Si cette machine est active pour le calcul
1194  if (pMachine && pMachine->isInCurrentCalcul())
1195  {
1196  tabTmp.clear();
1197 
1198  // Matrice de changement de repere pour cette machine
1199  OMatrix matrix = _pInfrastructure->getListMachine()[i]->getMatrix();
1200 
1201  // L'ensemble des faces de cette machine
1202  tabTmp = TYMachine::safeDownCast(_pInfrastructure->getMachine(i)->getElement())->acousticFaces();
1203 
1204  // Pour chacune de ces faces
1205  for (j = 0; j < tabTmp.size(); j++)
1206  {
1207  // On concatene les matrices
1208  tabTmp[j]->setMatrix(matrix * tabTmp[j]->getMatrix());
1209 
1210  // Ajout de la face
1211  tabFaces.push_back(tabTmp[j]);
1212  indices.push_back(std::pair<int, int>(compteurFace++, compteurInfra));
1213  EstUnIndexDeFaceEcran.push_back(false);
1214  etages.push_back(0);
1215  }
1216  }
1217  compteurInfra++;
1218  }
1219 
1220  nbFaceInfra =
1221  static_cast<uint32>(tabFaces.size()); // Determination du nombre de faces de l'infrastructure;
1222 
1223  // Les faces de la topographie (altimetrie) sont transformee en faces acoustiques
1224  // avec des proprietes acoustiques nulles
1225  // EstUnIndexDeFaceEcran n'est pas a affecter, car les faces d'infrastructures sont separees de celles de
1226  // l'alti, donc sachant ou commence les faces d'alti, le test "est un ecran" n'a pas de sens pour ces
1227  // dernieres
1228 
1229  // WIP here : the materials {c/sh}ould be stored in the TYAcousticPolygon
1230  // and thus be stored or exracted from the Altimetry ?
1231  // or is this data pulling from the solver to be replaced by data
1232  // pushing from the site to the model
1233  LPTYAltimetrie pAlti = getAltimetry();
1234  TYTabLPPolygon& listFacesAlti = pAlti->getListFaces();
1235  unsigned int nbFacesAlti = static_cast<uint32>(listFacesAlti.size());
1236 
1237  for (i = 0; i < nbFacesAlti; i++)
1238  {
1239  LPTYAcousticPolygon pAccPolygon = new TYAcousticPolygon();
1240  pAccPolygon->setParent(pAlti);
1241 
1242  // Geomtrie
1243  *pAccPolygon->getPolygon() = *listFacesAlti.at(i);
1244 
1245  // Ajout
1247  tabFaces.push_back(pNode);
1248  indices.push_back(std::pair<int, int>(compteurFace++, -1));
1249  etages.push_back(-1);
1250  }
1251 
1252  file.close();
1253 }
1254 
1256 {
1257  // As there is one only altimetry for all the subsites of the root site,
1258  // retrieve the altimetry from the root site and not from the current site.
1259  TYSiteNode const* rootsite = this;
1260  while (rootsite != nullptr && !rootsite->getRoot())
1261  {
1262  rootsite = dynamic_cast<TYSiteNode*>(rootsite->getParent());
1263  }
1264  if (rootsite != nullptr)
1265  return rootsite->getTopographie()->getAltimetrie();
1266  throw tympan::invalid_data("No root site node in current TYMPAN objects hierarchy.");
1267 }
1268 
1270 {
1271  if (getRoot())
1272  {
1273  return OMatrix(); // identity matrix at the root site
1274  }
1275  TYSiteNode const* parentsite = dynamic_cast<TYSiteNode*>(getParent());
1276  if (parentsite == nullptr)
1277  {
1278  return OMatrix();
1279  // should throw an exception
1280  }
1281 
1282  for (int i = 0; i < parentsite->_listSiteNode.size(); i++)
1283  {
1284  TYSiteNode const* subsite = dynamic_cast<TYSiteNode*>(parentsite->_listSiteNode[i]->getElement());
1285  if (subsite->getID() == getID())
1286  {
1287  return parentsite->getGlobalMatrix() * parentsite->_listSiteNode[i]->getMatrix();
1288  }
1289  }
1290  return OMatrix(); // this should not happen
1291 }
1292 
1293 bool almost_equal(double a, double b, double precision)
1294 {
1295  return abs(a - b) < abs(precision);
1296 }
1297 
1298 void TYSiteNode::groundBasedFaces(const TYTabAcousticVolumeGeoNode& volumes, const OMatrix& global_matrix,
1299  std::map<TYUUID, std::deque<TYTabPoint3D>>& contours) const
1300 {
1301  // Go through all the faces of the all the input volumes
1302  for (unsigned int i = 0; i < volumes.size(); i++)
1303  {
1304  OMatrix matrix = volumes[i]->getMatrix();
1305  matrix = global_matrix * matrix;
1306  TYAcousticVolume* volume = dynamic_cast<TYAcousticVolume*>(volumes[i]->getElement());
1307  assert(volume != nullptr &&
1308  "found an object which isn't a TYAcousticVolume in a TYTabAcousticVolumeGeoNode");
1309  TYTabAcousticSurfaceGeoNode faces = volume->acousticFaces();
1310  TYTabPoint3D contour;
1311  double tol = 10e-6;
1312  for (unsigned int j = 0; j < faces.size(); j++)
1313  {
1314  // Compute global matrix for the current face
1315  OMatrix face_matrix = matrix * faces[j]->getMatrix();
1316  faces[j]->setMatrix(face_matrix);
1317  TYAcousticSurface* pFace = dynamic_cast<TYAcousticSurface*>(faces[j]->getElement());
1318 
1319  // Take the contour of the acoustic face, move the points to a global scale
1320  // and make a polygon with them
1321  contour = pFace->getOContour();
1322  TYPolygon poly;
1323  for (unsigned int k = 0; k < contour.size(); k++)
1324  {
1325  contour[k] = face_matrix * contour[k];
1326  poly.getPoints().push_back(TYPoint(contour[k]));
1327  }
1328  // Compute polygon' normal
1329  poly.updateNormal();
1330  OVector3D normal = poly.normal();
1331  // We are looking for the floor-based face of the volumes. We keep the
1332  // current face if it is parallel to the ground
1333  if (!almost_equal(abs(normal.scalar(OVector3D(0., 0., 1.))), 1., tol))
1334  continue;
1335  // only keep the face if it is on or below the ground
1336  if (contour[0]._z < tol)
1337  {
1338  contours[volume->getID()].push_back(contour);
1339  }
1340  }
1341  }
1342 }
1343 
1344 void TYSiteNode::getFacesOnGround(std::map<TYUUID, std::deque<TYTabPoint3D>>& contours) const
1345 {
1346  assert(contours.empty() &&
1347  "Output argument 'contours' is supposed to be empty when calling 'TYSiteNode::getFacesOnGround'");
1348  // Buildings
1349  for (unsigned int i = 0; i < _pInfrastructure->getListBatiment().size(); i++)
1350  {
1351  // We get the geonode information : position and height of the building
1353  // If the building is not supposed to touch the ground, there is no need to get its contour
1354  if (gBatiment->getHauteur() != 0)
1355  {
1356  continue;
1357  }
1358  // If it does touch the ground, we set its z-coordinate to 0 to avoid changes when we relaunch several
1359  // times in a row (in which case we would use the calculated z)
1360  else
1361  {
1362  OPoint3D position = gBatiment->position();
1363  position._z = 0;
1364  gBatiment->setPosition(position);
1365  LPTYBatiment pBuilding = dynamic_cast<TYBatiment*>(gBatiment->getElement());
1366  assert(pBuilding != nullptr &&
1367  "found an object which is not a TYBatiment in _pInfrastructure->getListBatiment()");
1368  // If this building is active in the current simulation
1369  if (pBuilding->isInCurrentCalcul())
1370  {
1371  // Building transform matrix
1372  OMatrix matrix = _pInfrastructure->getBatiment(i)->getMatrix();
1373  TYTabAcousticVolumeGeoNode& building_volumes = pBuilding->getTabAcousticVol();
1374  // 1 TYTabPoint3D per volume face on the ground. Indeed there may be several,
1375  // since buildings and machines are volume nodes wghich means they
1376  // are made of one or more volumes.
1377  std::deque<TYTabPoint3D> base_faces;
1378  // Get the base of the building
1379  groundBasedFaces(building_volumes, matrix, contours);
1380  }
1381  }
1382  }
1383  // Machines
1384  for (int i = 0; i < _pInfrastructure->getListMachine().size(); i++)
1385  {
1386  // We get the geonode information : position and height of the building
1388  // If the machine is not supposed to touch the ground, there is no need to get its contour
1389  if (gMachine->getHauteur() != 0)
1390  {
1391  continue;
1392  }
1393  // If it does touch the ground, we set its z-coordinate to 0 to avoid changes when we relaunch several
1394  // times in a row (otherwise we would use the calculated z)
1395  else
1396  {
1397  OPoint3D position = gMachine->position();
1398  position._z = 0;
1399  gMachine->setPosition(position);
1400  // Si cette machine est active pour le calcul
1401  LPTYMachine pMachine = dynamic_cast<TYMachine*>(gMachine->getElement());
1402  assert(pMachine != nullptr &&
1403  "found an object which is not a TYMachine in _pInfrastructure->getListMachine()");
1404  if (pMachine->isInCurrentCalcul())
1405  {
1406  // Matrice de changement de repere pour cette machine
1407  OMatrix matrix = _pInfrastructure->getMachine(i)->getMatrix();
1408  TYTabAcousticVolumeGeoNode machine_volumes = pMachine->getTabAcousticVol();
1409  std::deque<TYTabPoint3D> base_faces;
1410  // Get the base of the machine
1411  groundBasedFaces(machine_volumes, matrix, contours);
1412  }
1413  }
1414  }
1415 }
1416 
1417 void TYSiteNode::getListFaces(TYTabAcousticSurfaceGeoNode& tabFaces, unsigned int& nbFaceInfra,
1418  std::vector<bool>& EstUnIndexDeFaceEcran) const
1419 {
1420  EstUnIndexDeFaceEcran.clear();
1421 
1422  unsigned int j = 0, i = 0;
1424 
1425  tabFaces.clear();
1426 
1427  // Batiments
1428  for (i = 0; i < _pInfrastructure->getListBatiment().size(); i++)
1429  {
1430  // Si ce batiment est actif pour le calcul
1431  LPTYBatiment pBatiment = TYBatiment::safeDownCast(_pInfrastructure->getBatiment(i)->getElement());
1432  if (pBatiment && pBatiment->isInCurrentCalcul())
1433  {
1434  tabTmp.clear();
1435 
1436  // Matrice de changement de repere pour ce batiment
1437  OMatrix matrix = _pInfrastructure->getListBatiment()[i]->getMatrix();
1438 
1439  // LPTYBatiment pBatiment =
1440  // TYBatiment::safeDownCast(_pInfrastructure->getBatiment(i)->getElement());
1441  LPTYEtage pEtage = TYEtage::safeDownCast(pBatiment->getAcousticVol(0));
1442 
1443  // Old Code_TYMPAN version could use a floor as a screen so, that case should be treated
1444  bool bEtageEcran = false;
1445  if (pEtage)
1446  {
1447  bEtageEcran = !pEtage->getClosed();
1448  }
1449  if (bEtageEcran)
1450  {
1451  pEtage->setacousticFacesPourCalcul(true);
1452  }
1453 
1454  // L'ensemble des faces de ce batiment
1455  tabTmp = pBatiment->acousticFaces();
1456 
1457  // Pour chacune de ces faces
1458  for (j = 0; j < tabTmp.size(); j++)
1459  {
1460  // On concatene les matrices
1461  tabTmp[j]->setMatrix(matrix * tabTmp[j]->getMatrix());
1462 
1463  // Ajout de la face
1464  tabFaces.push_back(tabTmp[j]);
1465  EstUnIndexDeFaceEcran.push_back(bEtageEcran);
1466  }
1467  if (bEtageEcran)
1468  {
1469  pEtage->setacousticFacesPourCalcul(false);
1470  }
1471  }
1472  }
1473 
1474  // Machines
1475  for (i = 0; i < _pInfrastructure->getListMachine().size(); i++)
1476  {
1477  // Si cette machine est active pour le calcul
1479  if (pMachine && pMachine->isInCurrentCalcul())
1480  {
1481  tabTmp.clear();
1482 
1483  // Matrice de changement de repere pour cette machine
1484  OMatrix matrix = _pInfrastructure->getListMachine()[i]->getMatrix();
1485 
1486  // L'ensemble des faces de cette machine
1487  tabTmp = TYMachine::safeDownCast(_pInfrastructure->getMachine(i)->getElement())->acousticFaces();
1488 
1489  // Pour chacune de ces faces
1490  for (j = 0; j < tabTmp.size(); j++)
1491  {
1492  // On concatene les matrices
1493  tabTmp[j]->setMatrix(matrix * tabTmp[j]->getMatrix());
1494 
1495  // Ajout de la face
1496  tabFaces.push_back(tabTmp[j]);
1497  EstUnIndexDeFaceEcran.push_back(false);
1498  }
1499  }
1500  }
1501 
1502  nbFaceInfra =
1503  static_cast<uint32>(tabFaces.size()); // Determination du nombre de faces de l'infrastructure;
1504 
1505  // Les faces de la topographie (altimetrie) sont transformee en faces acoustiques
1506  // avec des proprietes acoustiques nulles
1507  // EstUnIndexDeFaceEcran n'est pas a affecter, car les faces d'infrastructures sont separees de celles de
1508  // l'alti, donc sachant ou commence les faces d'alti, le test "est un ecran" n'a pas de sens pour ces
1509  // dernieres
1510 
1511  TYTabLPPolygon& listFacesAlti = getAltimetry()->getListFaces();
1512  unsigned int nbFacesAlti = static_cast<uint32>(listFacesAlti.size());
1513 
1514  for (i = 0; i < nbFacesAlti; i++)
1515  {
1516  LPTYAcousticPolygon pAccPolygon = new TYAcousticPolygon();
1517  pAccPolygon->setParent(getAltimetry());
1518 
1519  // Geomtrie
1520  *pAccPolygon->getPolygon() = *listFacesAlti.at(i);
1521 
1522  // Ajout
1524  tabFaces.push_back(pNode);
1525  }
1526 }
1527 
1529 {
1530  TYTabSiteNodeGeoNode& tabGeoNode = getListSiteNode();
1531  TYSiteNode* pSite = NULL;
1532 
1533  for (unsigned int i = 0; i < tabGeoNode.size(); i++)
1534  {
1535  pSite = TYSiteNode::safeDownCast(tabGeoNode[i]->getElement());
1536  pSite->setInCurrentCalcul(false, true, false);
1537  }
1538 }
1539 
1540 TYTabSiteNodeGeoNode TYSiteNode::collectSites(bool include /*=true*/) const
1541 {
1542  TYTabSiteNodeGeoNode sites;
1543 
1544  if (include)
1545  {
1546  sites.push_back(new TYSiteNodeGeoNode((TYSiteNode*)this));
1547  }
1548 
1549  for (unsigned int i = 0; i < _listSiteNode.size(); i++)
1550  {
1551  // On inclut forcement les sites sinon sans interet
1552  TYSiteNode* pSite = TYSiteNode::safeDownCast(_listSiteNode[i]->getElement());
1553  if (pSite && pSite->isInCurrentCalcul()) // Uniquement si le sous-site est dans le calcul
1554  {
1555  TYTabSiteNodeGeoNode tabChild = pSite->collectSites(true);
1556 
1557  // Concatenation des matrices
1558  OMatrix matrix = _listSiteNode[i]->getMatrix();
1559  for (unsigned int j = 0; j < tabChild.size(); j++)
1560  {
1561  tabChild[j]->setMatrix(matrix * tabChild[j]->getMatrix());
1562  }
1563 
1564  //...et ajoute au tableau a retourner
1565  sites.insert(sites.end(), tabChild.begin(), tabChild.end());
1566  }
1567  }
1568 
1569  return sites;
1570 }
1571 
1573 {
1574  bool ret = false;
1575 
1576  TYSourcePonctuelle* pSource = dynamic_cast<TYSourcePonctuelle*>(pElem);
1577  if (pSource != nullptr)
1578  {
1579  return true; // Pas de mise à jour nécessaire
1580  }
1581  TYAcousticLine* pLine = dynamic_cast<TYAcousticLine*>(pElem);
1582  if (pLine != nullptr) // Cas 1 : un objet de type source linéique
1583  {
1584  pLine->updateAcoustic(true);
1585  }
1586  else // Autres cas, recherche de parent et traitement approprié
1587  {
1588  TYElement* pParent = pElem; // On commencera par tester l'objet lui-meme
1589  do
1590  {
1591  TYAcousticVolumeNode* pVolNode = dynamic_cast<TYAcousticVolumeNode*>(pParent);
1592  if (pVolNode != nullptr)
1593  {
1594  ret = pVolNode->updateAcoustic(true);
1595  break; // On a trouvé, on peut sortir
1596  }
1597  TYSiteNode* pSite = dynamic_cast<TYSiteNode*>(pParent);
1598  if (pSite != nullptr)
1599  {
1600  pSite->updateAcoustique();
1601  ret = true;
1602  break; // On a trouvé, on peut sortir
1603  }
1604 
1605  pParent = pParent->getParent();
1606  } while (pParent);
1607  }
1608 
1609  return ret;
1610 }
1611 
1612 void TYSiteNode::update(const bool& force) // Force = false
1613 {
1614  // Altimetrisation des infrastructures du site
1615  updateAltiInfra();
1616 
1617  // Mise a jour de l'acoustique des elements du site
1618  updateAcoustique(force);
1619 
1620  // Et celle des sites inclus
1621  for (unsigned short i = 0; i < _listSiteNode.size(); i++)
1622  {
1623  TYSiteNode* pSite = TYSiteNode::safeDownCast(_listSiteNode[i]->getElement());
1624 
1625  if (pSite && pSite->isInCurrentCalcul())
1626  {
1627  pSite->update(force);
1628  }
1629  }
1630 
1631  // Si le site est dans un projet, on altimétrise les points de controle
1632  if (_pProjet && getRoot())
1633  {
1635  }
1636 }
1637 
1639 {
1640  assert(pSiteNodeGeoNode);
1641 
1642  LPTYSiteNode pSite = TYSiteNode::safeDownCast(pSiteNodeGeoNode->getElement());
1643 
1644  assert(pSite);
1645 
1646  pSiteNodeGeoNode->setParent(this);
1647  pSite->setParent(this);
1648  pSite->setProjet(_pProjet); // Informe du projet cadre
1649 
1650  _listSiteNode.push_back(pSiteNodeGeoNode);
1651 
1652 #if TY_USE_IHM
1653  pSite->updateGraphicTree();
1654 #endif
1655  setIsGeometryModified(true);
1656 
1657  return true;
1658 }
1659 
1661 {
1662  return addSiteNode(new TYSiteNodeGeoNode((LPTYElement)pSiteNode));
1663 }
1664 
1665 bool TYSiteNode::remSiteNode(const LPTYSiteNodeGeoNode pSiteNodeGeoNode)
1666 {
1667  assert(pSiteNodeGeoNode);
1668  bool ret = false;
1669  TYTabSiteNodeGeoNode::iterator ite;
1670 
1671  for (ite = _listSiteNode.begin(); ite != _listSiteNode.end(); ite++)
1672  {
1673  if ((*ite) == pSiteNodeGeoNode)
1674  {
1675  // Suppression des calcul
1676  if (_pProjet)
1677  {
1678  _pProjet->remElmtFromCalculs((*ite)->getElement());
1679  }
1680 
1681  _listSiteNode.erase(ite);
1682  ret = true;
1683  break;
1684  }
1685  }
1686 
1687  setIsGeometryModified(true);
1688 
1689  return ret;
1690 }
1691 
1693 {
1694  assert(pSiteNode);
1695  bool ret = false;
1696  TYTabSiteNodeGeoNode::iterator ite;
1697 
1698  for (ite = _listSiteNode.begin(); ite != _listSiteNode.end(); ite++)
1699  {
1700  if (TYSiteNode::safeDownCast((*ite)->getElement()) == pSiteNode)
1701  {
1702  // Suppression des calcul
1703  if (_pProjet)
1704  {
1705  _pProjet->remElmtFromCalculs((*ite)->getElement());
1706  }
1707 
1708  _listSiteNode.erase(ite);
1709  ret = true;
1710  break;
1711  }
1712  }
1713 
1714  setIsGeometryModified(true);
1715 
1716  return ret;
1717 }
1718 
1719 bool TYSiteNode::remSiteNode(QString idSiteNode)
1720 {
1721  bool ret = false;
1722  TYTabSiteNodeGeoNode::iterator ite;
1723 
1724  for (ite = _listSiteNode.begin(); ite != _listSiteNode.end(); ite++)
1725  {
1726  if (TYSiteNode::safeDownCast((*ite)->getElement())->getID().toString() == idSiteNode)
1727  {
1728  // Suppression des calcul
1729  if (_pProjet)
1730  {
1731  _pProjet->remElmtFromCalculs((*ite)->getElement());
1732  }
1733 
1734  _listSiteNode.erase(ite);
1735  ret = true;
1736  break;
1737  }
1738  }
1739 
1740  setIsGeometryModified(true);
1741 
1742  return ret;
1743 }
1744 
1746 {
1747  assert(pSiteNode);
1748  TYTabSiteNodeGeoNode::iterator ite;
1749 
1750  for (ite = _listSiteNode.begin(); ite != _listSiteNode.end(); ite++)
1751  {
1752  if (TYSiteNode::safeDownCast((*ite)->getElement()) == pSiteNode)
1753  {
1754  return (*ite);
1755  }
1756  }
1757 
1758  return NULL;
1759 }
1760 
1762 {
1763  LPTYSiteNode pSite = new TYSiteNode();
1764  pSite->getTopographie()
1765  ->getListTerrain()
1766  .clear(); // On vide car un terrain par defaut a ete cree dans le site cible
1767 
1768  unsigned int j = 0;
1769 
1770  // On copie les elements de ce site
1771  appendSite(this, OMatrix(), pSite);
1772  pSite->getTopographie()->setDefTerrainIdx(getTopographie()->getDefTerrainIdx());
1773  pSite->setEmprise(getTopographie()->getEmprise());
1774  pSite->getTopographie()->setDefTerrain(getTopographie()->getDefTerrainIdx());
1775 
1776  // Merge des sites enfants
1777  for (j = 0; j < _listSiteNode.size(); j++)
1778  {
1779  // Site enfant courant
1780  LPTYSiteNodeGeoNode pSiteNodeGeoNode = _listSiteNode[j];
1781 
1782  // Appel recursif
1783  TYSiteNode* pSiteChild = TYSiteNode::safeDownCast(pSiteNodeGeoNode->getElement());
1784  assert(pSiteChild);
1785  if (pSiteChild && !(pSiteChild->isInCurrentCalcul()))
1786  {
1787  continue;
1788  }
1789 
1790  LPTYSiteNode pSiteTmp = pSiteChild->merge();
1791 
1792  // On copie les elements du site enfant en prenant compte le changement de repere
1793  appendSite(pSiteTmp, pSiteNodeGeoNode->getMatrix(), pSite);
1794  }
1795 
1797  pSite->setProjet(_pProjet);
1798 
1799  return pSite;
1800 }
1801 
1802 void TYSiteNode::appendSite(LPTYSiteNode pSiteFrom, const OMatrix& matrix, LPTYSiteNode pSiteTo)
1803 {
1804  assert(pSiteFrom);
1805  assert(pSiteTo);
1806  unsigned int i = 0;
1807  OMatrix newMatrix;
1808 
1809  // Ajout des elements de topo
1810  LPTYTopographie pTopoFrom = pSiteFrom->getTopographie();
1811  LPTYTopographie pTopoTo = pSiteTo->getTopographie();
1812 
1813  // TODO BUG #0008309 : Courbe de niveau pas prise en compte dans l'altimétrie
1814  if (pSiteFrom->getUseEmpriseAsCrbNiv())
1815  {
1816  pTopoTo->addCrbNiv(new TYCourbeNiveau(pTopoFrom->getEmprise(), pSiteFrom->getAltiEmprise()));
1817  }
1818  // This scope is here to make p_ground local
1819  {
1820  // Add the 'emprise' as a Terrain with its defaultTErrain as Sol attribute.
1821  TYTerrain* p_ground = new TYTerrain();
1822  p_ground->setSol(pTopoFrom->getDefTerrain()->getSol());
1823  p_ground->setListPoints(pTopoFrom->getEmprise());
1824  pTopoTo->addTerrain(new TYTerrainGeoNode(p_ground, matrix));
1825  }
1826  for (i = 0; i < pTopoFrom->getListCrbNiv().size(); i++)
1827  {
1828  newMatrix = matrix * pTopoFrom->getListCrbNiv()[i]->getMatrix();
1829  pTopoTo->addCrbNiv(new TYCourbeNiveauGeoNode(pTopoFrom->getListCrbNiv()[i]->getElement(), newMatrix));
1830  }
1831 
1832  for (i = 0; i < pTopoFrom->getListTerrain().size(); i++)
1833  {
1834  newMatrix = matrix * pTopoFrom->getListTerrain()[i]->getMatrix();
1835  pTopoTo->addTerrain(new TYTerrainGeoNode(pTopoFrom->getListTerrain()[i]->getElement(), newMatrix));
1836  }
1837 
1838  for (i = 0; i < pTopoFrom->getListCrsEau().size(); i++)
1839  {
1840  newMatrix = matrix * pTopoFrom->getListCrsEau()[i]->getMatrix();
1841  pTopoTo->addCrsEau(new TYCoursEauGeoNode(pTopoFrom->getListCrsEau()[i]->getElement(), newMatrix));
1842  }
1843 
1844  for (i = 0; i < pTopoFrom->getListPlanEau().size(); i++)
1845  {
1846  newMatrix = matrix * pTopoFrom->getListPlanEau()[i]->getMatrix();
1847  pTopoTo->addPlanEau(new TYPlanEauGeoNode(pTopoFrom->getListPlanEau()[i]->getElement(), newMatrix));
1848  }
1849 
1850  // Ajout des elements d'infra
1851  LPTYInfrastructure pInfraFrom = pSiteFrom->getInfrastructure();
1852  LPTYInfrastructure pInfraTo = pSiteTo->getInfrastructure();
1853 
1854 #if WITH_NMPB
1855  for (i = 0; i < pInfraFrom->getListRoute().size(); i++)
1856  {
1857  newMatrix = matrix * pInfraFrom->getListRoute()[i]->getMatrix();
1858  pInfraTo->addRoute(new TYRouteGeoNode(pInfraFrom->getListRoute()[i]->getElement(), newMatrix));
1859  }
1860 #endif
1861  for (i = 0; i < pInfraFrom->getListResTrans().size(); i++)
1862  {
1863  newMatrix = matrix * pInfraFrom->getListResTrans()[i]->getMatrix();
1864  pInfraTo->addResTrans(
1865  new TYReseauTransportGeoNode(pInfraFrom->getListResTrans()[i]->getElement(), newMatrix));
1866  }
1867 
1868  for (i = 0; i < pInfraFrom->getListBatiment().size(); i++)
1869  {
1870  newMatrix = matrix * pInfraFrom->getListBatiment()[i]->getMatrix();
1871  TYBatimentGeoNode* pBatNode =
1872  new TYBatimentGeoNode(pInfraFrom->getListBatiment()[i]->getElement(), newMatrix);
1873  pBatNode->setHauteur(pInfraFrom->getListBatiment()[i]->getHauteur());
1874  pInfraTo->addBatiment(pBatNode);
1875  }
1876 
1877  for (i = 0; i < pInfraFrom->getListMachine().size(); i++)
1878  {
1879  newMatrix = matrix * pInfraFrom->getListMachine()[i]->getMatrix();
1880  TYMachineGeoNode* pMachineNode =
1881  new TYMachineGeoNode(pInfraFrom->getListMachine()[i]->getElement(), newMatrix);
1882  pMachineNode->setHauteur(pInfraFrom->getListMachine()[i]->getHauteur());
1883  pInfraTo->addMachine(pMachineNode);
1884  }
1885 
1886  for (i = 0; i < pInfraFrom->getSrcs().size(); i++)
1887  {
1888  newMatrix = matrix * pInfraFrom->getSrcs()[i]->getMatrix();
1889  pInfraTo->addSrc(new TYSourcePonctuelleGeoNode(pInfraFrom->getSrcs()[i]->getElement(), newMatrix));
1890  }
1891 }
1892 
1893 void TYSiteNode::exportCSV(std::ofstream& ofs)
1894 {
1895  // Export du nom de l'objet
1896  ofs << getName().toLatin1().data() << '\n';
1897 
1898  // Export du type de l'objet
1899  ofs << toString() << '\n';
1900  // Export des donnees acoustiques
1901  LPTYElementArray childs;
1902  getChilds(childs);
1903 
1904  for (int i = 0; i < childs.size(); i++)
1905  {
1906  TYElement* pElement = childs[i];
1907  TYSiteNode* pSite = dynamic_cast<TYSiteNode*>(pElement);
1908  if (pSite != nullptr)
1909  {
1910  // Export du nom de l'objet
1911  ofs << pElement->getName().toLatin1().data() << '\n';
1912  continue;
1913  }
1914  LPTYAcousticVolumeNode pVolNode = dynamic_cast<TYAcousticVolumeNode*>(pElement);
1915  if (pVolNode != nullptr)
1916  {
1917  pVolNode->exportCSV(ofs);
1918  continue;
1919  }
1920  LPTYAcousticLine pAcLine = dynamic_cast<TYAcousticLine*>(pElement);
1921  if (pAcLine != nullptr)
1922  {
1923  pAcLine->exportCSV(ofs);
1924  continue;
1925  }
1926  LPTYUserSourcePonctuelle pSource = dynamic_cast<TYUserSourcePonctuelle*>(pElement);
1927  if (pSource != nullptr)
1928  {
1929  pSource->exportCSV(ofs);
1930  }
1931  }
1932 
1933  ofs << '\n';
1934 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
std::vector< LPTYAcousticFaceSetGeoNode > TYTabAcousticVolumeGeoNode
Collection de noeuds geometriques de type TYAcousticFaceSet.
TYGeometryNode TYAcousticSurfaceGeoNode
Noeud geometrique de type TYAcousticSurface.
std::vector< LPTYAcousticSurfaceGeoNode > TYTabAcousticSurfaceGeoNode
Collection de noeuds geometriques de type TYAcousticSurface.
SmartPtr< TYAcousticSurfaceGeoNode > LPTYAcousticSurfaceGeoNode
Smart Pointer sur TYAcousticSurfaceGeoNode.
TYGeometryNode TYBatimentGeoNode
Noeud geometrique de type TYBatiment.
Definition: TYBatiment.h:90
TYGeometryNode TYCourbeNiveauGeoNode
Noeud geometrique de type TYCourbeNiveau.
TYGeometryNode TYCoursEauGeoNode
Noeud geometrique de type TYCoursEau.
Definition: TYCoursEau.h:66
class OGenID TYUUID
Definition: TYDefines.h:59
std::deque< OPoint3D > TYTabPoint3D
Collection de OPoint3D.
Definition: TYDefines.h:403
std::vector< LPTYPolygon > TYTabLPPolygon
Collection de pointeurs de TYPolygon.
Definition: TYDefines.h:349
std::list< TYUUID > TYListID
Collection d'identifiants.
Definition: TYDefines.h:331
std::vector< LPTYElement > LPTYElementArray
Definition: TYElement.h:344
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
TYGeometryNode TYMachineGeoNode
Noeud geometrique de type TYMachine.
Definition: TYMachine.h:164
TYGeometryNode TYPlanEauGeoNode
Noeud geometrique de type TYPlanEau.
Definition: TYPlanEau.h:198
TYGeometryNode TYReseauTransportGeoNode
Noeud geometrique de type TYReseauTransport.
TYGeometryNode TYRouteGeoNode
Geometrical node of type TYRoute.
Definition: TYRoute.h:33
Representation graphique d'un ensemble de sites (fichier header)
outil IHM pour un ensemble de sites (fichier header)
std::vector< bool > EstUnIndexDeFaceEcran
bool almost_equal(double a, double b, double precision)
TY_EXTENSION_INST(TYSiteNode)
TY_EXT_GRAPHIC_INST(TYSiteNode)
#define TR(id)
Definition: TYSiteNode.cpp:39
systemSIG
Systeme SIG.
Definition: TYSiteNode.h:29
@ TYMPAN
Definition: TYSiteNode.h:30
TYGeometryNode TYSiteNodeGeoNode
Noeud geometrique de type TYSiteNode.
Definition: TYSiteNode.h:36
std::vector< LPTYSiteNodeGeoNode > TYTabSiteNodeGeoNode
Collection de noeuds geometriques de type TYSiteNode.
Definition: TYSiteNode.h:40
TYGeometryNode TYSourcePonctuelleGeoNode
Noeud geometrique de type TYSourcePonctuelle.
TYGeometryNode TYTerrainGeoNode
Noeud geometrique de type TYTerrain.
Definition: TYTerrain.h:177
Implementation details header for altimetry_reader.cpp.
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
Definition: idgen.h:28
The 4x4 matrix class.
Definition: 3d.h:625
OMatrix getInvert(int *ok=0) const
Return the inverse matrix of this matrix.
Definition: 3d.cpp:813
virtual void debug(const char *message,...)
Definition: logging.cpp:151
virtual void error(const char *message,...)
Definition: logging.cpp:127
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:248
static OPrototype * safeDownCast(OPrototype *pObject)
Definition: TYElement.cpp:71
3D frame with a point and 3 vectors.
Definition: 3d.h:1263
OPoint3D _origin
The origin point.
Definition: 3d.h:1331
The 3D vector class.
Definition: 3d.h:298
double scalar(const OVector3D &vector) const
Performs the scalar product between this object and another vector.
Definition: 3d.cpp:210
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
TYTabPoint & getTabPoint()
virtual bool updateAcoustic(const bool &force=false)
TYTabAcousticSurfaceGeoNode & getTabAcousticSurf()
virtual TYTabPoint3D getOContour(int n=-1) const
virtual TYTabAcousticSurfaceGeoNode acousticFaces()
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
virtual bool updateAcoustic(const bool &force=false)
LPTYAcousticVolume getAcousticVol(int index)
TYTabAcousticVolumeGeoNode & getTabAcousticVol()
virtual TYTabAcousticSurfaceGeoNode acousticFaces()
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...
void plugBackTriangulation(const std::deque< OPoint3D > &points, std::deque< OTriangle > &triangles, const std::deque< LPTYSol > &materials)
plug back triangulation providfed by the TYTopographie
void setIsUpToDate(bool isUpToDate)
TYTabLPPolygon & getListFaces()
Definition: TYAltimetrie.h:124
Calculation program.
Definition: TYCalcul.h:50
QString solverParams
Definition: TYCalcul.h:482
TYElement * getParent() const
Definition: TYElement.h:697
virtual bool isInCurrentCalcul()
Definition: TYElement.h:539
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:305
static void setIsSavedOk(const bool &toSave)
Definition: TYElement.h:905
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:366
QString _name
Nom courant de l'element.
Definition: TYElement.h:956
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:263
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:545
const TYUUID & getID() const
Definition: TYElement.cpp:176
virtual QString getName() const
Definition: TYElement.h:682
TYElement * _pParent
Reference sur l'element parent.
Definition: TYElement.h:959
virtual void updateCurrentCalcul(TYListID &listID, bool recursif=true)
Definition: TYElement.cpp:461
virtual void setInCurrentCalcul(bool state, bool recurschild=true, bool recursparent=true)
Definition: TYElement.cpp:408
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYElement.h:530
void setParent(TYElement *pParent)
Definition: TYElement.h:690
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:379
QString getStringID() const
Definition: TYElement.h:651
static TYElement * getInstance(TYUUID uuid)
Definition: TYElement.cpp:158
virtual void setIsGeometryModified(bool isModified)
Definition: TYElement.cpp:253
LPTYDalle getPlafond()
Definition: TYEtage.h:229
void setacousticFacesPourCalcul(bool bPourCalculTrajet)
Definition: TYEtage.cpp:2024
TYTabMurGeoNode & getTabMur()
Definition: TYEtage.h:143
bool getClosed()
Definition: TYEtage.h:206
const ORepere3D & getORepere3D() const
void setHauteur(const double &hauteur)
Set the heigth above the ground.
double getHauteur()
Get the height above the ground.
OPoint3D position()
Get the position of the element.
TYElement * getElement() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
OMatrix getMatrix() const
void setPosition(const OPoint3D &pos)
Set the position of the element.
void setRepere(const ORepere3D &repere)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
TYTabBatimentGeoNode & getListBatiment()
bool addToCalcul(TYGeometryNode *pNode)
LPTYUserSourcePonctuelleGeoNode getSrc(int index)
LPTYMachineGeoNode getMachine(int index)
virtual void reparent()
LPTYReseauTransport getResTrans(int index)
TYTabUserSourcePonctuelleGeoNode & getSrcs()
LPTYBatimentGeoNode getBatiment(int index)
TYTabReseauTransportGeoNode & getListResTrans()
virtual DOM_Element toXML(DOM_Element &domElement)
bool addBatiment(LPTYBatimentGeoNode pBatimentGeoNode)
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
bool addMachine(LPTYMachineGeoNode pMachineGeoNode)
bool addSrc(LPTYUserSourcePonctuelle pSrc)
bool updateAcoustic(const TYCalcul *pCalcul, const bool &force=false)
TYTabMachineGeoNode & getListMachine()
bool addResTrans(LPTYReseauTransportGeoNode pResTransGeoNode)
Definition: TYMur.h:36
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
void enable(bool enable)
Active la generation de nom.
Definition: TYNameManager.h:64
static TYNameManager * get()
Retourne l'instance singleton.
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYPoint.cpp:112
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYPoint.cpp:92
const TYTabPoint & getPoints() const
Definition: TYPolygon.h:123
virtual OVector3D normal() const
Definition: TYPolygon.cpp:243
void updateNormal()
Definition: TYPolygon.cpp:523
void remElmtFromCalculs(TYElement *pElement)
Supprime un element de tous les calculs.
Definition: TYProjet.cpp:722
bool updateAltiRecepteurs()
Definition: TYProjet.cpp:632
double getDelaunayTolerence()
Definition: TYProjet.h:490
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:426
double getHauteurMoyenne() const
virtual bool updateAltitudes(const TYAltimetrie &alti, LPTYRouteGeoNode pGeoNode, OMatrix globalMatrix)
Required the road to update its altitude after altimetry changed.
Definition: TYRoute.cpp:420
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYSegment.cpp:97
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYSegment.cpp:120
TYTabSiteNodeGeoNode collectSites(bool include=true) const
const double getAltiEmprise() const
Definition: TYSiteNode.h:141
double _SIG_Y
Definition: TYSiteNode.h:703
void setProjet(const LPTYProjet pProjet)
Definition: TYSiteNode.cpp:557
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYSiteNode.cpp:223
void purge()
Definition: TYSiteNode.h:97
LPTYAltimetrie getAltimetry() const
void appendSite(LPTYSiteNode pSiteFrom, const OMatrix &matrix, LPTYSiteNode pSiteTo)
OMatrix getGlobalMatrix() const
LPTYTopographie getTopographie()
Definition: TYSiteNode.h:149
virtual void updateCurrentCalcul(TYListID &listID, bool recursif=true)
Definition: TYSiteNode.cpp:541
virtual void setIsGeometryModified(bool isModified)
Definition: TYSiteNode.cpp:498
bool readMesh(std::deque< OPoint3D > &points, std::deque< OTriangle > &triangles, std::deque< LPTYSol > &materials, const QString &meshFilePath)
Definition: TYSiteNode.cpp:731
virtual void do_updateAltimetrie(QString resultMeshFilePath)
Definition: TYSiteNode.cpp:643
virtual bool remFromCalcul()
Definition: TYSiteNode.cpp:524
LPTYTopographie _pTopographie
Topographie.
Definition: TYSiteNode.h:664
void setEmprise(TYTabPoint points)
Definition: TYSiteNode.h:362
QString _topoFile
Nom du fichier de topographie temporaire.
Definition: TYSiteNode.h:679
virtual void setChildsNotInCurrentCalcul()
void setTopoFileName(const QString &name)
Definition: TYSiteNode.h:248
virtual void getChilds(LPTYElementArray &childs, bool recursif=true)
Definition: TYSiteNode.cpp:470
LPTYSiteNode merge()
virtual void reparent()
Definition: TYSiteNode.cpp:566
bool remSiteNode(const LPTYSiteNodeGeoNode pSiteNodeGeoNode)
LPTYInfrastructure getInfrastructure()
Definition: TYSiteNode.h:174
LPTYInfrastructure _pInfrastructure
Infrastructure.
Definition: TYSiteNode.h:667
QString _topoFileName
Nom du fichier de topographie (image de fond)
Definition: TYSiteNode.h:673
virtual ~TYSiteNode()
Definition: TYSiteNode.cpp:97
double _altiEmprise
Altitude associee a l'emprise (s'il y a lieu)
Definition: TYSiteNode.h:661
float _echelle
Echelle du site.
Definition: TYSiteNode.h:685
virtual int fromXML(DOM_Element domElement)
Definition: TYSiteNode.cpp:324
systemSIG _SIGType
Coordonnees SIG.
Definition: TYSiteNode.h:700
const QString & getMeshFilePath()
Definition: TYSiteNode.cpp:59
TYTabSiteNodeGeoNode _listSiteNode
Liste des sites.
Definition: TYSiteNode.h:707
TYPoint _position
Position.
Definition: TYSiteNode.h:689
QString _meshFilePath
Chemin vers le fichier PLY d'altimétrie.
Definition: TYSiteNode.h:676
bool _useTopoFile
Flag d'utilisation d'une image de fond.
Definition: TYSiteNode.h:670
QString _topoFileExtension
Extension du fichier de topographie.
Definition: TYSiteNode.h:682
virtual void updateAcoustique(const bool &force=false)
void setMeshFilePath(const QString &path)
Definition: TYSiteNode.cpp:64
void uuid2tysol(const std::deque< std::string > &material_ids, std::deque< LPTYSol > &materials)
Definition: TYSiteNode.cpp:758
void update(const bool &force=false)
bool _root
Test si site racine.
Definition: TYSiteNode.h:697
void getListFaces(TYTabAcousticSurfaceGeoNode &tabFaces, unsigned int &nbFaceInfra, std::vector< bool > &EstUnIndexDeFaceEcran) const
static const QString & getTopoFilePath()
Definition: TYSiteNode.cpp:49
double getDelaunay()
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYSiteNode.cpp:271
TYTabSiteNodeGeoNode & getListSiteNode()
Definition: TYSiteNode.h:346
virtual std::string toString() const
Definition: TYSiteNode.cpp:266
LPTYSiteNodeGeoNode findSiteNode(const LPTYSiteNode pSiteNode)
LPTYProjet _pProjet
Projet auquel appartient (eventuellement) le site.
Definition: TYSiteNode.h:655
TYSegment _orientation
Orientation du Nord.
Definition: TYSiteNode.h:687
bool addSiteNode(LPTYSiteNodeGeoNode pSiteNodeGeoNode)
void loadTopoFile()
Definition: TYSiteNode.cpp:583
virtual TYSiteNode & operator=(const TYSiteNode &other)
Operateur =.
Definition: TYSiteNode.cpp:102
virtual bool updateAltimetrie(QString resultMeshFilePath)
Definition: TYSiteNode.cpp:625
static void setTopoFilePath(const QString &path)
Definition: TYSiteNode.cpp:54
virtual void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
void getListFacesWithoutFloor(TYTabAcousticSurfaceGeoNode &tabFaces, unsigned int &nbFaceInfra, std::vector< bool > &EstUnIndexDeFaceEcran, std::vector< std::pair< int, int >> &indices, std::vector< int > &etages) const
bool getUseEmpriseAsCrbNiv() const
Definition: TYSiteNode.h:123
virtual void updateAltiInfra()
Definition: TYSiteNode.cpp:781
void groundBasedFaces(const TYTabAcousticVolumeGeoNode &volumes, const OMatrix &global_matrix, std::map< TYUUID, std::deque< TYTabPoint3D >> &contours) const
bool getRoot() const
Definition: TYSiteNode.h:321
double _SIG_X
Definition: TYSiteNode.h:702
virtual bool addToCalcul()
Definition: TYSiteNode.cpp:508
void getFacesOnGround(std::map< TYUUID, std::deque< TYTabPoint3D >> &contours) const
bool _bEmpriseAsCrbNiv
Utilisation de l'emprise comme courbe de niveau.
Definition: TYSiteNode.h:658
virtual bool operator!=(const TYSiteNode &other) const
Operateur !=.
Definition: TYSiteNode.cpp:218
bool _isTopoFileModified
Flag de modification de l'image de fond.
Definition: TYSiteNode.h:710
double _SIG_OFFSET
Definition: TYSiteNode.h:704
virtual bool operator==(const TYSiteNode &other) const
Operateur ==.
Definition: TYSiteNode.cpp:130
static QString _topoFilePath
Chemin du dossier image temporaire.
Definition: TYSiteNode.h:651
Definition: TYSol.h:25
virtual void setListPoints(const TYTabPoint &liste)
Definition: TYTerrain.h:145
LPTYSol getSol() const
Definition: TYTerrain.h:77
virtual TYTabPoint & getListPoints()
Definition: TYTerrain.h:131
void setSol(const LPTYSol pSol)
Definition: TYTerrain.h:89
TYTerrain * getDefTerrain()
virtual void setIsGeometryModified(bool isModified)
TYTabPlanEauGeoNode & getListPlanEau()
bool addCrsEau(LPTYCoursEauGeoNode pCoursEauGeoNode)
LPTYCoursEau getCrsEau(int index)
virtual DOM_Element toXML(DOM_Element &domElement)
virtual void reparent()
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
LPTYAltimetrie getAltimetrie()
void setDefTerrain(int defTerrainIdx)
void setDefTerrainIdx(const int &defTerrainIdx)
TYTabCoursEauGeoNode & getListCrsEau()
bool addCrbNiv(LPTYCourbeNiveauGeoNode pCrbNivGeoNode)
bool addPlanEau(LPTYPlanEauGeoNode pPlanEauGeoNode)
LPTYTerrain getTerrain(int index)
TYTabPoint & getEmprise()
TYTabCourbeNiveauGeoNode & getListCrbNiv()
bool addTerrain(LPTYTerrainGeoNode pTerGeoNode)
TYTabTerrainGeoNode & getListTerrain()
void sortTerrainsBySurface()
void exportCSV(std::ofstream &ofs)
Export au format csv sur un flux transmis.
static QString getSavedFileName()
Definition: TYXMLManager.h:140
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 void addElementIntValue(DOM_Element &parentElem, DOMString nodeName, int nodeValue)
Definition: TYXMLTools.cpp:72
static bool getElementFloatValue(DOM_Element parentElem, DOMString nodeName, float &nodeValue)
Definition: TYXMLTools.cpp:211
static bool getElementIntValue(DOM_Element parentElem, DOMString nodeName, int &nodeValue)
Definition: TYXMLTools.cpp:129
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
static void addElementFloatValue(DOM_Element &parentElem, DOMString nodeName, float nodeValue)
Definition: TYXMLTools.cpp:82
read an Altimetry from a PLY file.
virtual const points_array_t & points() const
virtual void read()
read the file whose name was given at reader's construction time
virtual const materials_array_t & materials() const
Getter for the faces read.
virtual const faces_array_t & faces() const
Getter for the faces read.
static FILE * openFileForReading(const QString &filename)
#define tympan_source_loc
This macro build a source_loc object to be attached to a tympan::Exception.
Definition: exceptions.h:91
unsigned int uint32
Definition: defines.h:75
void save_project(const char *filename, const LPTYProjet &project)
save a project into an XML file
The base exception class for all exceptions specific to Code_TYMPAN.
Definition: exceptions.h:63
The base exception class for errors due to invalid data.
Definition: exceptions.h:75
bool python(QStringList args, std::string &error_msg)
Launch a Python subprocess and wait for it using a non-blocking UI loop.
bool must_keep_tmp_files()
Tell whether temporary files should be preserved (debug mode).
bool init_tmp_file(QTemporaryFile &tmp_file, bool keep_file)
Create and initialize a QTemporaryFile according to the current policy.
Utilities to interact with Python subprocesses from the Tympan application.
Utilities to load a project and a solver.