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