Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYSetGeometriqueParcours.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 /*
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];
51 };
52 
57 {
58 public:
64 
68  static QMutex _mutex;
71  {
72  Init();
73  }
76  {
77  Clean();
78  }
79  // NB: PolyligneP0 & PolyligneP1 ne sont pas copies:
81  void Copy(TYSetGeometriqueParcours& geoIn);
83  void AllouerPolylignes(int nNbPolylineAllouee)
84  {
85  _nNbPolylineAllouee = nNbPolylineAllouee;
86  _ListePolylines = new TYPolyligneParcours[nNbPolylineAllouee];
87  };
91  int MergePointsDoubles();
92  // Undefined method:
93  // int SupprimeLesPointsDoubles();
103  void SeparationDroiteGauche(bool* PointsAGauche, bool* PointsADroite, TYSetGeometriqueParcours& geoGauche,
104  TYSetGeometriqueParcours& geoDroite, int compteurIter = 0);
109  bool polyligneContientSouR(int i);
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, int compteurIter = 0);
154  bool SecondePasse(TYSetGeometriqueParcours& geoPremierePasse, TYSetGeometriqueParcours& geoSecondePasse,
155  bool bTrajetsAGaucheDeSR, TYPointParcours**& pTableauEC, int& nbPtsEC,
156  int compteurIter = 0, bool bIsLastSecondePasse = false);
159  int* IndexePointsFrontiere, int NbPointsFrontiere);
161  bool AjoutePointALaPolyLigne(int indexPolyligne, TYPointParcours& P);
163  int AjouteLesPointsComprisEntre(TYSetGeometriqueParcours& geoPolySource, int nIndexePoly,
164  int nIndexeNbPremierPointAAjouter, int nIndexeDernierPointAAjouter);
166  int ParcourtPolyligneAPartirDe(int IndexPointRacine, TYPolyligneParcours*& PolyligneRacine,
167  std::vector<bool>& pEstUnPointIntersectant,
168  TYSetGeometriqueParcours& geoPremierePasse);
176 
184  bool intersects(TYSetGeometriqueParcours& geoPasse);
185 
195  bool coincideWith(TYSetGeometriqueParcours& otherGeoPasse);
196 
197  /* Unused method:
198  int NbreRefPoint()
199  {
200  int nNbRefPoint = 0;
201  //Nombre de reference aux points dans les polylignes
202  for (int i = 0; i < _nNbPolylines; i++)
203  {
204  nNbRefPoint += _ListePolylines[i].nombreDePoint();
205  }
206  return nNbRefPoint;
207  }*/
208 
217  static int EnveloppeConvexeLes2PremiersPointsEtant(TYPointParcours** TableauDePoints, int nNbPoints,
218  TYPointParcours** TableauDePointsECOut,
219  bool bPremiersPointsLesPlusHauts);
229  TYPointParcours** TableauDePoints, int nNbPoints);
231  void CreerTrajetAPartirDuneListeDePointsTriee(TYPointParcours** TableauDePoints, int nNbPoints,
232  bool bSens, bool bGardeIdentifiant);
235 
242  bool extendListePoint(int nNouvelleTaille);
243 
245  void Clean()
246  {
247  if (_ListePolylines)
248  {
250  }
251  if (_ListePoint)
252  {
254  }
255  }
257  void Init()
258  {
259  _ListePolylines = NULL;
260  _ListePoint = NULL;
261  _nNbPolylines = 0;
262  _nNbPointTotal = 0;
264  }
265 
266 private:
267  // int MergePointsDoubles(bool bLexico);
269  void SwapPolyligne(int i, int j);
270 
276  static void InverseOrdreDesPoints(TYPointParcours** ListeDePointsAInverser, int nNbPointsDeLaListe);
277 };
278 
279 #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.
TYPointParcours * _ListePoint
List of points on the path.
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.
static int EnveloppeConvexeLes2PremiersPointsEtant(TYPointParcours **TableauDePoints, int nNbPoints, TYPointParcours **TableauDePointsECOut, bool bPremiersPointsLesPlusHauts)
Compute the convex hull (arrays should be allocated before the call)
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.
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 TYPointParcours * _DestQSort
static access to the C function of quicksort
static TYPointParcours * _ListePointQSort
static access to the C function of quicksort
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)
void SeparationDroiteGauche(bool *PointsAGauche, bool *PointsADroite, TYSetGeometriqueParcours &geoGauche, TYSetGeometriqueParcours &geoDroite, int compteurIter=0)
Separate left and right polylines with two geometric paths.
bool coincideWith(TYSetGeometriqueParcours &otherGeoPasse)
Tests if the first polyline of this geo parcours coincide with the geo passe in argument,...
static TYPointParcours * _SrceQSort
static access to the C function of quicksort
static void InverseOrdreDesPoints(TYPointParcours **ListeDePointsAInverser, int nNbPointsDeLaListe)
Invert a list of points.
int _nNbPolylines
Polylines number.
void Copy(TYSetGeometriqueParcours &geoIn)
Copy operator.
int _nNbPointTotal
Total number of points.
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.
bool extendListePoint(int nNouvelleTaille)
Extends the attribute array _ListePoint.
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.