Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAcousticPathFinder.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 
18 #include "TYSolver.h"
19 #include "TYAcousticPathFinder.h"
20 
21 TYAcousticPathFinder::TYAcousticPathFinder(TYSolver& solver) : _solver(solver), _bCalcTrajetHorizontaux(false)
22 {
23 }
24 
26 
28 {
30 }
31 
32 void TYAcousticPathFinder::computePath(const std::deque<TYSIntersection>& tabIntersect,
33  const TYTrajet& trajet, TabPoint3D& ptsTop, TabPoint3D& ptsLeft,
34  TabPoint3D& ptsRight)
35 {
36  bool dessus = true, lateral = false;
37 
38  // Construction du rayon SR
39  OSegment3D rayon;
40  trajet.getPtSetPtRfromOSeg3D(rayon);
41 
42  // Determination du parcours et calcul des chemins
43  // 1. Parcours vertical
44  // le dernier ptsTop n'est pas affecte
45  computeParcoursLateraux(tabIntersect, rayon, dessus, ptsTop, ptsTop);
46 
47  // Parcours gauche & droits si necessaire
48  computeParcoursLateraux(tabIntersect, rayon, lateral, ptsLeft, ptsRight);
49 }
50 
51 bool TYAcousticPathFinder::computeParcoursLateraux(const std::deque<TYSIntersection>& tabIntersect,
52  const OSegment3D& rayon, const bool& dessus,
53  TabPoint3D& ptsLeft, TabPoint3D& ptsRight) const
54 {
55  // Si on est en trajet lateral non demande par le calcul
56  if (!_bCalcTrajetHorizontaux && !dessus)
57  {
58  return false;
59  }
60 
61  size_t nbFaces = tabIntersect.size();
62 
63  short indiceIntersect = dessus ? 0 : 1;
64  TYCalculParcours Parcours(static_cast<int>(nbFaces), dessus != 0); // dessus = vue de cote
65 
66  // Quoiqu'il arrive, on ajoute la source:
67  ptsLeft.push_back(rayon._ptA);
68  // Si on a une vue de haut, on doit aussi calculer les trajets a droite:
69  if (!dessus)
70  {
71  ptsRight.push_back(rayon._ptA);
72  }
73 
74  // Creation du segment SR
75  Parcours.AjouterSegmentSR(const_cast<double*>(rayon._ptA._value), const_cast<double*>(rayon._ptB._value));
76 
77  for (size_t i = 0; i < nbFaces; i++)
78  {
79  if (tabIntersect[i].bIntersect[indiceIntersect])
80  {
81  TYSIntersection inter = tabIntersect[i];
82  Parcours.AjouterSegmentCoupe((double*)inter.segInter[indiceIntersect]._ptA._value,
83  (double*)inter.segInter[indiceIntersect]._ptB._value, inter.isInfra,
84  inter.isEcran);
85  }
86  }
87 
88  // Traitement du parcours
89  Parcours.Traitement();
90 
91  // La liste a retourner ne contient pas le dernier point (Recepteur)
92  // On retourne 2 listes si on est en vue de haut (parcours lateraux),
93  // sinon une seule (vue de face => trajet par dessus les obstacles)
94  double dPointTemp[3];
95  // Que l'on soit en vue de haut ou non, il faut le trajet gauche
96  int nNbrePointsTrajetGauche = Parcours.NombrePointsTrajetGauche();
97  OPoint3D pt;
98  for (int j = 1; j < (nNbrePointsTrajetGauche - 1);
99  j++) //-1: pas de recepteur en sortie; 1 car la source a deja ete ajoutee
100  {
101  Parcours.PointTrajetGauche(j, dPointTemp);
102  pt._x = dPointTemp[0];
103  pt._y = dPointTemp[1];
104  pt._z = dPointTemp[2]; // x y z
105  ptsLeft.push_back(pt);
106  }
107 
108  if (!dessus)
109  {
110  int nNbrePointsTrajetDroite = Parcours.NombrePointsTrajetDroite();
111  OPoint3D pt;
112  for (int j = 1; j < (nNbrePointsTrajetDroite - 1);
113  j++) //-1: pas de recepteur en sortie; 1 car la source a deja ete ajoutee
114  {
115  Parcours.PointTrajetDroite(j, dPointTemp);
116  pt._x = dPointTemp[0];
117  pt._y = dPointTemp[1];
118  pt._z = dPointTemp[2]; // x y z
119  ptsRight.push_back(pt);
120  }
121  }
122 
123  return true;
124 }
std::vector< OPoint3D > TabPoint3D
Definition: 3d.h:483
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
double _value[3]
Definition: 3d.h:286
The 3D point class.
Definition: 3d.h:487
Class to define a segment.
Definition: 3d.h:1089
OPoint3D _ptA
Point A of the segment.
Definition: 3d.h:1201
OPoint3D _ptB
Point B of the segment.
Definition: 3d.h:1203
virtual void computePath(const std::deque< TYSIntersection > &tabIntersect, const TYTrajet &trajet, TabPoint3D &ptsTop, TabPoint3D &ptsLeft, TabPoint3D &ptsRight)
Compute a path between a source and a receptor. The receptor is not included in the path.
bool _bCalcTrajetHorizontaux
Boolean to compute or not the horizontal trajectories.
virtual ~TYAcousticPathFinder()
Destructor.
virtual void init()
Initialize the class parameters.
bool computeParcoursLateraux(const std::deque< TYSIntersection > &tabIntersect, const OSegment3D &rayon, const bool &dessus, TabPoint3D &ptsLeft, TabPoint3D &ptsRight) const
TYAcousticPathFinder(TYSolver &solver)
Constructor.
Class for computing path used by TYAcousticPathFinder.
void AjouterSegmentSR(double *ptA, double *ptB)
Add points A (source) and B (receptor)
void AjouterSegmentCoupe(double *ptA, double *ptB, bool isInfra, bool isEcran)
Add a segment defined by 2 points.
bool Traitement()
Build the left and right geometric paths.
void PointTrajetDroite(int i, double *pt)
Return the ith point of the right geometric path.
int NombrePointsTrajetDroite()
Return the points number of the left geometric path.
void PointTrajetGauche(int i, double *pt)
Return the ith point of the left geometric path.
int NombrePointsTrajetGauche()
Return the points number of the right geometric path.
9613 Solver
Definition: TYSolver.h:38
This class TYTrajet (journey) links a couple Source-Receptor and a collection of paths,...
Definition: TYTrajet.h:35
void getPtSetPtRfromOSeg3D(OSegment3D &seg) const
Definition: TYTrajet.h:175
static LPSolverConfiguration get()
Get the configuration.
Definition: config.cpp:93
This file provides class for solver configuration.
Data structure for intersections.
bool isInfra
Flag to define if is a infrastructure face.
OSegment3D segInter[2]
bool isEcran
Flag to define if is a screen face.