25 #include "inline-macro.hh"
28 #include "dart-vertex.hh"
29 #include "geometry.hh"
30 #include "g-map-vertex.hh"
32 using namespace GMap3d;
35 int ADirectVertex,
int AExtremity1,
36 const CVertex & AZVector)
39 assert(0 <= ADirectVertex);
40 assert(0 <= AExtremity1);
41 assert(!AZVector.isNull());
48 if (fabs(AZVector.getX()) > fabs(AZVector.getY()))
50 if (fabs(AZVector.getX()) > fabs(AZVector.getZ()))
63 if (fabs(AZVector.getY()) > fabs(AZVector.getZ()))
77 int ADirectVertex,
int AExtremity1,
78 const CVertex & AZVector,
79 bool AExactComparison)
80 :
CDartCompare(AMap, ADirectVertex, AExtremity1, AZVector)
86 int ADirectVertex,
int AExtremity1,
87 const CVertex & AZVector)
88 :
CDartCompare(AMap, ADirectVertex, AExtremity1, AZVector)
92 TCoordinate CDartVertexerticalCompare::FX = 0 ;
96 const CVertex & AZVector)
112 #define GET_VERTEX(DART) (FMap-> \
113 getDirectInfoAsAttributeVertex(DART, FDirectVertex))
116 TCoordinate & AX, TCoordinate & AY)
const
118 AX = AVertex.getCoord(
FCoord1);
119 AY = AVertex.getCoord(
FCoord2);
122 bool CDartLexicoCompare::operator()
123 (CDartVertex * ADart1, CDartVertex * ADart2)
const
131 static TCoordinate x1, y1, x2, y2;
137 if (FExactComparison)
147 if (!areEqual(x1, x2))
150 if (!areEqual(y1, y2))
155 bool in1 = FMap->isMarked(ADart1, FExtremity1);
156 bool in2 = FMap->isMarked(ADart2, FExtremity1);
166 return ADart1 < ADart2;
169 bool CDartVertexerticalCompare::operator()
170 (CDartVertex * ADart1, CDartVertex * ADart2)
const
177 static TCoordinate xA,yA, xB,yB, xC,yC, xD,yD;
180 project(*
GET_VERTEX(FMap->alpha0(ADart1)), xB, yB);
182 project(*
GET_VERTEX(FMap->alpha0(ADart2)), xD, yD);
185 TCoordinate dxAB = xB - xA;
186 TCoordinate dxCD = xD - xC;
189 TCoordinate dyAB = yB - yA;
190 TCoordinate dyCD = yD - yC;
193 TCoordinate tAB = isZero(dxAB) ? 0.0 : (FX - xA) / dxAB;
194 TCoordinate tCD = isZero(dxCD) ? 0.0 : (FX - xC) / dxCD;
196 TCoordinate yAB = yA + tAB * dyAB;
197 TCoordinate yCD = yC + tCD * dyCD;
200 if (!areEqual(yAB, yCD))
204 bool in1 = FMap->isMarked(ADart1, FExtremity1);
205 bool in2 = FMap->isMarked(ADart2, FExtremity1);
213 assert(areEqual(tAB, 0.0) || areEqual(tAB, 1.0) ||
214 areEqual(tCD, 0.0) || areEqual(tCD, 1.0) );
216 bool inverseAB = areEqual(tAB, 1.0);
217 bool inverseCD = areEqual(tCD, 1.0);
219 bool verticalAB = isZero(dxAB);
220 bool verticalCD = isZero(dxCD);
222 if (verticalAB || verticalCD)
230 return ADart1 < ADart2;
233 TCoordinate tanAB = dyAB / dxAB;
234 TCoordinate tanCD = dyCD / dxCD;
236 if (inverseAB) tanAB = - tanAB;
237 if (inverseCD) tanCD = - tanCD;
239 if (areEqual(tanAB, tanCD))
240 return ADart1 < ADart2;
242 return tanAB < tanCD;
249 static TCoordinate y;
253 bool CDartAngularCompare::operator()
254 (CDartVertex * ADart1, CDartVertex * ADart2)
const
262 const CVertex & A = *
GET_VERTEX(FMap->alpha0(ADart1));
263 const CVertex & B = *
GET_VERTEX(FMap->alpha0(ADart2));
265 TCoordinate angle = CGeometry::getAngle(A-O, B-O, FZVector);