46 assert(indexPointPoly1 >= 0);
47 assert(indexPointPoly2 >= 0);
49 if (indexPointPoly1 == indexPointPoly2)
54 return (indexPointPoly1 - indexPointPoly2);
100 int indexPoint1 = 0, indexPoint2 = 0, i = 0, j = 0;
106 assert(indexPoint1 >= 0);
107 assert(indexPoint2 >= 0);
108 if (indexPoint1 > indexPoint2)
128 while (j < nOldNbPolylines && indexPoint1 ==
_ListePolylines[j].indexePoint1() &&
136 if (i != j && j < nOldNbPolylines)
148 if (indexPoint1 == indexPoint2)
165 int i = 0, j = 0, index = 0, doublons = 0;
202 std::vector<bool>& pEstUnPointIntersectant,
bool bCoteGauche,
bool* PointsAGauche,
bool* PointsADroite)
204 int i = 0, indexePoint = 0, indexePoint1 = 0, indexePoint2 = 0;
207 NbPointsFrontiere = 0;
208 pEstUnPointIntersectant.clear();
211 pEstUnPointIntersectant.push_back(
false);
222 if (PointsAGauche[indexePoint1] == PointsADroite[indexePoint1])
225 pEstUnPointIntersectant[indexePoint1] =
true;
226 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint1;
230 if (PointsAGauche[indexePoint2] == PointsADroite[indexePoint2])
233 pEstUnPointIntersectant[indexePoint2] =
true;
234 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint2;
239 bool b2PointsAGauche = PointsAGauche[indexePoint1] && PointsAGauche[indexePoint2];
240 bool b2PointsADroite = PointsADroite[indexePoint1] && PointsADroite[indexePoint2];
241 if (b2PointsAGauche || b2PointsADroite)
245 int nIndexePointFrontiereDansSegment = 0;
248 nIndexePointFrontiereDansSegment = PointsADroite[indexePoint1] ? 0 : 1;
252 nIndexePointFrontiereDansSegment = PointsAGauche[indexePoint1] ? 0 : 1;
264 indexePoint = nAncienNbPointTotal;
265 nAncienNbPointTotal++;
268 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint;
269 pEstUnPointIntersectant[indexePoint] =
true;
278 bool*& PointsAGauche,
bool*& PointsADroite)
304 PointsAGauche[i] =
false;
305 PointsADroite[i] =
false;
314 int i = 0, j = 0, indexePoint = 0;
320 bAuMoinsUnPointAGauche[i] =
false;
321 bAuMoinsUnPointADroite[i] =
false;
324 (!bAuMoinsUnPointADroite[i] || !bAuMoinsUnPointAGauche[i]);
330 bAuMoinsUnPointAGauche[i] = bAuMoinsUnPointAGauche[i] || PointsAGauche[indexePoint];
331 bAuMoinsUnPointADroite[i] = bAuMoinsUnPointADroite[i] || PointsADroite[indexePoint];
366 if (bAuMoinsUnPointAGauche[i])
381 if (bAuMoinsUnPointADroite[i])
426 int e1 = *((
int*)(p1));
427 int e2 = *((
int*)(p2));
434 if (dAbscisseCurviligneCP1 < dAbscisseCurviligneCP2)
438 if (dAbscisseCurviligneCP1 > dAbscisseCurviligneCP2)
446 int* IndexePointsFrontiere,
447 int NbPointsFrontiere)
453 if (NbPointsFrontiere == 0)
500 std::vector<bool>& pEstUnPointIntersectant,
503 int IndexPoint = IndexPointRacine;
504 int IndexPointSuivant = 0;
512 PolyligneRacine = PolyligneCourante;
513 IndexPointSuivant = PolyligneCourante->
indexePointSuivant(IndexPoint, PolyligneSuivante);
516 IndexPoint = IndexPointSuivant;
517 }
while (NULL != PolyligneSuivante && !pEstUnPointIntersectant[IndexPoint] &&
518 (PolyligneCourante = PolyligneSuivante));
540 std::vector<bool>& pEstUnPointIntersectant)
562 if (NbSegmentsConnexes >= 2)
580 Connexes = newConnexes;
594 NbSegmentsConnexes = 0;
597 pEstUnPointIntersectant.push_back(pEstUnPointIntersectant[indexePoint]);
602 assert(NbSegmentsConnexes < 2);
622 for (j = 0; j < 2; j++)
624 assert((*pPolylignesVoisines[j]) == NULL);
629 if (indexeSegmentj != i && indexeSegmentj != -1)
639 if (indexeSegmentj != i && indexeSegmentj != -1)
646 *(pPolylignesVoisines[j]) = NULL;
649 NbSegmentsConnexes--;
652 bool bP0P1PointentSurMemePolyligne =
666 int* IndexePointsFrontiere,
int NbPointsFrontiere,
667 std::vector<bool>& pEstUnPointIntersectant,
Connexite* Connexes,
679 while (i < NbPointsFrontiere &&
684 int PremierPointIntersection = i;
685 while (i < NbPointsFrontiere &&
690 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())
762 int& nbPtsEC,
int compteurIter,
bool bIsLastSecondePasse)
767 if (!bIsLastSecondePasse && compteurIter > 2)
777 if (nNbPointsPremierePasse == 0)
783 for (i = 0; i < nNbPointsPremierePasse; i++)
785 TableauDePointsPremierePasse[i] = &(geoPremierePasse.
_ListePoint[i]);
792 TYPointParcours* pRecepteur = TableauDePointsPremierePasse[nNbPointsPremierePasse - 1];
793 TableauDePointsPremierePasse[nNbPointsPremierePasse - 1] = TableauDePointsPremierePasse[1];
794 TableauDePointsPremierePasse[1] = pRecepteur;
799 bool bSaGaucheDeR = TableauDePointsPremierePasse[indexS]->
x < TableauDePointsPremierePasse[indexR]->
x;
801 bool premierPtsLesPlusHauts = bTrajetsAGaucheDeSR != bSaGaucheDeR;
804 TableauDePointsPremierePasse, nNbPointsPremierePasse, TableauDePointsEC, premierPtsLesPlusHauts);
809 int nNbPointAlloue = nNbPointsEC * nNbPointsPremierePasse * 4;
810 geoSecondePasse.
Clean();
818 bool bOrdonneDeSversR =
820 if (!bOrdonneDeSversR)
825 int nVerifNbPointsAjoutes = 1;
826 int nbPts = nNbPointsEC;
827 for (i = 1; i < nbPts; i++)
829 if (!bIsLastSecondePasse && (compteurIter < 2) &&
830 this->
intersects(*TableauDePointsEC[i - 1], *TableauDePointsEC[i]))
837 int NbPointsFrontiere = 0;
838 bool* PointsAGauche =
nullptr;
839 bool* PointsADroite =
nullptr;
851 std::vector<bool> estUnPointIntersectant;
853 if (bTrajetsAGaucheDeSR)
856 IndexePointsFrontiere, NbPointsFrontiere,
857 estUnPointIntersectant, bTrajetsAGaucheDeSR,
858 PointsAGauche, PointsADroite);
864 nVerifNbPointsAjoutes++;
870 *TableauDePointsEC[i - 1], *TableauDePointsEC[i], IndexePointsFrontiere,
871 NbPointsFrontiere, estUnPointIntersectant, Connexes, nouvellePremierePasse, compteurIter);
875 nVerifNbPointsAjoutes++;
880 bool bSecondePasseOk =
881 geoGauche.
SecondePasse(nouvellePremierePasse, nouvelleSecondePasse, bTrajetsAGaucheDeSR,
882 pTableauECG, nbPtsECG, compteurIter);
883 if (!bSecondePasseOk)
886 nVerifNbPointsAjoutes++;
892 int nNbPointNouvelleSecondePasse = nouvelleSecondePasse.
_nNbPointTotal;
894 if (nVerifNbPointsAjoutes + nNbPointNouvelleSecondePasse >
897 int nouvelleTaille = nVerifNbPointsAjoutes + (nbPts - i) * nNbPointNouvelleSecondePasse;
904 nVerifNbPointsAjoutes++;
912 IndexePointsFrontiere, NbPointsFrontiere,
913 estUnPointIntersectant, bTrajetsAGaucheDeSR,
914 PointsAGauche, PointsADroite);
920 nVerifNbPointsAjoutes++;
926 *TableauDePointsEC[i - 1], *TableauDePointsEC[i], IndexePointsFrontiere,
927 NbPointsFrontiere, estUnPointIntersectant, Connexes, nouvellePremierePasse, compteurIter);
931 nVerifNbPointsAjoutes++;
936 bool bSecondePasseOk =
937 geoDroite.
SecondePasse(nouvellePremierePasse, nouvelleSecondePasse, bTrajetsAGaucheDeSR,
938 pTableauECD, nbPtsECD, compteurIter);
939 if (!bSecondePasseOk)
942 nVerifNbPointsAjoutes++;
948 int nNbPointNouvelleSecondePasse = nouvelleSecondePasse.
_nNbPointTotal;
950 if (nVerifNbPointsAjoutes + nNbPointNouvelleSecondePasse >
953 int nouvelleTaille = nVerifNbPointsAjoutes + (nbPts - i) * nNbPointNouvelleSecondePasse;
960 nVerifNbPointsAjoutes++;
970 nVerifNbPointsAjoutes++;
974 pTableauEC = TableauDePointsEC;
975 nbPtsEC = nNbPointsEC;
982 int nNbPointsDeLaListe)
984 for (
int i = 0; i < nNbPointsDeLaListe / 2; i++)
986 TYPointParcours* pTmp = ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i];
987 ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i] = ListeDePointsAInverser[i];
988 ListeDePointsAInverser[i] = pTmp;
993 int nIndexePoly,
int nIndexeNbPremierPointAAjouter,
994 int nIndexeDernierPointAAjouter)
996 int nNbPointsAjoutes = 0;
1002 PolyligneSource->
indexePoint(i) != nIndexeNbPremierPointAAjouter;
1012 if (PolyligneSource->
indexePoint(i) == nIndexeDernierPointAAjouter)
1017 return nNbPointsAjoutes;
1033 bool bMemePoint1 = (indexPoint1 == indexPoint1In) || (indexPoint1 == indexPoint2In);
1034 bool bMemePoint2 = (indexPoint2 == indexPoint2In) || (indexPoint2 == indexPoint1In);
1035 bool bMemePoints = bMemePoint1 || bMemePoint2;
1094 return (determinant < 0);
1100 return (determinant > 0);
1106 bool bPremiersPointsLesPlusHauts)
1112 int nNbPointsEC = 0;
1116 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
1117 int indexS = bSaGaucheDeR ? 0 : 1;
1118 int indexR = bSaGaucheDeR ? 1 : 0;
1125 TableauDePointsECOut[nNbPointsEC] = TableauDePoints[indexS];
1136 int indexePointDuBonCote = -1;
1143 indexePointDuBonCote = -1;
1144 for (i = 2; i < nNbPoints; i++)
1146 P2 = (*TableauDePoints[i]);
1151 double determinant = NAN;
1152 bool bDuBonCote = (*pDuBonCote)(PP1, PP2, determinant);
1158 bool bBonCandidatPourRemplacement =
false;
1165 bBonCandidatPourRemplacement =
false;
1169 bBonCandidatPourRemplacement = PP2.normeCarree() > PP1.normeCarree();
1174 bBonCandidatPourRemplacement = bDuBonCote;
1176 if (bBonCandidatPourRemplacement)
1180 indexePointDuBonCote = i;
1187 if (indexePointDuBonCote >= 0)
1190 pNouveauPointEC = TableauDePoints[indexePointDuBonCote];
1198 pNouveauPointEC = TableauDePoints[indexR];
1201 TableauDePointsECOut[nNbPointsEC] = pNouveauPointEC;
1203 }
while (nNbPointsEC < nNbPoints && indexePointDuBonCote >= 0);
1212 if (NULL == TableauDePoints || 0 == nNbPoints)
1216 int nNbPointsSelectiones = 2;
1226 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
1230 G = *TableauDePoints[0];
1231 D = *TableauDePoints[1];
1235 G = *TableauDePoints[1];
1236 D = *TableauDePoints[0];
1247 bool noIntersection =
true;
1251 for (
int j = 0; (j < nbPts - 1) && (noIntersection); j++)
1258 noIntersection =
false;
1266 return nNbPointsSelectiones;
1277 bool bEntreSetR =
false;
1280 for (i = 0; i < nNbPoints; i++)
1284 while (i != 0 && i < nNbPoints &&
_ListePoint[i].Identifiant <= nIdentifiantRacine)
1300 TableauDePoints[nNbPointsSelectiones] = &(
_ListePoint[i]);
1301 nNbPointsSelectiones++;
1305 return nNbPointsSelectiones;
1309 int nNbPoints,
bool bSens,
1310 bool bGardeIdentifiant)
1312 if (NULL == TableauDePoints || 0 == nNbPoints)
1334 for (i = 0; i < nNbPoints; i++)
1339 if (!bGardeIdentifiant)
1341 for (i = 0; i < nNbPoints; i++)
1349 for (i = 0; i < nNbPoints; i++)
1351 _ListePoint[i] = *TableauDePoints[nNbPoints - i - 1];
1354 if (!bGardeIdentifiant)
1356 for (i = 0; i < nNbPoints; i++)
1371 double norme1 = NAN;
1372 double norme2 = NAN;
1373 double cosVal1 = NAN;
1374 double cosVal2 = NAN;
1376 bool t1 =
false, t2 =
false;
1383 for (
int j = 0; j < nbPts; j++)
1398 cosVal1 = v1.
scalar(v3) / norme1;
1408 cosVal2 = v2.
scalar(v3) / norme2;
1420 cosVal2 = v2.
scalar(v4) / norme2;
1430 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
double _y
y coordinate of OCoord3D
double _x
x coordinate of OCoord3D
double norme() const
Computes the length of this vector.
double scalar(const OVector3D &vector) const
Performs the scalar product between this object and another vector.
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.
bool extendPtrPoints(int nNouvelleTaille)
Extends the attribute array _PtrPoints.
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.
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.
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.
bool coincideWith(TYSetGeometriqueParcours &otherGeoPasse)
Tests if the first polyline of this geo parcours coincide with the geo passe in argument,...
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.
bool extendListePoint(int nNouvelleTaille)
Extends the attribute array _ListePoint.
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.