Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYCalculParcours.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 
16 /*
17  *
18  */
19 
20 #include <stdio.h>
21 #include <math.h>
22 
24 #include "TYCalculParcours.h"
25 #include <assert.h>
26 
28 
29 TYCalculParcours::TYCalculParcours(int nNbSegMax, bool bVertical)
30 {
31  _bVertical = bVertical;
32  _nNbSegMax = nNbSegMax;
33  // Creation d'un set geometrique pour les donnees d'entree:
39 
40  // Creation d'un set geometrique pour le segment d'entree Source-Recepteur:
42  _geoSR->_nNbPolylines = 0;
46 
47  _vectorPoint.clear();
49 }
50 
52 {
55  _vectorPoint.clear();
57 }
58 
59 void TYCalculParcours::InitChangementVariable2D3D(bool bAxeXMoinsSignifiant)
60 {
61  // Changement de variable en entree pour traitement 2D (une coordonnee ne sera pas prise en compte)
62  if (_bVertical)
63  {
64  // Lorsque le rayon Source-Recepteur est plus oriente suivant Y que X (repere Tympan),
65  // on garde Y (au lieu de X) comme seconde composante (apres Z, l'altitude = la premiere composante
66  // 2D). Remarques :
67  //* la composante ignoree est tout de meme stockee et restituee a la fin (cgangement de variable)
68  //* on ne fait que choisir des points existants
69  //(on n'en calcule pas de nouveaux -du moins pour le calcul vertical-)
70  //* pour les calculs horizontaux, seuls les points sur le trajet Source-Recepteur sont susceptibles
71  // d'etre issus de calculs au lieu de selection. La coordonnee Z de ces points resulte alors d'une
72  // interpollation (cf methode IntersectionDroites) Exemple: le rayon Source-Recepteur est parallele a
73  // l'axe Y; dans ce cas, le plan 2D est (0y, 0z)
74  if (bAxeXMoinsSignifiant)
75  {
76  _indexXInOut = 1; // Y->X
77  _indexYInOut = 2; // Z->Y
78  _indexZInOut = 0; // X->Z
79  }
80  else
81  {
82  _indexXInOut = 0;
83  _indexYInOut = 2; // Z->Y
84  _indexZInOut = 1; // Y->Z
85  }
86  }
87  else
88  {
89  _indexXInOut = 0;
90  _indexYInOut = 1;
91  _indexZInOut = 2;
92  }
93 }
94 
96  bool bVertical)
97 {
98  _geoSR = geoSR;
99  _geoImporterDXF = geoImporterDXF;
100  _bVertical = bVertical;
101  _nNbSegMax = -1; // on se souvient que les polylignes ont ete importees petit a petit
102 }
103 
104 void TYCalculParcours::AjouterSegment(double* ptA, double* ptB, bool isInfra, bool isEcran,
106 {
107  // create point1 from ptA
108  TYPointParcours p1_temp;
109  p1_temp.isInfra = isInfra;
110  p1_temp.isEcran = isEcran;
111  p1_temp.x = ptA[_indexXInOut];
112  p1_temp.y = ptA[_indexYInOut];
113  p1_temp.z = ptA[_indexZInOut];
114 
115  // create point2 from ptB
116  TYPointParcours p2_temp;
117  p2_temp.isInfra = isInfra;
118  p2_temp.isEcran = isEcran;
119  p2_temp.x = ptB[_indexXInOut];
120  p2_temp.y = ptB[_indexYInOut];
121  p2_temp.z = ptB[_indexZInOut];
122 
123  bool ptA_AlreadyExists = false;
124  bool ptB_AlreadyExists = false;
125 
126  int indicePt1Doublon = -1;
127  int indicePt2Doublon = -1;
128 
129  // verifier si ptA et ptB pas de doublons dans la liste de point
130  for (int i = static_cast<int>(_vectorPoint.size()) - 1; i >= 0; i--)
131  {
132  if ((_vectorPoint[i]->isEcran == p1_temp.isEcran) && (_vectorPoint[i]->isInfra == p1_temp.isInfra) &&
134  {
135  ptA_AlreadyExists = true;
136  indicePt1Doublon = i;
137  break;
138  }
139  }
140 
141  for (int i = static_cast<int>(_vectorPoint.size()) - 1; i >= 0; i--)
142  {
143  if ((_vectorPoint[i]->isEcran == p2_temp.isEcran) && (_vectorPoint[i]->isInfra == p2_temp.isInfra) &&
145  {
146  ptB_AlreadyExists = true;
147  indicePt2Doublon = i;
148  break;
149  }
150  }
151 
152  if (ptA_AlreadyExists & !ptB_AlreadyExists)
153  { // SI doublon ptA
154  TYPointParcours* p2 = &(geo->_ListePoint[geo->_nNbPointTotal]);
155  p2->isInfra = isInfra;
156  p2->isEcran = isEcran;
157  p2->x = ptB[_indexXInOut];
158  p2->y = ptB[_indexYInOut];
159  p2->z = ptB[_indexZInOut];
160  p2->Identifiant = geo->_nNbPointTotal;
161  p2->Identifiant = geo->_nNbPointTotal;
162  _vectorPoint.push_back(p2);
163  geo->_nNbPointTotal++;
164  geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(_vectorPoint[indicePt1Doublon], p2);
165  geo->_nNbPolylines++;
166  // delete p1;
167  }
168  else if (!ptA_AlreadyExists & ptB_AlreadyExists)
169  { // SI doublon ptB
170  TYPointParcours* p1 = &(geo->_ListePoint[geo->_nNbPointTotal]);
171  p1->isInfra = isInfra;
172  p1->isEcran = isEcran;
173  p1->x = ptA[_indexXInOut];
174  p1->y = ptA[_indexYInOut];
175  p1->z = ptA[_indexZInOut];
176  p1->Identifiant = geo->_nNbPointTotal;
177  p1->Identifiant = geo->_nNbPointTotal;
178  _vectorPoint.push_back(p1);
179  geo->_nNbPointTotal++;
180  geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(p1, _vectorPoint[indicePt2Doublon]);
181  geo->_nNbPolylines++;
182  // delete p2;
183  }
184  else if (ptA_AlreadyExists & ptB_AlreadyExists)
185  { // SI doublon ptA et ptB
186  geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(_vectorPoint[indicePt1Doublon],
187  _vectorPoint[indicePt2Doublon]);
188  geo->_nNbPolylines++;
189  // delete p1,p2;
190  }
191  else
192  { // SI aucun doublon
193  TYPointParcours* p1 = &(geo->_ListePoint[geo->_nNbPointTotal]);
194  p1->isInfra = isInfra;
195  p1->isEcran = isEcran;
196  p1->x = ptA[_indexXInOut];
197  p1->y = ptA[_indexYInOut];
198  p1->z = ptA[_indexZInOut];
199  p1->Identifiant = geo->_nNbPointTotal;
200 
201  p1->Identifiant = geo->_nNbPointTotal;
202  geo->_nNbPointTotal++;
203  TYPointParcours* p2 = &(geo->_ListePoint[geo->_nNbPointTotal]);
204  p2->isInfra = isInfra;
205  p2->isEcran = isEcran;
206  p2->x = ptB[_indexXInOut];
207  p2->y = ptB[_indexYInOut];
208  p2->z = ptB[_indexZInOut];
209  p2->Identifiant = geo->_nNbPointTotal;
210  p2->Identifiant = geo->_nNbPointTotal;
211  geo->_nNbPointTotal++;
212  _vectorPoint.push_back(p1);
213  _vectorPoint.push_back(p2);
214  // On ajoute une polyligne a geo:
215  geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(p1, p2);
216  geo->_nNbPolylines++;
217  }
218 }
219 
220 void TYCalculParcours::AjouterSegmentCoupe(double* ptA, double* ptB, bool isInfra, bool isEcran)
221 {
223  AjouterSegment(ptA, ptB, isInfra, isEcran, _geoImporterDXF);
224 }
225 
226 void TYCalculParcours::AjouterSegmentSR(double* ptA, double* ptB)
227 {
228  assert(_geoSR->_nNbPointTotal == 0);
229  assert(_geoSR->_nNbPolylines == 0);
230  // On fait ici le choix du systeme de coordonnee:
231  double dDeltaX = fabs(ptA[0] - ptB[0]);
232  double dDeltaY = fabs(ptA[1] - ptB[1]);
233  InitChangementVariable2D3D(dDeltaX < dDeltaY);
234  // InitChangementVariable2D3D(ptA[0] == ptB[0]);
235  AjouterSegment(ptA, ptB, false, false, _geoSR);
236 }
237 
238 void TYCalculParcours::PointTrajetGauche(int i, double* pt)
239 {
241 }
242 
243 void TYCalculParcours::PointTrajetDroite(int i, double* pt)
244 {
246 }
247 
249 {
250  assert(i < geo->_nNbPointTotal);
251  pt[_indexXInOut] = geo->_ListePoint[i].x;
252  pt[_indexYInOut] = geo->_ListePoint[i].y;
253  pt[_indexZInOut] = geo->_ListePoint[i].z;
254 }
255 
257 {
258  if (_geoTrajetDroite == nullptr)
259  {
260  return 0;
261  }
262 
263  double ptA[3];
264  double ptB[3];
265  PointTrajet(0, ptA, _geoSR);
266  PointTrajet(1, ptB, _geoSR);
267 
269 }
270 
272 {
273  if (_geoTrajetGauche == nullptr)
274  {
275  return 0;
276  }
277 
278  double ptA[3];
279  double ptB[3];
280  PointTrajet(0, ptA, _geoSR);
281  PointTrajet(1, ptB, _geoSR);
282 
284 }
285 
287 {
288  _geoTrajetGauche = nullptr;
289  _geoTrajetDroite = nullptr;
290 
291  bool resTraitement =
293 
294  return resTraitement;
295 }
296 
297 bool TYCalculParcours::CalculTrajet(TYSetGeometriqueParcours& geoCourant, bool bCoteGauche,
298  bool* PointsAGauche, bool* PointsADroite,
299  TYSetGeometriqueParcours& geoPremierePasse,
300  TYSetGeometriqueParcours*& geoTrajet)
301 {
302  bool bPasEnferme = true;
303  // 3.4 Calcul des trajets
304  // A partir de maintenant, on ne traite plus qu'un seul cote
305  // bool bCoteGauche = true;
306  // 3.4.1 Ramener les points traversant la frontiere sur la frontiere
307  int* IndexePointsFrontiere = new int[geoCourant._nNbPointTotal];
308  int NbPointsFrontiere = 0;
309 
310  // on considere ici que les polylignes sont en fait des segments (vrai venant de Tympan)
312  _geoSR->_ListePoint[0], _geoSR->_ListePoint[1], IndexePointsFrontiere, NbPointsFrontiere,
313  _estUnPointIntersectant, bCoteGauche, PointsAGauche, PointsADroite);
314 
315  // On va plus loin que s'il y a des points d'intersection (sinon, c'est SR)
316  if (NbPointsFrontiere)
317  {
318  // 3.4.2 Mettre bout a bout les polylignes
319  // Merger les segments: on considere ici que chaque point ne peut appartenir a plus de 2 polylignes (a
320  // verifier en venant de Tympan)
321  Connexite* Connexes = new Connexite[geoCourant._nNbPointTotal];
322 
323  bool bOk = geoCourant.ListerPointsConnexes(Connexes, _estUnPointIntersectant);
324  if (!bOk)
325  {
326  bPasEnferme = false; // on a trouve des points n-uples; comme on ne sait pas les gerer, on
327  // pretexte un enfermemnt
329  }
330  else
331  {
332  // Est-on enferme ? C'est le cas si en suivant une polyligne intersectante,
333  // on se retrouve avant S ou apres R sur [S,R]
334  // Comme on doit parcourir toutes les polylignes intersectantes, on en profite pour calculer les
335  // trajets:
336  bPasEnferme = geoCourant.PremierePasse(_geoSR->_ListePoint[0], _geoSR->_ListePoint[1],
337  IndexePointsFrontiere, NbPointsFrontiere,
338  _estUnPointIntersectant, Connexes, geoPremierePasse);
339  }
340  if (bPasEnferme)
341  {
342  geoTrajet = &geoPremierePasse;
343  }
344 
345  SAFE_DELETE_LIST(Connexes);
346  }
347  SAFE_DELETE_LIST(IndexePointsFrontiere);
348 
349  return bPasEnferme;
350 }
351 
353  TYSetGeometriqueParcours& geoDernierePasseDroite,
354  TYSetGeometriqueParcours*& geoTrajetGauche,
355  TYSetGeometriqueParcours*& geoTrajetDroite)
356 {
357  // Preparation des donnees
358  // 1. Le segment SR doit etre present
359  assert(NULL != _geoSR);
360  if (NULL == _geoSR->_ListePoint)
361  {
362  return -1;
363  }
364  // 2. On attribue des identifiants speciaux aux points S & R, pour ne pas les melanger a d'autres
367 
368  bool bSaGaucheDeR = _geoSR->_ListePoint[0].x > _geoSR->_ListePoint[1].x;
369  // S'il n'y a pas d'obstacle:
371  {
372  // On copie _geoSR
373  geoDernierePasseGauche.Copy(*_geoSR);
374  geoDernierePasseDroite.Copy(*_geoSR);
375 
376  // On n'ecrit pas le fichier
377  return 0;
378  }
379 
380  // 3.1 Filtrage
381  // 3.1.1 Filtrage sur les polylignes
382  if (!_bVertical)
383  {
384  TYPointParcours** pTableauECD = NULL;
385  int nbPtsECD = 0;
386  TYPointParcours** pTableauECG = NULL;
387  TYPointParcours** pTableauFinG = NULL;
388  TYPointParcours** pTableauFinD = NULL;
389 
390  int nbPtsECG = 0;
391  int nbPtsFinG = 0;
392  int nbPtsFinD = 0;
393 
394  TYSetGeometriqueParcours geoGauche;
395  TYSetGeometriqueParcours geoDroite;
396 
398 
399  // 3.2 Marquage des points a gauche ou a droite
400  bool* PointsAGauche = NULL;
401  bool* PointsADroite = NULL;
403  PointsAGauche, PointsADroite);
404 
405  // 3.3 Separation des points suivants le côté droit au gauche
406  // Cette separation donne deja les segments intersectant [SR]
407 
408  _geoImporterDXF->SeparationDroiteGauche(PointsAGauche, PointsADroite, geoGauche, geoDroite);
409 
410  // 3.4 Calcul des trajets
411  TYSetGeometriqueParcours geoPremierePasseGauche;
412  bool bPasEnfermeAGauche = CalculTrajet(geoGauche, true, PointsAGauche, PointsADroite,
413  geoPremierePasseGauche, geoTrajetGauche);
414  if (bPasEnfermeAGauche && geoPremierePasseGauche._nNbPolylines > 0)
415  {
416  TYSetGeometriqueParcours geoSecondePasseGauche;
417  bool bGeoSecondePasseGaucheIntersects = false;
418  int nNbBouclesPasseGauche = 0;
419  do
420  {
421  nNbBouclesPasseGauche++;
422  geoGauche.SecondePasse(geoPremierePasseGauche, geoSecondePasseGauche, true, pTableauECG,
423  nbPtsECG);
424  geoGauche.SecondePasse(geoSecondePasseGauche, geoDernierePasseGauche, true, pTableauFinG,
425  nbPtsFinG, MAX_POINTS, true);
426  bGeoSecondePasseGaucheIntersects = geoGauche.intersects(geoDernierePasseGauche);
427  if (geoPremierePasseGauche.coincideWith(geoDernierePasseGauche))
428  {
429  break;
430  }
431 
432  geoPremierePasseGauche.Clean();
433  geoPremierePasseGauche.Copy(geoDernierePasseGauche);
434  } while (bGeoSecondePasseGaucheIntersects && (nNbBouclesPasseGauche < 4));
435 
436  if (!bGeoSecondePasseGaucheIntersects)
437  {
438  geoTrajetGauche = &geoDernierePasseGauche;
439  }
440  else
441  {
442  geoTrajetGauche = nullptr;
443  }
444  }
445 
446  TYSetGeometriqueParcours geoPremierePasseDroite;
447  bool bPasEnfermeADroite = CalculTrajet(geoDroite, false, PointsAGauche, PointsADroite,
448  geoPremierePasseDroite, geoTrajetDroite);
449  if (bPasEnfermeADroite && geoPremierePasseDroite._nNbPolylines > 0)
450  {
451  TYSetGeometriqueParcours geoSecondePasseDroite;
452  bool bGeoSecondePasseDroiteIntersects = false;
453  int nNbBouclesPasseDroite = 0;
454  do
455  {
456  nNbBouclesPasseDroite++;
457  geoDroite.SecondePasse(geoPremierePasseDroite, geoSecondePasseDroite, false, pTableauECD,
458  nbPtsECD);
459  geoDroite.SecondePasse(geoSecondePasseDroite, geoDernierePasseDroite, false, pTableauFinD,
460  nbPtsFinD, MAX_POINTS, true);
461  bGeoSecondePasseDroiteIntersects = geoDroite.intersects(geoDernierePasseDroite);
462  if (geoPremierePasseDroite.coincideWith(geoDernierePasseDroite))
463  {
464  break;
465  }
466 
467  geoPremierePasseDroite.Clean();
468  geoPremierePasseDroite.Copy(geoDernierePasseDroite);
469  } while (bGeoSecondePasseDroiteIntersects && (nNbBouclesPasseDroite < 4));
470 
471  if (!bGeoSecondePasseDroiteIntersects)
472  {
473  geoTrajetDroite = &geoDernierePasseDroite;
474  }
475  else
476  {
477  geoTrajetDroite = nullptr;
478  }
479  }
480 
481  SAFE_DELETE_LIST(PointsAGauche);
482  SAFE_DELETE_LIST(PointsADroite);
483 
484  SAFE_DELETE_LIST(pTableauECD);
485  SAFE_DELETE_LIST(pTableauECG);
486 
487  SAFE_DELETE_LIST(pTableauFinG);
488  SAFE_DELETE_LIST(pTableauFinD);
489  }
490  else
491  {
492  // Il suffit de calculer l'EC de l'ensemble des points formes par ceux d'abscisse compris entre Sx &
493  // Rx, et d'en prendre la partie superieure Avant, on termine le merge entrepris avant, ie qu'on ne
494  // reordonne la liste pour mettre en premier les nons doublons
495  //_geoImporterDXF->GenerePointNonConfondus();
496  // Hypotheses:
497  // On suppose que ni source ni recepteur ne sont dans un batiment
498  TYPointParcours** TableauDePointsSelectionnes =
500  2]; // +2 pour prendre en compte les points S et R qui sont ajoutes
501  int nNbPointsSelectiones = _geoImporterDXF->SelectionnePointsEntreSetRetDuCoteDeSR(
502  _geoSR, TableauDePointsSelectionnes, _geoImporterDXF->_nNbPointTotal);
503 
504  TYPointParcours** TableauDePointsEC = new TYPointParcours*[nNbPointsSelectiones];
505  // int nNbPointsEC =
506  // TYSetGeometriqueParcours::EnveloppeConvexeLes2PremiersPointsEtantLesPlusBas(TableauDePointsSelectionnes,
507  // nNbPointsSelectiones, TableauDePointsEC);
508 
509  int nNbPointsEC = 0;
510  bool bWrong = false;
511  int idx = 0;
512  TYPointParcours A, B;
513 
514  // xbh: corrige le pb de trajet vu sur le projet UMP 1.7 insono.xml
515  // Ce n'est vraiment pas optimal, mais je n'ai pas trouve de meilleure solution
516  // avec l'algorithme actuel que d'eliminer les points posant probleme et de recalculer
517  // l'enveloppe convexe a partir du nouvel ensemble de points.
518  // Cela a l'air de mieux fonctionner, mais il doit rester des cas ou des problemes persistent.
519  // En particulier, on suppose dans le filtrage de l'enveloppe que l'on n'a pas de points de
520  // rebroussements. Ce qui est faux dans le cas ou on passe par dessus un mur d'epaisseur nulle (mais
521  // ce cas est-il possible dans Tympan??)
522  do
523  {
525  TableauDePointsSelectionnes, nNbPointsSelectiones, TableauDePointsEC, false);
526 
527  // xbh: ajout d'une deuxieme passe pour filter l'enveloppe convexe en eliminant les points de
528  // rebroussements
529  bWrong = false;
530  idx = 0;
531  for (int i = 0; i < nNbPointsEC; i++)
532  {
533  if (i > 1)
534  {
535  A = TYPointParcours::vecteur2D(*TableauDePointsEC[i - 1], *TableauDePointsEC[i - 2]);
536  B = TYPointParcours::vecteur2D(*TableauDePointsEC[i - 1], *TableauDePointsEC[i]);
537 
538  if (TYPointParcours::Scalaire(A, B) >
539  0) // point de rebroussement dans l'enveloppe, on l'oublie pour lisser l'enveloppe
540  {
541  bWrong = true;
542  idx = i - 1;
543  break; // on s'arrete ici...
544  }
545  else if (ABS(TYPointParcours::Scalaire(A, B)) < EPSILON_13)
546  {
547  // on autorise les angles a 90i�� que lors du suivis du contour d'un obstacle
549  TableauDePointsEC[i - 2], TableauDePointsEC[i - 1], TableauDePointsEC[i]))
550  {
551  bWrong = true;
552  idx = i - 1;
553  break; // on s'arrete ici...
554  }
555  }
556  else if ((A.x == 0.0f) || (B.x == 0.0f))
557  {
558  // on autorise les segments verticaux que lors du suivis du contour d'un obstacle
560  TableauDePointsEC[i - 2], TableauDePointsEC[i - 1], TableauDePointsEC[i]))
561  {
562  bWrong = true;
563  idx = i - 1;
564  break; // on s'arrete ici...
565  }
566  }
567  }
568  }
569 
570  if (bWrong) // Si un point pose pb, on l'elimine et on recommence le calcul de l'enveloppe...
571  {
572  int k = 0;
573  for (k = 0; k < nNbPointsSelectiones; k++)
574  {
575  if (TableauDePointsEC[idx] == TableauDePointsSelectionnes[k])
576  {
577  idx = k;
578  break; // on a trouve le point, on stop ici
579  }
580  }
581  for (k = idx; k < nNbPointsSelectiones - 1; k++)
582  {
583  // On decale tout le tableau
584  TableauDePointsSelectionnes[k] = TableauDePointsSelectionnes[k + 1];
585  }
586  nNbPointsSelectiones--;
587  }
588  } while (bWrong);
589 
590  // Les points doivent etre ordonnes pour le trajet; on sait que le premier point est S, le second R
591  // Si S est a droite de R, il faudra reordonner les points pour le trajet
592  bool bAGaucheDeSR = (_geoSR->_ListePoint[0].x < _geoSR->_ListePoint[1].x);
593  geoDernierePasseGauche.CreerTrajetAPartirDuneListeDePointsTriee(TableauDePointsEC, nNbPointsEC,
594  bAGaucheDeSR, true);
595  geoTrajetGauche = &geoDernierePasseGauche;
596 
597  SAFE_DELETE_LIST(TableauDePointsEC);
598  SAFE_DELETE_LIST(TableauDePointsSelectionnes);
599  }
600 
601  return 0;
602 }
All base classes related to 3D manipulation.
#define EPSILON_13
Definition: 3d.h:41
double ABS(double a)
Return the absolute value.
Definition: 3d.h:67
int nNbAbandonsParPointNuples
TYSetGeometriqueParcours * _geoImporterDXF
TYSetGeometriqueParcours * _geoSR
std::vector< bool > _estUnPointIntersectant
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.
int _nNbSegMax
Number of segments (encountered faces)
void InitChangementVariable2D3D(bool bAxeXMoinsSignifiant)
Select the 2D plane and set _indexXInOut, _indexYInOut, _indexZInOut.
int Traite(TYSetGeometriqueParcours &geoDernierePasseGauche, TYSetGeometriqueParcours &geoDernierePasseDroite, TYSetGeometriqueParcours *&geoTrajetGauche, TYSetGeometriqueParcours *&geoTrajetDroite)
Handles the pathfinding for lateral and vertical paths.
TYSetGeometriqueParcours * _geoTrajetGauche
Paths list on the left.
~TYCalculParcours()
Destructor.
bool Traitement()
Build the left and right geometric paths.
TYCalculParcours(int nNbSegMax, bool _bVertical)
Constructor.
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.
bool _bVertical
True if horizontal view.
void AjouterSegment(double *ptA, double *ptB, bool isInfra, bool isEcran, TYSetGeometriqueParcours *geo)
creates and add vector AB into geo
TYSetGeometriqueParcours _geoDernierePasseGauche
TYSetGeometriqueParcours * _geoTrajetDroite
Paths list on the right.
TYSetGeometriqueParcours _geoDernierePasseDroite
std::vector< TYPointParcours * > _vectorPoint
void PointTrajet(int i, double *pt, TYSetGeometriqueParcours *geo)
copy coordinates from the point of index i from the object geo into pt
bool CalculTrajet(TYSetGeometriqueParcours &geoCourant, bool bCoteGauche, bool *PointsAGauche, bool *PointsADroite, TYSetGeometriqueParcours &geoPremierePasse, TYSetGeometriqueParcours *&geoTrajet)
select the points that could be included in the path
void ajouteSegment(TYPointParcours *p1, TYPointParcours *p2)
Add a first polyline with two points p1 and p2.
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.
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.
void RamenerPointsTraversantLaFrontiere(TYPointParcours &Srce, TYPointParcours &Dest, int *IndexePointsFrontiere, int &NbPointsFrontiere, std::vector< bool > &pEstUnPointIntersectant, bool bCoteGauche, bool *PointsAGauche, bool *PointsADroite)
To be commented.
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.
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...
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,...
int _nNbPolylines
Polylines number.
TYPointParcours * _ListePoint
List of points on the path.
void Copy(TYSetGeometriqueParcours &geoIn)
Copy operator.
int _nNbPointTotal
Total number of points.
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.
bool AppartienneMemePolyligne(TYPointParcours *a, TYPointParcours *b, TYPointParcours *c)
Check if the points a, b, c belong to the same polyline.
#define INDENTIFIANT_SOURCE
#define MAX_POINTS
#define INDENTIFIANT_RECEPTEUR
#define SAFE_DELETE_LIST(_p)
Definition: macros.h:239
#define SAFE_DELETE(_p)
Definition: macros.h:225
Connectivity between points and segments.
Point of a path.
double z
z coordinate of the point
bool isInfra
Flag set to indicate if the point is an infrastructure.
int Identifiant
Point id.
static bool Confondus(TYPointParcours *P1, TYPointParcours *P2)
double y
y coordinate of the point
static double Scalaire(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4)
Compute the scalar product of the vector P1P2 and P3P4.
double x
x coordinate of the point
bool isEcran
Flag set to indicate if the point is a screen.
static TYPointParcours vecteur2D(TYPointParcours &P1, TYPointParcours &P2)
Compute the 2 dimensional vector P1P2 in the XY plane.