44 assert(indexPointPoly1 >= 0);
45 assert(indexPointPoly2 >= 0);
47 if (indexPointPoly1 == indexPointPoly2)
52 return (indexPointPoly1 - indexPointPoly2);
98 int indexPoint1 = 0, indexPoint2 = 0, i = 0, j = 0;
104 assert(indexPoint1 >= 0);
105 assert(indexPoint2 >= 0);
106 if (indexPoint1 > indexPoint2)
126 while (j < nOldNbPolylines && indexPoint1 ==
_ListePolylines[j].indexePoint1() &&
134 if (i != j && j < nOldNbPolylines)
146 if (indexPoint1 == indexPoint2)
163 int i = 0, j = 0, index = 0, doublons = 0;
200 std::vector<bool>& pEstUnPointIntersectant,
bool bCoteGauche,
bool* PointsAGauche,
bool* PointsADroite)
202 int i = 0, indexePoint = 0, indexePoint1 = 0, indexePoint2 = 0;
205 NbPointsFrontiere = 0;
206 pEstUnPointIntersectant.clear();
209 pEstUnPointIntersectant.push_back(
false);
220 if (PointsAGauche[indexePoint1] == PointsADroite[indexePoint1])
223 pEstUnPointIntersectant[indexePoint1] =
true;
224 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint1;
228 if (PointsAGauche[indexePoint2] == PointsADroite[indexePoint2])
231 pEstUnPointIntersectant[indexePoint2] =
true;
232 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint2;
237 bool b2PointsAGauche = PointsAGauche[indexePoint1] && PointsAGauche[indexePoint2];
238 bool b2PointsADroite = PointsADroite[indexePoint1] && PointsADroite[indexePoint2];
239 if (b2PointsAGauche || b2PointsADroite)
243 int nIndexePointFrontiereDansSegment = 0;
246 nIndexePointFrontiereDansSegment = PointsADroite[indexePoint1] ? 0 : 1;
250 nIndexePointFrontiereDansSegment = PointsAGauche[indexePoint1] ? 0 : 1;
262 indexePoint = nAncienNbPointTotal;
263 nAncienNbPointTotal++;
266 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint;
267 pEstUnPointIntersectant[indexePoint] =
true;
276 bool*& PointsAGauche,
bool*& PointsADroite)
302 PointsAGauche[i] =
false;
303 PointsADroite[i] =
false;
312 int i = 0, j = 0, indexePoint = 0;
318 bAuMoinsUnPointAGauche[i] =
false;
319 bAuMoinsUnPointADroite[i] =
false;
322 (!bAuMoinsUnPointADroite[i] || !bAuMoinsUnPointAGauche[i]);
328 bAuMoinsUnPointAGauche[i] = bAuMoinsUnPointAGauche[i] || PointsAGauche[indexePoint];
329 bAuMoinsUnPointADroite[i] = bAuMoinsUnPointADroite[i] || PointsADroite[indexePoint];
364 if (bAuMoinsUnPointAGauche[i])
379 if (bAuMoinsUnPointADroite[i])
424 int e1 = *((
int*)(p1));
425 int e2 = *((
int*)(p2));
432 if (dAbscisseCurviligneCP1 < dAbscisseCurviligneCP2)
436 if (dAbscisseCurviligneCP1 > dAbscisseCurviligneCP2)
444 int* IndexePointsFrontiere,
445 int NbPointsFrontiere)
451 if (NbPointsFrontiere == 0)
498 std::vector<bool>& pEstUnPointIntersectant,
501 int IndexPoint = IndexPointRacine;
502 int IndexPointSuivant = 0;
510 PolyligneRacine = PolyligneCourante;
511 IndexPointSuivant = PolyligneCourante->
indexePointSuivant(IndexPoint, PolyligneSuivante);
514 IndexPoint = IndexPointSuivant;
515 }
while (NULL != PolyligneSuivante && !pEstUnPointIntersectant[IndexPoint] &&
516 (PolyligneCourante = PolyligneSuivante));
538 std::vector<bool>& pEstUnPointIntersectant)
560 if (NbSegmentsConnexes >= 2)
578 Connexes = newConnexes;
592 NbSegmentsConnexes = 0;
595 pEstUnPointIntersectant.push_back(pEstUnPointIntersectant[indexePoint]);
600 assert(NbSegmentsConnexes < 2);
620 for (j = 0; j < 2; j++)
622 assert((*pPolylignesVoisines[j]) == NULL);
627 if (indexeSegmentj != i && indexeSegmentj != -1)
637 if (indexeSegmentj != i && indexeSegmentj != -1)
644 *(pPolylignesVoisines[j]) = NULL;
647 NbSegmentsConnexes--;
650 bool bP0P1PointentSurMemePolyligne =
664 int* IndexePointsFrontiere,
int NbPointsFrontiere,
665 std::vector<bool>& pEstUnPointIntersectant,
Connexite* Connexes,
677 while (i < NbPointsFrontiere &&
682 int PremierPointIntersection = i;
683 while (i < NbPointsFrontiere &&
688 int DernierPointIntersection = i;
702 for (i = PremierPointIntersection; i < DernierPointIntersection; i++)
705 int IndexPoint = IndexePointsFrontiere[i];
716 if (pEstUnPointIntersectant[IndexPoint])
733 while (i < NbPointsFrontiere && IndexPoint != IndexePointsFrontiere[i])
741 if (!PolyligneCourante->
isEcran())
760 int& nbPtsEC,
int compteurIter,
bool bIsLastSecondePasse)
765 if (!bIsLastSecondePasse && compteurIter > 2)
775 if (nNbPointsPremierePasse == 0)
781 for (i = 0; i < nNbPointsPremierePasse; i++)
783 TableauDePointsPremierePasse[i] = &(geoPremierePasse.
_ListePoint[i]);
790 TYPointParcours* pRecepteur = TableauDePointsPremierePasse[nNbPointsPremierePasse - 1];
791 TableauDePointsPremierePasse[nNbPointsPremierePasse - 1] = TableauDePointsPremierePasse[1];
792 TableauDePointsPremierePasse[1] = pRecepteur;
797 bool bSaGaucheDeR = TableauDePointsPremierePasse[indexS]->
x < TableauDePointsPremierePasse[indexR]->
x;
799 bool premierPtsLesPlusHauts = bTrajetsAGaucheDeSR != bSaGaucheDeR;
802 TableauDePointsPremierePasse, nNbPointsPremierePasse, TableauDePointsEC, premierPtsLesPlusHauts);
807 int nNbPointAlloue = nNbPointsEC * nNbPointsPremierePasse * 4;
808 geoSecondePasse.
Clean();
816 bool bOrdonneDeSversR =
818 if (!bOrdonneDeSversR)
823 int nVerifNbPointsAjoutes = 1;
824 int nbPts = nNbPointsEC;
825 for (i = 1; i < nbPts; i++)
827 if (!bIsLastSecondePasse && (compteurIter < 2) &&
828 this->
intersects(*TableauDePointsEC[i - 1], *TableauDePointsEC[i]))
835 int NbPointsFrontiere = 0;
836 bool* PointsAGauche =
nullptr;
837 bool* PointsADroite =
nullptr;
849 std::vector<bool> estUnPointIntersectant;
851 if (bTrajetsAGaucheDeSR)
854 IndexePointsFrontiere, NbPointsFrontiere,
855 estUnPointIntersectant, bTrajetsAGaucheDeSR,
856 PointsAGauche, PointsADroite);
862 nVerifNbPointsAjoutes++;
868 *TableauDePointsEC[i - 1], *TableauDePointsEC[i], IndexePointsFrontiere,
869 NbPointsFrontiere, estUnPointIntersectant, Connexes, nouvellePremierePasse, compteurIter);
873 nVerifNbPointsAjoutes++;
878 bool bSecondePasseOk =
879 geoGauche.
SecondePasse(nouvellePremierePasse, nouvelleSecondePasse, bTrajetsAGaucheDeSR,
880 pTableauECG, nbPtsECG, compteurIter);
881 if (!bSecondePasseOk)
884 nVerifNbPointsAjoutes++;
890 int nNbPointNouvelleSecondePasse = nouvelleSecondePasse.
_nNbPointTotal;
892 if (nVerifNbPointsAjoutes + nNbPointNouvelleSecondePasse >
895 int nouvelleTaille = nVerifNbPointsAjoutes + (nbPts - i) * nNbPointNouvelleSecondePasse;
902 nVerifNbPointsAjoutes++;
910 IndexePointsFrontiere, NbPointsFrontiere,
911 estUnPointIntersectant, bTrajetsAGaucheDeSR,
912 PointsAGauche, PointsADroite);
918 nVerifNbPointsAjoutes++;
924 *TableauDePointsEC[i - 1], *TableauDePointsEC[i], IndexePointsFrontiere,
925 NbPointsFrontiere, estUnPointIntersectant, Connexes, nouvellePremierePasse, compteurIter);
929 nVerifNbPointsAjoutes++;
934 bool bSecondePasseOk =
935 geoDroite.
SecondePasse(nouvellePremierePasse, nouvelleSecondePasse, bTrajetsAGaucheDeSR,
936 pTableauECD, nbPtsECD, compteurIter);
937 if (!bSecondePasseOk)
940 nVerifNbPointsAjoutes++;
946 int nNbPointNouvelleSecondePasse = nouvelleSecondePasse.
_nNbPointTotal;
948 if (nVerifNbPointsAjoutes + nNbPointNouvelleSecondePasse >
951 int nouvelleTaille = nVerifNbPointsAjoutes + (nbPts - i) * nNbPointNouvelleSecondePasse;
958 nVerifNbPointsAjoutes++;
968 nVerifNbPointsAjoutes++;
972 pTableauEC = TableauDePointsEC;
973 nbPtsEC = nNbPointsEC;
980 int nNbPointsDeLaListe)
982 for (
int i = 0; i < nNbPointsDeLaListe / 2; i++)
984 TYPointParcours* pTmp = ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i];
985 ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i] = ListeDePointsAInverser[i];
986 ListeDePointsAInverser[i] = pTmp;
991 int nIndexePoly,
int nIndexeNbPremierPointAAjouter,
992 int nIndexeDernierPointAAjouter)
994 int nNbPointsAjoutes = 0;
1000 PolyligneSource->
indexePoint(i) != nIndexeNbPremierPointAAjouter;
1010 if (PolyligneSource->
indexePoint(i) == nIndexeDernierPointAAjouter)
1015 return nNbPointsAjoutes;
1031 bool bMemePoint1 = (indexPoint1 == indexPoint1In) || (indexPoint1 == indexPoint2In);
1032 bool bMemePoint2 = (indexPoint2 == indexPoint2In) || (indexPoint2 == indexPoint1In);
1033 bool bMemePoints = bMemePoint1 || bMemePoint2;
1092 return (determinant < 0);
1098 return (determinant > 0);
1104 bool bPremiersPointsLesPlusHauts)
1110 int nNbPointsEC = 0;
1114 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
1115 int indexS = bSaGaucheDeR ? 0 : 1;
1116 int indexR = bSaGaucheDeR ? 1 : 0;
1123 TableauDePointsECOut[nNbPointsEC] = TableauDePoints[indexS];
1134 int indexePointDuBonCote = -1;
1141 indexePointDuBonCote = -1;
1142 for (i = 2; i < nNbPoints; i++)
1144 P2 = (*TableauDePoints[i]);
1149 double determinant = NAN;
1150 bool bDuBonCote = (*pDuBonCote)(PP1, PP2, determinant);
1156 bool bBonCandidatPourRemplacement =
false;
1163 bBonCandidatPourRemplacement =
false;
1167 bBonCandidatPourRemplacement = PP2.normeCarree() > PP1.normeCarree();
1172 bBonCandidatPourRemplacement = bDuBonCote;
1174 if (bBonCandidatPourRemplacement)
1178 indexePointDuBonCote = i;
1185 if (indexePointDuBonCote >= 0)
1188 pNouveauPointEC = TableauDePoints[indexePointDuBonCote];
1196 pNouveauPointEC = TableauDePoints[indexR];
1199 TableauDePointsECOut[nNbPointsEC] = pNouveauPointEC;
1201 }
while (nNbPointsEC < nNbPoints && indexePointDuBonCote >= 0);
1210 if (NULL == TableauDePoints || 0 == nNbPoints)
1214 int nNbPointsSelectiones = 2;
1224 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
1228 G = *TableauDePoints[0];
1229 D = *TableauDePoints[1];
1233 G = *TableauDePoints[1];
1234 D = *TableauDePoints[0];
1245 bool noIntersection =
true;
1249 for (
int j = 0; (j < nbPts - 1) && (noIntersection); j++)
1256 noIntersection =
false;
1264 return nNbPointsSelectiones;
1275 bool bEntreSetR =
false;
1278 for (i = 0; i < nNbPoints; i++)
1282 while (i != 0 && i < nNbPoints &&
_ListePoint[i].Identifiant <= nIdentifiantRacine)
1298 TableauDePoints[nNbPointsSelectiones] = &(
_ListePoint[i]);
1299 nNbPointsSelectiones++;
1303 return nNbPointsSelectiones;
1307 int nNbPoints,
bool bSens,
1308 bool bGardeIdentifiant)
1310 if (NULL == TableauDePoints || 0 == nNbPoints)
1332 for (i = 0; i < nNbPoints; i++)
1337 if (!bGardeIdentifiant)
1339 for (i = 0; i < nNbPoints; i++)
1347 for (i = 0; i < nNbPoints; i++)
1349 _ListePoint[i] = *TableauDePoints[nNbPoints - i - 1];
1352 if (!bGardeIdentifiant)
1354 for (i = 0; i < nNbPoints; i++)
1369 double norme1 = NAN;
1370 double norme2 = NAN;
1371 double cosVal1 = NAN;
1372 double cosVal2 = NAN;
1374 bool t1 =
false, t2 =
false;
1381 for (
int j = 0; j < nbPts; j++)
1396 cosVal1 = v1.
scalar(v3) / norme1;
1406 cosVal2 = v2.
scalar(v3) / norme2;
1418 cosVal2 = v2.
scalar(v4) / norme2;
1428 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
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)
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.
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.
#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.