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