Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYSetGeometriqueParcours.h
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 /*
17  *
18  *
19  *
20  *
21  */
22 
23 #ifndef TYSET_GEOMETRIQUE_PARCOURS_H
24 #define TYSET_GEOMETRIQUE_PARCOURS_H
25 
26 #include "Tympan/core/macros.h"
27 #include "TYPointParcours.h"
28 #include "TYPolyligneParcours.h"
29 #include <qmutex.h>
30 #include <vector>
31 
32 // On devrait pouvoir etendre le nombre de point sur (2pow31) -1, vue que les indentifiants sont codes sur des
33 // int:
34 #define MAX_POINTS 32767
35 
36 // Afin d'eviter des bugs de synchronisation de differents listes de points,
37 // traitement basee sur les identifiants (SelectionnePointsEntreSetRetDuCoteDeSR,...),
38 // on marque les identifiants des points particuliers Source et Recepteur,
39 // provenant en outre toujours d'une liste separee
40 #define INDENTIFIANT_SOURCE MAX_POINTS
41 #define INDENTIFIANT_RECEPTEUR (MAX_POINTS - 1)
42 
47 struct Connexite
48 {
49  int IndexesSegment[2];
50  int NbSegmentsConnexes;
51 };
52 
57 {
58 public:
61  int _nNbPolylines;
63  int _nNbPointTotal;
64 
66  static TYPointParcours* _SrceQSort;
67  static TYPointParcours* _DestQSort;
68  static QMutex _mutex;
71  {
72  Init();
73  }
76  {
77  Clean();
78  }
79  // NB: PolyligneP0 & PolyligneP1 ne sont pas copies:
83  void AllouerPolylignes(int nNbPolylineAllouee)
84  {
85  _nNbPolylineAllouee = nNbPolylineAllouee;
86  _ListePolylines = new TYPolyligneParcours[nNbPolylineAllouee];
87  };
92  // Undefined method:
93  // int SupprimeLesPointsDoubles();
103  void SeparationDroiteGauche(bool* PointsAGauche, bool* PointsADroite, TYSetGeometriqueParcours& geoGauche,
104  TYSetGeometriqueParcours& geoDroite);
117  void MarquePointsADroiteEtAGauche(TYPointParcours& Srce, TYPointParcours& Dest, bool*& PointsAGauche,
118  bool*& PointsADroite);
121  int* IndexePointsFrontiere, int& NbPointsFrontiere,
122  std::vector<bool>& pEstUnPointIntersectant, bool bCoteGauche,
123  bool* PointsAGauche, bool* PointsADroite);
129  bool ListerPointsConnexes(Connexite*& Connexes, std::vector<bool>& pEstUnPointIntersectant);
130 
142  bool PremierePasse(TYPointParcours& Srce, TYPointParcours& Dest, int* IndexePointsFrontiere,
143  int NbPointsFrontiere, std::vector<bool>& pEstUnPointIntersectant, Connexite* Connexes,
144  TYSetGeometriqueParcours& geoPremierePasse);
154  bool SecondePasse(TYSetGeometriqueParcours& geoPremierePasse, TYSetGeometriqueParcours& geoSecondePasse,
155  bool bTrajetsAGaucheDeSR, TYPointParcours**& pTableauEC, int& nbPtsEC);
158  int* IndexePointsFrontiere, int NbPointsFrontiere);
160  bool AjoutePointALaPolyLigne(int indexPolyligne, TYPointParcours& P);
162  int AjouteLesPointsComprisEntre(TYSetGeometriqueParcours& geoPolySource, int nIndexePoly,
163  int nIndexeNbPremierPointAAjouter, int nIndexeDernierPointAAjouter);
165  int ParcourtPolyligneAPartirDe(int IndexPointRacine, TYPolyligneParcours*& PolyligneRacine,
166  std::vector<bool>& pEstUnPointIntersectant,
167  TYSetGeometriqueParcours& geoPremierePasse);
175 
176  /* Unused method:
177  int NbreRefPoint()
178  {
179  int nNbRefPoint = 0;
180  //Nombre de reference aux points dans les polylignes
181  for (int i = 0; i < _nNbPolylines; i++)
182  {
183  nNbRefPoint += _ListePolylines[i].nombreDePoint();
184  }
185  return nNbRefPoint;
186  }*/
187 
196  static int EnveloppeConvexeLes2PremiersPointsEtant(TYPointParcours** TableauDePoints, int nNbPoints,
197  TYPointParcours** TableauDePointsECOut,
198  bool bPremiersPointsLesPlusHauts);
208  TYPointParcours** TableauDePoints, int nNbPoints);
210  void CreerTrajetAPartirDuneListeDePointsTriee(TYPointParcours** TableauDePoints, int nNbPoints,
211  bool bSens, bool bGardeIdentifiant);
214 
215 private:
216  // int MergePointsDoubles(bool bLexico);
218  void SwapPolyligne(int i, int j);
220  void Clean()
221  {
222  if (_ListePolylines)
223  {
225  }
226  if (_ListePoint)
227  {
229  }
230  }
232  void Init()
233  {
234  _ListePolylines = NULL;
235  _ListePoint = NULL;
236  _nNbPolylines = 0;
237  _nNbPointTotal = 0;
239  }
245  static void InverseOrdreDesPoints(TYPointParcours** ListeDePointsAInverser, int nNbPointsDeLaListe);
246 };
247 
248 #endif // TYSET_GEOMETRIQUE_PARCOURS_H
NxReal c
Definition: NxVec3.cpp:317
Polylines path class used by the TYSetGeometriqueParcours class.
Class to build a geometric path used by the TYCalculParcours class.
void MarquePointsADroiteEtAGauche(TYPointParcours &Srce, TYPointParcours &Dest, bool *&PointsAGauche, bool *&PointsADroite)
Mark points on the left and on the right of the current geometric path.
int ParcourtPolyligneAPartirDe(int IndexPointRacine, TYPolyligneParcours *&PolyligneRacine, std::vector< bool > &pEstUnPointIntersectant, TYSetGeometriqueParcours &geoPremierePasse)
To be commented.
bool intersects(TYPointParcours &P1, TYPointParcours &P2)
Check if [P1P2] segment can intersect the geometric path.
void Clean()
Delete polylines list and points list.
bool SecondePasse(TYSetGeometriqueParcours &geoPremierePasse, TYSetGeometriqueParcours &geoSecondePasse, bool bTrajetsAGaucheDeSR, TYPointParcours **&pTableauEC, int &nbPtsEC, int compteurIter=0, bool bIsLastSecondePasse=false)
Second pass.
bool polyligneContientSouR(int i)
Returns true if polyligne of index i contains Source or Receptor.
void RamenerPointsTraversantLaFrontiere(TYPointParcours &Srce, TYPointParcours &Dest, int *IndexePointsFrontiere, int &NbPointsFrontiere, std::vector< bool > &pEstUnPointIntersectant, bool bCoteGauche, bool *PointsAGauche, bool *PointsADroite)
To be commented.
void SwapPolyligne(int i, int j)
Swap polylines i and j.
int SupressionPolylignesRedondantes()
Suppress useless polylines.
TYPolyligneParcours * _ListePolylines
Geometric path as a polylines.
void TriePointsIntersectionSuivantSR(TYPointParcours &Srce, TYPointParcours &Dest, int *IndexePointsFrontiere, int NbPointsFrontiere)
To be commented.
static void InverseOrdreDesPoints(TYPointParcours **ListeDePointsAInverser, int nNbPointsDeLaListe)
Invert a list of points.
static TYPointParcours * _DestQSort
static access to the C function of quicksort
int SelectionnePointsEntreSetRetDuCoteDeSR(TYSetGeometriqueParcours *geoSR, TYPointParcours **TableauDePoints, int nNbPoints)
Select points from the current geometric path which are between source and receptor of the geoSR geom...
static int EnveloppeConvexeLes2PremiersPointsEtant(TYPointParcours **TableauDePoints, int nNbPoints, TYPointParcours **TableauDePointsECOut, bool bPremiersPointsLesPlusHauts)
Compute the convex hull (arrays should be allocated before the call)
bool PolylignesInfraFermees()
Return true if all polylines from infrastructure are closed.
void CreerTrajetAPartirDuneListeDePointsTriee(TYPointParcours **TableauDePoints, int nNbPoints, bool bSens, bool bGardeIdentifiant)
Create paths from a sorted points list (Used only for vertical paths)
static TYPointParcours * _SrceQSort
static access to the C function of quicksort
void SeparationDroiteGauche(bool *PointsAGauche, bool *PointsADroite, TYSetGeometriqueParcours &geoGauche, TYSetGeometriqueParcours &geoDroite, int compteurIter=0)
Separate left and right polylines with two geometric paths.
int _nNbPolylines
Polylines number.
TYPointParcours * _ListePoint
List of points on the path.
void Copy(TYSetGeometriqueParcours &geoIn)
Copy operator.
int _nNbPointTotal
Total number of points.
static TYPointParcours * _ListePointQSort
static access to the C function of quicksort
bool AjoutePointALaPolyLigne(int indexPolyligne, TYPointParcours &P)
Add a point P to the polyline indexPolyligne.
void AllouerPolylignes(int nNbPolylineAllouee)
Allocation of the polylines list.
bool PremierePasse(TYPointParcours &Srce, TYPointParcours &Dest, int *IndexePointsFrontiere, int NbPointsFrontiere, std::vector< bool > &pEstUnPointIntersectant, Connexite *Connexes, TYSetGeometriqueParcours &geoPremierePasse, int compteurIter=0)
First pass to build a path along all the intersecting polylines.
bool ListerPointsConnexes(Connexite *&Connexes, std::vector< bool > &pEstUnPointIntersectant)
Fill for each point the connectivity with segments.
int MergePointsDoubles()
Detect and fix double points.
bool AppartienneMemePolyligne(TYPointParcours *a, TYPointParcours *b, TYPointParcours *c)
Check if the points a, b, c belong to the same polyline.
int AjouteLesPointsComprisEntre(TYSetGeometriqueParcours &geoPolySource, int nIndexePoly, int nIndexeNbPremierPointAAjouter, int nIndexeDernierPointAAjouter)
Add some points of the nIndexePoly polyline from the geoPolySource geometric path.
int _nNbPolylineAllouee
Allocated polylines.
#define SAFE_DELETE_LIST(_p)
Definition: macros.h:239
Connectivity between points and segments.
int IndexesSegment[2]
Two indexes of the segment.
int NbSegmentsConnexes
Related segments number.
Point of a path.