Code_TYMPAN  4.2.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 
31 //On devrait pouvoir etendre le nombre de point sur (2pow31) -1, vue que les indentifiants sont codes sur des int:
32 #define MAX_POINTS 32767
33 
34 //Afin d'eviter des bugs de synchronisation de differents listes de points,
35 //traitement basee sur les identifiants (SelectionnePointsEntreSetRetDuCoteDeSR,...),
36 //on marque les identifiants des points particuliers Source et Recepteur,
37 //provenant en outre toujours d'une liste separee
38 #define INDENTIFIANT_SOURCE MAX_POINTS
39 #define INDENTIFIANT_RECEPTEUR (MAX_POINTS-1)
40 
45 struct Connexite
46 {
47  int IndexesSegment[2];
48  int NbSegmentsConnexes;
49 };
50 
55 {
56 public:
57  TYPolyligneParcours* _ListePolylines;
58  TYPointParcours* _ListePoint;
59  int _nNbPolylines;
60  int _nNbPolylineAllouee;
61  int _nNbPointTotal;
62 
63  static TYPointParcours* _ListePointQSort;
64  static TYPointParcours* _SrceQSort;
65  static TYPointParcours* _DestQSort;
66  static QMutex _mutex;
67  TYSetGeometriqueParcours() { Init();}
71  // NB: PolyligneP0 & PolyligneP1 ne sont pas copies:
73  void Copy(TYSetGeometriqueParcours& geoIn);
75  void AllouerPolylignes(int nNbPolylineAllouee)
76  {
77  _nNbPolylineAllouee = nNbPolylineAllouee;
78  _ListePolylines = new TYPolyligneParcours[nNbPolylineAllouee];
79  };
81  bool PolylignesInfraFermees();
83  int MergePointsDoubles();
84  // Undefined method:
85  // int SupprimeLesPointsDoubles();
87  int SupressionPolylignesRedondantes();
95  void SeparationDroiteGauche(bool* PointsAGauche, bool* PointsADroite, TYSetGeometriqueParcours& geoGauche, TYSetGeometriqueParcours& geoDroite);
103  void MarquePointsADroiteEtAGauche(TYPointParcours& Srce, TYPointParcours& Dest, bool*& PointsAGauche, bool*& PointsADroite);
105  void RamenerPointsTraversantLaFrontiere(TYPointParcours& Srce, TYPointParcours& Dest, int* IndexePointsFrontiere, int& NbPointsFrontiere, bool* EstUnPointIntersectant, bool bCoteGauche, bool* PointsAGauche, bool* PointsADroite);
110  bool ListerPointsConnexes(Connexite *& Connexes);
111 
123  bool PremierePasse(TYPointParcours& Srce, TYPointParcours& Dest, int* IndexePointsFrontiere, int NbPointsFrontiere, bool* EstUnPointIntersectant, Connexite* Connexes, TYSetGeometriqueParcours& geoPremierePasse);
133  bool SecondePasse(TYSetGeometriqueParcours& geoPremierePasse, TYSetGeometriqueParcours& geoSecondePasse, bool bTrajetsAGaucheDeSR, TYPointParcours** & pTableauEC, int& nbPtsEC);
135  void TriePointsIntersectionSuivantSR(TYPointParcours& Srce, TYPointParcours& Dest, int* IndexePointsFrontiere, int NbPointsFrontiere);
137  bool AjoutePointALaPolyLigne(int indexPolyligne, TYPointParcours& P);
139  int AjouteLesPointsComprisEntre(TYSetGeometriqueParcours& geoPolySource, int nIndexePoly, int nIndexeNbPremierPointAAjouter, int nIndexeDernierPointAAjouter);
141  int ParcourtPolyligneAPartirDe(int IndexPointRacine, TYPolyligneParcours*& PolyligneRacine, bool* EstUnPointIntersectant, TYSetGeometriqueParcours& geoPremierePasse);
148  bool intersects(TYPointParcours& P1, TYPointParcours& P2);
149 
150  /* Unused method:
151  int NbreRefPoint()
152  {
153  int nNbRefPoint = 0;
154  //Nombre de reference aux points dans les polylignes
155  for (int i = 0; i < _nNbPolylines; i++)
156  {
157  nNbRefPoint += _ListePolylines[i].nombreDePoint();
158  }
159  return nNbRefPoint;
160  }*/
161 
170  static int EnveloppeConvexeLes2PremiersPointsEtant(TYPointParcours** TableauDePoints, int nNbPoints, TYPointParcours** TableauDePointsECOut, bool bPremiersPointsLesPlusHauts);
178  int SelectionnePointsEntreSetRetDuCoteDeSR(TYSetGeometriqueParcours* geoSR, TYPointParcours** TableauDePoints, int nNbPoints);
180  void CreerTrajetAPartirDuneListeDePointsTriee(TYPointParcours** TableauDePoints, int nNbPoints, bool bSens, bool bGardeIdentifiant);
182  bool AppartienneMemePolyligne(TYPointParcours* a, TYPointParcours* b, TYPointParcours* c);
183 
184 private:
185  //int MergePointsDoubles(bool bLexico);
187  void SwapPolyligne(int i, int j);
189  void Clean()
190  {
191  if (_ListePolylines)
192  {
193  SAFE_DELETE_LIST(_ListePolylines);
194  }
195  if (_ListePoint)
196  {
197  SAFE_DELETE_LIST(_ListePoint);
198  }
199  }
201  void Init()
202  {
203  _ListePolylines = NULL;
204  _ListePoint = NULL;
205  _nNbPolylines = 0;
206  _nNbPointTotal = 0;
207  _nNbPolylineAllouee = 0;
208  }
214  static void InverseOrdreDesPoints(TYPointParcours** ListeDePointsAInverser, int nNbPointsDeLaListe);
215 
216 };
217 
218 #endif// TYSET_GEOMETRIQUE_PARCOURS_H
Polylines path class used by the TYSetGeometriqueParcours class.
Connectivity between points and segments.
void AllouerPolylignes(int nNbPolylineAllouee)
Allocation of the polylines list.
void Init()
Initialize data.
Point of a path.
int IndexesSegment[2]
Two indexes of the segment.
Class to build a geometric path used by the TYCalculParcours class.
NxReal c
Definition: NxVec3.cpp:345
void Clean()
Delete polylines list and points list.
#define SAFE_DELETE_LIST(_p)
Definition: macros.h:235
int NbSegmentsConnexes
Related segments number.