46 assert(indexPointPoly1 >= 0);
47 assert(indexPointPoly2 >= 0);
49 if (indexPointPoly1 == indexPointPoly2)
54 return (indexPointPoly1 - indexPointPoly2);
102 int indexPoint1 = 0, indexPoint2 = 0, i = 0, j = 0;
108 assert(indexPoint1 >= 0);
109 assert(indexPoint2 >= 0);
110 if (indexPoint1 > indexPoint2)
130 while (j < nOldNbPolylines && indexPoint1 ==
_ListePolylines[j].indexePoint1() &&
138 if (i != j && j < nOldNbPolylines)
150 if (indexPoint1 == indexPoint2)
167 int i = 0, j = 0, index = 0, doublons = 0;
204 std::vector<bool>& pEstUnPointIntersectant,
bool bCoteGauche,
bool* PointsAGauche,
bool* PointsADroite)
206 int i = 0, indexePoint = 0, indexePoint1 = 0, indexePoint2 = 0;
209 NbPointsFrontiere = 0;
210 pEstUnPointIntersectant.clear();
213 pEstUnPointIntersectant.push_back(
false);
224 if (PointsAGauche[indexePoint1] == PointsADroite[indexePoint1])
227 pEstUnPointIntersectant[indexePoint1] =
true;
228 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint1;
232 if (PointsAGauche[indexePoint2] == PointsADroite[indexePoint2])
235 pEstUnPointIntersectant[indexePoint2] =
true;
236 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint2;
241 bool b2PointsAGauche = PointsAGauche[indexePoint1] && PointsAGauche[indexePoint2];
242 bool b2PointsADroite = PointsADroite[indexePoint1] && PointsADroite[indexePoint2];
243 if (b2PointsAGauche || b2PointsADroite)
247 int nIndexePointFrontiereDansSegment = 0;
250 nIndexePointFrontiereDansSegment = PointsADroite[indexePoint1] ? 0 : 1;
254 nIndexePointFrontiereDansSegment = PointsAGauche[indexePoint1] ? 0 : 1;
266 indexePoint = nAncienNbPointTotal;
267 nAncienNbPointTotal++;
270 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint;
271 pEstUnPointIntersectant[indexePoint] =
true;
280 bool*& PointsAGauche,
bool*& PointsADroite)
306 PointsAGauche[i] =
false;
307 PointsADroite[i] =
false;
316 int i = 0, j = 0, indexePoint = 0;
322 bAuMoinsUnPointAGauche[i] =
false;
323 bAuMoinsUnPointADroite[i] =
false;
326 (!bAuMoinsUnPointADroite[i] || !bAuMoinsUnPointAGauche[i]);
332 bAuMoinsUnPointAGauche[i] = bAuMoinsUnPointAGauche[i] || PointsAGauche[indexePoint];
333 bAuMoinsUnPointADroite[i] = bAuMoinsUnPointADroite[i] || PointsADroite[indexePoint];
368 if (bAuMoinsUnPointAGauche[i])
383 if (bAuMoinsUnPointADroite[i])
428 int e1 = *((
int*)(p1));
429 int e2 = *((
int*)(p2));
436 if (dAbscisseCurviligneCP1 < dAbscisseCurviligneCP2)
440 if (dAbscisseCurviligneCP1 > dAbscisseCurviligneCP2)
448 int* IndexePointsFrontiere,
449 int NbPointsFrontiere)
455 if (NbPointsFrontiere == 0)
502 std::vector<bool>& pEstUnPointIntersectant,
505 int IndexPoint = IndexPointRacine;
506 int IndexPointSuivant = 0;
514 PolyligneRacine = PolyligneCourante;
515 IndexPointSuivant = PolyligneCourante->
indexePointSuivant(IndexPoint, PolyligneSuivante);
518 IndexPoint = IndexPointSuivant;
519 }
while (NULL != PolyligneSuivante && !pEstUnPointIntersectant[IndexPoint] &&
520 (PolyligneCourante = PolyligneSuivante));
542 std::vector<bool>& pEstUnPointIntersectant)
564 if (NbSegmentsConnexes >= 2)
582 Connexes = newConnexes;
596 NbSegmentsConnexes = 0;
599 pEstUnPointIntersectant.push_back(pEstUnPointIntersectant[indexePoint]);
604 assert(NbSegmentsConnexes < 2);
624 for (j = 0; j < 2; j++)
626 assert((*pPolylignesVoisines[j]) == NULL);
631 if (indexeSegmentj != i && indexeSegmentj != -1)
641 if (indexeSegmentj != i && indexeSegmentj != -1)
648 *(pPolylignesVoisines[j]) = NULL;
651 NbSegmentsConnexes--;
654 bool bP0P1PointentSurMemePolyligne =
668 int* IndexePointsFrontiere,
int NbPointsFrontiere,
669 std::vector<bool>& pEstUnPointIntersectant,
Connexite* Connexes,
681 while (i < NbPointsFrontiere &&
686 int PremierPointIntersection = i;
687 while (i < NbPointsFrontiere &&
692 int DernierPointIntersection = i;
704 for (i = PremierPointIntersection; i < DernierPointIntersection; i++)
707 int IndexPoint = IndexePointsFrontiere[i];
718 if (pEstUnPointIntersectant[IndexPoint])
735 while (i < NbPointsFrontiere && IndexPoint != IndexePointsFrontiere[i])
743 if (!PolyligneCourante->
isEcran())
769 if (nNbPointsPremierePasse == 0)
775 for (i = 0; i < nNbPointsPremierePasse; i++)
777 TableauDePointsPremierePasse[i] = &(geoPremierePasse.
_ListePoint[i]);
784 TYPointParcours* pRecepteur = TableauDePointsPremierePasse[nNbPointsPremierePasse - 1];
785 TableauDePointsPremierePasse[nNbPointsPremierePasse - 1] = TableauDePointsPremierePasse[1];
786 TableauDePointsPremierePasse[1] = pRecepteur;
791 bool bSaGaucheDeR = TableauDePointsPremierePasse[indexS]->
x < TableauDePointsPremierePasse[indexR]->
x;
793 if (bTrajetsAGaucheDeSR)
798 TableauDePointsPremierePasse, nNbPointsPremierePasse, TableauDePointsEC,
false);
803 TableauDePointsPremierePasse, nNbPointsPremierePasse, TableauDePointsEC,
true);
811 TableauDePointsPremierePasse, nNbPointsPremierePasse, TableauDePointsEC,
true);
816 TableauDePointsPremierePasse, nNbPointsPremierePasse, TableauDePointsEC,
false);
823 int nNbPointAlloue = nNbPointsEC * nNbPointsPremierePasse;
831 bool bOrdonneDeSversR =
833 if (!bOrdonneDeSversR)
838 int nVerifNbPointsAjoutes = 1;
839 for (i = 1; i < nNbPointsEC; i++)
841 if (this->
intersects(*TableauDePointsEC[i - 1], *TableauDePointsEC[i]))
848 geoPremierePasse, 0, TableauDePointsEC[i - 1]->Identifiant,
849 TableauDePointsEC[i]->Identifiant);
854 nVerifNbPointsAjoutes++;
858 pTableauEC = TableauDePointsEC;
859 nbPtsEC = nNbPointsEC;
866 int nNbPointsDeLaListe)
868 for (
int i = 0; i < nNbPointsDeLaListe / 2; i++)
870 TYPointParcours* pTmp = ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i];
871 ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i] = ListeDePointsAInverser[i];
872 ListeDePointsAInverser[i] = pTmp;
877 int nIndexePoly,
int nIndexeNbPremierPointAAjouter,
878 int nIndexeDernierPointAAjouter)
880 int nNbPointsAjoutes = 0;
886 PolyligneSource->
indexePoint(i) != nIndexeNbPremierPointAAjouter;
896 if (PolyligneSource->
indexePoint(i) == nIndexeDernierPointAAjouter)
901 return nNbPointsAjoutes;
917 bool bMemePoint1 = (indexPoint1 == indexPoint1In) || (indexPoint1 == indexPoint2In);
918 bool bMemePoint2 = (indexPoint2 == indexPoint2In) || (indexPoint2 == indexPoint1In);
919 bool bMemePoints = bMemePoint1 || bMemePoint2;
943 return (determinant < 0);
949 return (determinant > 0);
955 bool bPremiersPointsLesPlusHauts)
965 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
966 int indexS = bSaGaucheDeR ? 0 : 1;
967 int indexR = bSaGaucheDeR ? 1 : 0;
974 TableauDePointsECOut[nNbPointsEC] = TableauDePoints[indexS];
985 int indexePointDuBonCote = -1;
992 indexePointDuBonCote = -1;
993 for (i = 2; i < nNbPoints; i++)
995 P2 = (*TableauDePoints[i]);
1000 double determinant = NAN;
1001 bool bDuBonCote = (*pDuBonCote)(PP1, PP2, determinant);
1007 bool bBonCandidatPourRemplacement =
false;
1014 bBonCandidatPourRemplacement =
false;
1018 bBonCandidatPourRemplacement = PP2.normeCarree() > PP1.normeCarree();
1023 bBonCandidatPourRemplacement = bDuBonCote;
1025 if (bBonCandidatPourRemplacement)
1029 indexePointDuBonCote = i;
1036 if (indexePointDuBonCote >= 0)
1039 pNouveauPointEC = TableauDePoints[indexePointDuBonCote];
1047 pNouveauPointEC = TableauDePoints[indexR];
1050 TableauDePointsECOut[nNbPointsEC] = pNouveauPointEC;
1052 }
while (nNbPointsEC < nNbPoints && indexePointDuBonCote >= 0);
1061 if (NULL == TableauDePoints || 0 == nNbPoints)
1065 int nNbPointsSelectiones = 2;
1075 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
1079 G = *TableauDePoints[0];
1080 D = *TableauDePoints[1];
1084 G = *TableauDePoints[1];
1085 D = *TableauDePoints[0];
1096 bool noIntersection =
true;
1100 for (
int j = 0; (j < nbPts - 1) && (noIntersection); j++)
1107 noIntersection =
false;
1115 return nNbPointsSelectiones;
1125 bool bEntreSetR =
false;
1128 for (i = 0; i < nNbPoints; i++)
1132 while (i != 0 && i < nNbPoints &&
_ListePoint[i].Identifiant <= nIdentifiantRacine)
1148 TableauDePoints[nNbPointsSelectiones] = &(
_ListePoint[i]);
1149 nNbPointsSelectiones++;
1153 return nNbPointsSelectiones;
1157 int nNbPoints,
bool bSens,
1158 bool bGardeIdentifiant)
1160 if (NULL == TableauDePoints || 0 == nNbPoints)
1182 for (i = 0; i < nNbPoints; i++)
1187 if (!bGardeIdentifiant)
1189 for (i = 0; i < nNbPoints; i++)
1197 for (i = 0; i < nNbPoints; i++)
1199 _ListePoint[i] = *TableauDePoints[nNbPoints - i - 1];
1202 if (!bGardeIdentifiant)
1204 for (i = 0; i < nNbPoints; i++)
1219 double norme1 = NAN;
1220 double norme2 = NAN;
1221 double cosVal1 = NAN;
1222 double cosVal2 = NAN;
1224 bool t1 =
false, t2 =
false;
1231 for (
int j = 0; j < nbPts; j++)
1245 norme1 = (v1.norme() * v3.norme());
1246 cosVal1 = v1.scalar(v3) / norme1;
1255 norme2 = (v2.norme() * v3.norme());
1256 cosVal2 = v2.scalar(v3) / norme2;
1267 norme2 = (v2.norme() * v4.norme());
1268 cosVal2 = v2.scalar(v4) / norme2;
1277 norme1 = (v1.norme() * v4.norme());
1278 cosVal1 = v1.scalar(v4) / norme1;
All base classes related to 3D manipulation.
double ABS(double a)
Return the absolute value.
#define SEUIL_DETERMNANT_COLINEAIRE
of two vectors
Polylines path class used by the TYSetGeometriqueParcours class.
void ajoutePoint(int indexe, TYPointParcours *p)
Add a point.
TYPointParcours point(int indexe)
Return a copy the point Pi.
TYPolyligneParcours * _PolyligneP1
Pointer to the next polyline (from P1 point)
bool allouer(int nNbPoint)
Allocate nNbPoint points to the polyline.
int indexePoint2()
Return point id of point P1.
int indexePoint1()
Return point id of point P0.
void setPoint(int indexe, TYPointParcours *p)
Change a point.
int indexePointSuivant(int IndexPoint, TYPolyligneParcours *&PolyligneSuivante)
Return the point id of the next point given by IndexPoint id.
int nombreDePoint()
Return the number of points.
TYPointParcours * pointPtr(int indexe)
Return a pointer on the point Pi.
bool isEcran()
Return true if P0 and P1 are Ecran.
TYPolyligneParcours * _PolyligneP0
Pointer to the previous polyline (from P0 point)
void Copy(TYPolyligneParcours &p)
Copy operator.
int indexePoint(int i)
Return point id of point i of the polyline.
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.
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.
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.
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...
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.
static void InverseOrdreDesPoints(TYPointParcours **ListeDePointsAInverser, int nNbPointsDeLaListe)
Invert a list of points.
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 compareTYPolyligneParcours(const void *p1, const void *p2)
bool SecondVecteurAGaucheDuPremier(TYPointParcours &V1, TYPointParcours &V2, double &determinant)
bool SecondVecteurADroiteDuPremier(TYPointParcours &V1, TYPointParcours &V2, double &determinant)
int compareAbscissesCurvilignes(const void *p1, const void *p2)
#define SAFE_DELETE_LIST(_p)
Connectivity between points and segments.
int IndexesSegment[2]
Two indexes of the segment.
int NbSegmentsConnexes
Related segments number.
double z
z coordinate of the point
bool isInfra
Flag set to indicate if the point is an infrastructure.
static bool Confondus(TYPointParcours *P1, TYPointParcours *P2)
static bool IntersectionSegments(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4, TYPointParcours &P, bool bP3OrP4MustNotCoincideWithP=false)
Return true if [P1P2] intersects [P3P4] if P1 or P2 coincide with the intersection point P,...
static double ZCross(TYPointParcours SR, TYPointParcours SP)
Return cross product applied to SR and SP points.
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 bool IntersectionDroites(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4, TYPointParcours &P)
static double AbscisseCurviligneCarreSurSR(TYPointParcours &P, TYPointParcours &S, TYPointParcours &R)
Return the square of the curvilinear abscissa of point P on [SR].
static TYPointParcours vecteur2D(TYPointParcours &P1, TYPointParcours &P2)
Compute the 2 dimensional vector P1P2 in the XY plane.