46 assert(indexPointPoly1 >= 0);
47 assert(indexPointPoly2 >= 0);
49 if (indexPointPoly1 == indexPointPoly2)
54 return (indexPointPoly1 - indexPointPoly2);
102 int indexPoint1, indexPoint2, i, j;
108 assert(indexPoint1 >= 0);
109 assert(indexPoint2 >= 0);
110 if (indexPoint1 > indexPoint2)
124 while (i < _nNbPolylines)
126 indexPoint1 = _ListePolylines[i].indexePoint1();
127 indexPoint2 = _ListePolylines[i].indexePoint2();
128 while (j < nOldNbPolylines &&
129 indexPoint1 == _ListePolylines[j].indexePoint1() &&
130 indexPoint2 == _ListePolylines[j].indexePoint2())
137 if (i != j && j < nOldNbPolylines)
139 _ListePolylines[i].Copy(_ListePolylines[j]);
147 indexPoint1 = _ListePolylines[i].indexePoint1();
148 indexPoint2 = _ListePolylines[i].indexePoint2();
149 if (indexPoint1 == indexPoint2)
151 if (i != (_nNbPolylines - 1))
153 _ListePolylines[i].Copy(_ListePolylines[_nNbPolylines - 1]);
166 int i, j, index, doublons = 0;
201 int i, indexePoint, indexeAutrePoint, indexePoint1, indexePoint2;
204 NbPointsFrontiere = 0;
207 EstUnPointIntersectant[i] =
false;
218 if (PointsAGauche[indexePoint1] == PointsADroite[indexePoint1])
221 EstUnPointIntersectant[indexePoint1] =
true;
222 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint1;
226 if (PointsAGauche[indexePoint2] == PointsADroite[indexePoint2])
229 EstUnPointIntersectant[indexePoint2] =
true;
230 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint2;
235 bool b2PointsAGauche = PointsAGauche[indexePoint1] && PointsAGauche[indexePoint2];
236 bool b2PointsADroite = PointsADroite[indexePoint1] && PointsADroite[indexePoint2];
237 if (b2PointsAGauche || b2PointsADroite)
241 int nIndexePointFrontiereDansSegment;
244 nIndexePointFrontiereDansSegment = PointsADroite[indexePoint1] ? 0 : 1;
248 nIndexePointFrontiereDansSegment = PointsAGauche[indexePoint1] ? 0 : 1;
252 indexeAutrePoint = (indexePoint == indexePoint1) ? indexePoint2 : indexePoint1;
261 indexePoint = nAncienNbPointTotal;
262 nAncienNbPointTotal++;
265 IndexePointsFrontiere[NbPointsFrontiere] = indexePoint;
266 EstUnPointIntersectant[indexePoint] =
true;
302 int i, j, indexePoint;
308 bAuMoinsUnPointAGauche[i] =
false;
309 bAuMoinsUnPointADroite[i] =
false;
314 bAuMoinsUnPointAGauche[i] = bAuMoinsUnPointAGauche[i] || PointsAGauche[indexePoint];
315 bAuMoinsUnPointADroite[i] = bAuMoinsUnPointADroite[i] || PointsADroite[indexePoint];
338 if (bAuMoinsUnPointAGauche[i])
352 if (bAuMoinsUnPointADroite[i])
381 int e1 = *((
int*)(p1));
382 int e2 = *((
int*)(p2));
389 if (dAbscisseCurviligneCP1 < dAbscisseCurviligneCP2) {
return -1; }
390 if (dAbscisseCurviligneCP1 > dAbscisseCurviligneCP2) {
return 1; }
400 if (NbPointsFrontiere == 0) {
return; }
412 TYSetGeometriqueParcours::_SrceQSort = &Srce;
413 TYSetGeometriqueParcours::_DestQSort = &Dest;
414 TYSetGeometriqueParcours::_ListePointQSort =
_ListePoint;
442 int IndexPoint = IndexPointRacine;
443 int IndexPointSuivant;
451 PolyligneRacine = PolyligneCourante;
452 IndexPointSuivant = PolyligneCourante->
indexePointSuivant(IndexPoint, PolyligneSuivante);
455 IndexPoint = IndexPointSuivant;
457 while (NULL != PolyligneSuivante && !EstUnPointIntersectant[IndexPoint] && (PolyligneCourante = PolyligneSuivante));
501 if (NbSegmentsConnexes >= 2)
517 std::copy(Connexes, Connexes + _nNbPointTotal, newConnexes);
519 Connexes = newConnexes;
533 NbSegmentsConnexes = 0;
538 assert(NbSegmentsConnexes < 2);
558 for (j = 0; j < 2; j++)
560 assert((*pPolylignesVoisines[j]) == NULL);
565 if (indexeSegmentj != i && indexeSegmentj != -1)
574 if (indexeSegmentj != i && indexeSegmentj != -1)
581 *(pPolylignesVoisines[j]) = NULL;
585 NbSegmentsConnexes--;
613 int PremierPointIntersection = i;
615 int DernierPointIntersection = i;
626 for (i = PremierPointIntersection; i < DernierPointIntersection; i++)
629 int IndexPoint = IndexePointsFrontiere[i];
639 if (EstUnPointIntersectant[IndexPoint])
656 while (i < NbPointsFrontiere && IndexPoint != IndexePointsFrontiere[i]) { i++; }
661 if (!PolyligneCourante->
isEcran())
683 if (nNbPointsPremierePasse == 0) {
return false; }
686 for (i = 0; i < nNbPointsPremierePasse; i++)
688 TableauDePointsPremierePasse[i] = &(geoPremierePasse.
_ListePoint[i]);
695 TYPointParcours* pRecepteur = TableauDePointsPremierePasse[nNbPointsPremierePasse - 1];
696 TableauDePointsPremierePasse[nNbPointsPremierePasse - 1] = TableauDePointsPremierePasse[1];
697 TableauDePointsPremierePasse[1] = pRecepteur;
702 bool bSaGaucheDeR = TableauDePointsPremierePasse[indexS]->
x < TableauDePointsPremierePasse[indexR]->
x;
704 if (bTrajetsAGaucheDeSR)
731 int nNbPointAlloue = nNbPointsEC * nNbPointsPremierePasse;
740 if (!bOrdonneDeSversR)
745 int nVerifNbPointsAjoutes = 1;
746 for (i = 1; i < nNbPointsEC; i++)
748 if (this->
intersects(*TableauDePointsEC[i - 1], *TableauDePointsEC[i]))
754 nVerifNbPointsAjoutes += geoSecondePasse.
AjouteLesPointsComprisEntre(geoPremierePasse, 0, TableauDePointsEC[i - 1]->Identifiant, TableauDePointsEC[i]->Identifiant);
759 nVerifNbPointsAjoutes++;
763 pTableauEC = TableauDePointsEC;
764 nbPtsEC = nNbPointsEC;
772 for (
int i = 0; i < nNbPointsDeLaListe / 2; i++)
774 TYPointParcours* pTmp = ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i];
775 ListeDePointsAInverser[nNbPointsDeLaListe - 1 - i] = ListeDePointsAInverser[i];
776 ListeDePointsAInverser[i] = pTmp;
782 int nNbPointsAjoutes = 0;
787 for (i = 0; i < PolyligneSource->
nombreDePoint() && PolyligneSource->
indexePoint(i) != nIndexeNbPremierPointAAjouter; i++) { ; }
793 if (PolyligneSource->
indexePoint(i) == nIndexeDernierPointAAjouter)
798 return nNbPointsAjoutes;
815 bool bMemePoint1 = (indexPoint1 == indexPoint1In) || (indexPoint1 == indexPoint2In);
816 bool bMemePoint2 = (indexPoint2 == indexPoint2In) || (indexPoint2 == indexPoint1In);
817 bool bMemePoints = bMemePoint1 || bMemePoint2;
840 return (determinant < 0);
846 return (determinant > 0);
858 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
859 int indexS = bSaGaucheDeR ? 0 : 1;
860 int indexR = bSaGaucheDeR ? 1 : 0;
867 TableauDePointsECOut[nNbPointsEC] = TableauDePoints[indexS];
878 int indexePointDuBonCote = -1;
885 indexePointDuBonCote = -1;
886 for (i = 2; i < nNbPoints; i++)
888 P2 = (*TableauDePoints[i]);
894 bool bDuBonCote = (*pDuBonCote)(PP1, PP2, determinant);
899 bool bBonCandidatPourRemplacement;
905 bBonCandidatPourRemplacement =
false;
909 bBonCandidatPourRemplacement = PP2.normeCarree() > PP1.normeCarree();
914 bBonCandidatPourRemplacement = bDuBonCote;
916 if (bBonCandidatPourRemplacement)
920 indexePointDuBonCote = i;
927 if (indexePointDuBonCote >= 0)
930 pNouveauPointEC = TableauDePoints[indexePointDuBonCote];
938 pNouveauPointEC = TableauDePoints[indexR];
941 TableauDePointsECOut[nNbPointsEC] = pNouveauPointEC;
944 while (nNbPointsEC < nNbPoints && indexePointDuBonCote >= 0);
951 if (NULL == TableauDePoints || 0 == nNbPoints)
955 int nNbPointsSelectiones = 2;
965 bool bSaGaucheDeR = TableauDePoints[0]->
x < TableauDePoints[1]->
x;
969 G = *TableauDePoints[0];
970 D = *TableauDePoints[1];
974 G = *TableauDePoints[1];
975 D = *TableauDePoints[0];
986 bool noIntersection =
true;
990 for (
int j = 0; (j < nbPts - 1) && (noIntersection); j++)
997 noIntersection =
false;
1003 if (noIntersection) {
return nNbPointsSelectiones; }
1011 bool bIndentifiantNulAjoute =
false;
1017 for (i = 0; i < nNbPoints; i++)
1021 while (i != 0 && i < nNbPoints &&
_ListePoint[i].Identifiant <= nIdentifiantRacine) { i++; }
1034 TableauDePoints[nNbPointsSelectiones] = &(
_ListePoint[i]);
1037 bIndentifiantNulAjoute =
true;
1040 nNbPointsSelectiones++;
1044 return nNbPointsSelectiones;
1050 if (NULL == TableauDePoints || 0 == nNbPoints)
1072 for (i = 0; i < nNbPoints; i++)
1077 if (!bGardeIdentifiant)
1079 for (i = 0; i < nNbPoints; i++)
1087 for (i = 0; i < nNbPoints; i++)
1089 _ListePoint[i] = *TableauDePoints[nNbPoints - i - 1];
1092 if (!bGardeIdentifiant)
1094 for (i = 0; i < nNbPoints; i++)
1120 for (
int j = 0; j < nbPts; j++)
1135 cosVal1 = v1.
scalar(v3) / norme1;
1145 cosVal2 = v2.
scalar(v3) / norme2;
1157 cosVal2 = v2.
scalar(v4) / norme2;
1167 cosVal1 = v1.
scalar(v4) / norme1;
bool allouer(int nNbPoint)
Allocate nNbPoint points to the polyline.
static bool IntersectionSegments(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4, TYPointParcours &P)
Return false if [P1P2] and [P3P4] does not intersect, true if not with P the intersection.
int compareTYPolyligneParcours(const void *p1, const void *p2)
int indexePoint1()
Return point id of point P0.
bool ListerPointsConnexes(Connexite *&Connexes, std::vector< bool > &pEstUnPointIntersectant)
Fill for each point the connectivity with segments.
Polylines path class used by the TYSetGeometriqueParcours class.
void SeparationDroiteGauche(bool *PointsAGauche, bool *PointsADroite, TYSetGeometriqueParcours &geoGauche, TYSetGeometriqueParcours &geoDroite)
Separate left and right polylines with two geometric paths.
static double ZCross(TYPointParcours SR, TYPointParcours SP)
Return cross product applied to SR and SP points.
Connectivity between points and segments.
bool isEcran
Flag set to indicate if the point is a screen.
int indexePoint(int i)
Return point id of point i of the polyline.
int indexePointSuivant(int IndexPoint, TYPolyligneParcours *&PolyligneSuivante)
Return the point id of the next point given by IndexPoint id.
int _nNbPolylines
Polylines number.
bool isEcran()
Return true if P0 and P1 are Ecran.
void Copy(TYSetGeometriqueParcours &geoIn)
Copy operator.
static TYPointParcours vecteur2D(TYPointParcours &P1, TYPointParcours &P2)
Return a TYPointParcours point P=P1P2=P2-P1.
void ajoutePoint(int indexe, TYPointParcours *p)
Add a point.
bool SecondVecteurADroiteDuPremier(TYPointParcours &V1, TYPointParcours &V2, double &determinant)
int IndexesSegment[2]
Two indexes of the segment.
static bool IntersectionDroites(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4, TYPointParcours &P)
Return false if (P1P2) and (P3P4) are parallel, true if not with P the intersection.
double y
y coordinate of the point
int indexePoint2()
Return point id of point P1.
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 MarquePointsADroiteEtAGauche(TYPointParcours &Srce, TYPointParcours &Dest, bool *&PointsAGauche, bool *&PointsADroite)
Mark points on the left and on the right of the current geometric path.
static TYPointParcours * _SrceQSort
static access to the C function of quicksort
bool intersects(TYPointParcours &P1, TYPointParcours &P2)
Check if [P1P2] segment can intersect the geometric path.
TYPointParcours * _ListePoint
List of points on the path.
double norme() const
Computes the length of this vector.
TYPointParcours * pointPtr(int indexe)
Return a pointer on the point Pi.
static TYPointParcours * _ListePointQSort
static access to the C function of quicksort
void RamenerPointsTraversantLaFrontiere(TYPointParcours &Srce, TYPointParcours &Dest, int *IndexePointsFrontiere, int &NbPointsFrontiere, std::vector< bool > &pEstUnPointIntersectant, bool bCoteGauche, bool *PointsAGauche, bool *PointsADroite)
To be commented.
static void InverseOrdreDesPoints(TYPointParcours **ListeDePointsAInverser, int nNbPointsDeLaListe)
Invert a list of points.
Class to build a geometric path used by the TYCalculParcours class.
int SupressionPolylignesRedondantes()
Suppress useless polylines.
bool AjoutePointALaPolyLigne(int indexPolyligne, TYPointParcours &P)
Add a point P to the polyline indexPolyligne.
void CreerTrajetAPartirDuneListeDePointsTriee(TYPointParcours **TableauDePoints, int nNbPoints, bool bSens, bool bGardeIdentifiant)
Create paths from a sorted points list (Used only for vertical paths)
int ParcourtPolyligneAPartirDe(int IndexPointRacine, TYPolyligneParcours *&PolyligneRacine, std::vector< bool > &pEstUnPointIntersectant, TYSetGeometriqueParcours &geoPremierePasse)
To be commented.
TYPolyligneParcours * _ListePolylines
Geometric path as a polylines.
bool PremierePasse(TYPointParcours &Srce, TYPointParcours &Dest, int *IndexePointsFrontiere, int NbPointsFrontiere, std::vector< bool > &pEstUnPointIntersectant, Connexite *Connexes, TYSetGeometriqueParcours &geoPremierePasse)
First pass to build a path along all the intersecting polylines.
#define SAFE_DELETE_LIST(_p)
static TYPointParcours * _DestQSort
static access to the C function of quicksort
double _y
y coordinate of OCoord3D
double _x
x coordinate of OCoord3D
double x
x coordinate of the point
int MergePointsDoubles()
Detect and fix double points.
void TriePointsIntersectionSuivantSR(TYPointParcours &Srce, TYPointParcours &Dest, int *IndexePointsFrontiere, int NbPointsFrontiere)
To be commented.
#define SEUIL_DETERMNANT_COLINEAIRE
Below this absolute value, the determinant is not a valid criteria to assess the collinearity of two ...
TYPolyligneParcours * _PolyligneP0
Pointer to the previous polyline (from P0 point)
static double Scalaire(TYPointParcours &P1, TYPointParcours &P2, TYPointParcours &P3, TYPointParcours &P4)
Return scalar product P2P1.P4P3.
TYPointParcours point(int indexe)
Return a copy the point Pi.
int NbSegmentsConnexes
Related segments number.
bool AppartienneMemePolyligne(TYPointParcours *a, TYPointParcours *b, TYPointParcours *c)
Check if the points a, b, c belong to the same polyline.
static int EnveloppeConvexeLes2PremiersPointsEtant(TYPointParcours **TableauDePoints, int nNbPoints, TYPointParcours **TableauDePointsECOut, bool bPremiersPointsLesPlusHauts)
Compute the convex hull (arrays should be allocated before the call)
int AjouteLesPointsComprisEntre(TYSetGeometriqueParcours &geoPolySource, int nIndexePoly, int nIndexeNbPremierPointAAjouter, int nIndexeDernierPointAAjouter)
Add some points of the nIndexePoly polyline from the geoPolySource geometric path.
double scalar(const OVector3D &vector) const
Performs the scalar product between this object and another vector.
bool isInfra
Flag set to indicate if the point is an infrastructure.
int compareAbscissesCurvilignes(const void *p1, const void *p2)
int nombreDePoint()
Return the number of points.
int _nNbPointTotal
Total number of points.
void SwapPolyligne(int i, int j)
Swap polylines i and j.
void setPoint(int indexe, TYPointParcours *p)
Change a point.
double z
z coordinate of the point
TYPolyligneParcours * _PolyligneP1
Pointer to the next polyline (from P1 point)
static double AbscisseCurviligneCarreSurSR(TYPointParcours &P, TYPointParcours &S, TYPointParcours &R)
Return the square of the curvilinear abscissa of point P on [SR].
static bool Confondus(TYPointParcours *P1, TYPointParcours *P2)
Return true if P1 and P2 are on the same location (separated by less than a threshold distance) ...
bool PolylignesInfraFermees()
Return true if all polylines from infrastructure are closed.
bool SecondVecteurAGaucheDuPremier(TYPointParcours &V1, TYPointParcours &V2, double &determinant)
bool SecondePasse(TYSetGeometriqueParcours &geoPremierePasse, TYSetGeometriqueParcours &geoSecondePasse, bool bTrajetsAGaucheDeSR, TYPointParcours **&pTableauEC, int &nbPtsEC)
Second pass.