Skip to content

Commit 0f42d26

Browse files
committed
fix collision with new geometry methods
1 parent 08405db commit 0f42d26

1 file changed

Lines changed: 27 additions & 33 deletions

File tree

src/ogdf_python/matplotlib/rendering.h

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ namespace ogdf {
8989
}
9090
}
9191

92-
bool isPointCoveredByNode(const DPoint& point, const DPoint& v, const DPoint& vSize,
92+
bool isPointCoveredByNodeOP(const DPoint& point, const DPoint& v, const DPoint& vSize,
9393
const Shape& shape) {
9494
const double epsilon = 1e-6;
9595
const double trapeziumWidthOffset = vSize.m_x * 0.275;
@@ -181,7 +181,7 @@ namespace ogdf {
181181
}
182182
}
183183

184-
DPoint contourPointFromAngle(double angle, int n, double rotationOffset, const DPoint& center,
184+
DPoint contourPointFromAngleOP(double angle, int n, double rotationOffset, const DPoint& center,
185185
const DPoint& vSize) {
186186
// math visualised: https://www.desmos.com/calculator/j6iktd7fs4
187187
double nOffset = floor((angle - rotationOffset) / (2 * Math::pi / n)) * 2 * Math::pi / n;
@@ -198,36 +198,36 @@ namespace ogdf {
198198
return intersectionPoint + center;
199199
}
200200

201-
DPoint contourPointFromAngle(double angle, Shape shape, const DPoint& center, const DPoint& vSize) {
201+
DPoint contourPointFromAngleOP(double angle, Shape shape, const DPoint& center, const DPoint& vSize) {
202202
angle = std::fmod(angle, 2 * Math::pi);
203203
if (angle < 0) {
204204
angle += Math::pi * 2;
205205
}
206206

207207
switch (shape) {
208208
case Shape::Triangle:
209-
return contourPointFromAngle(angle, 3, Math::pi / 2, center, vSize * .5);
209+
return contourPointFromAngleOP(angle, 3, Math::pi / 2, center, vSize * .5);
210210
case Shape::InvTriangle:
211-
return center - contourPointFromAngle(angle + Math::pi, Shape::Triangle, DPoint(), vSize);
211+
return center - contourPointFromAngleOP(angle + Math::pi, Shape::Triangle, DPoint(), vSize);
212212
case Shape::Image:
213213
case Shape::RoundedRect:
214214
case Shape::Rect:
215-
return contourPointFromAngle(angle, 4, Math::pi / 4, center, vSize / sqrt(2));
215+
return contourPointFromAngleOP(angle, 4, Math::pi / 4, center, vSize / sqrt(2));
216216
case Shape::Pentagon:
217-
return contourPointFromAngle(angle, 5, Math::pi / 2, center, vSize / 2);
217+
return contourPointFromAngleOP(angle, 5, Math::pi / 2, center, vSize / 2);
218218
case Shape::Hexagon:
219-
return contourPointFromAngle(angle, 6, 0, center, vSize / 2);
219+
return contourPointFromAngleOP(angle, 6, 0, center, vSize / 2);
220220
case Shape::Octagon:
221-
return contourPointFromAngle(angle, 8, Math::pi / 8, center, vSize / 2);
221+
return contourPointFromAngleOP(angle, 8, Math::pi / 8, center, vSize / 2);
222222
case Shape::Rhomb:
223-
return contourPointFromAngle(angle, 4, Math::pi / 2, center, vSize / 2);
223+
return contourPointFromAngleOP(angle, 4, Math::pi / 2, center, vSize / 2);
224224
case Shape::Trapeze:
225225
if (angle < atan(2) || angle >= Math::pi * 7 / 4) {
226-
DPoint other = contourPointFromAngle(Math::pi - angle, Shape::Trapeze, DPoint(), vSize);
226+
DPoint other = contourPointFromAngleOP(Math::pi - angle, Shape::Trapeze, DPoint(), vSize);
227227
other.m_x *= -1;
228228
return other + center;
229229
} else if (angle < Math::pi - atan(2)) {
230-
return contourPointFromAngle(angle, Shape::Rect, center, vSize);
230+
return contourPointFromAngleOP(angle, Shape::Rect, center, vSize);
231231
} else if (angle < Math::pi * 5 / 4) {
232232
DLine tLine = DLine(.5, -1, 1, 1);
233233
DLine eLine = DLine(0, 0, 2 * cos(angle), 2 * sin(angle));
@@ -236,10 +236,10 @@ namespace ogdf {
236236
iPoint = DPoint(iPoint.m_x * vSize.m_x * .5, iPoint.m_y * vSize.m_y * .5);
237237
return iPoint + center;
238238
} else { // angle < Math::pi * 7 / 4
239-
return contourPointFromAngle(angle, Shape::Rect, center, vSize);
239+
return contourPointFromAngleOP(angle, Shape::Rect, center, vSize);
240240
}
241241
case Shape::InvTrapeze:
242-
return center - contourPointFromAngle(angle + Math::pi, Shape::Trapeze, DPoint(), vSize);
242+
return center - contourPointFromAngleOP(angle + Math::pi, Shape::Trapeze, DPoint(), vSize);
243243
case Shape::Parallelogram:
244244
if (angle < atan(2) || angle > Math::pi * 7 / 4) {
245245
DLine tLine = DLine(-.5, -1, -1, 1);
@@ -249,7 +249,7 @@ namespace ogdf {
249249
iPoint = DPoint(iPoint.m_x * vSize.m_x * .5, iPoint.m_y * vSize.m_y * .5);
250250
return iPoint + center;
251251
} else if (angle < Math::pi * 3 / 4) {
252-
return contourPointFromAngle(angle, Shape::Rect, center, vSize);
252+
return contourPointFromAngleOP(angle, Shape::Rect, center, vSize);
253253
} else if (angle < Math::pi + atan(2)) {
254254
DLine tLine = DLine(.5, 1, 1, -1);
255255
DLine eLine = DLine(0, 0, 2 * cos(angle), 2 * sin(angle));
@@ -258,10 +258,10 @@ namespace ogdf {
258258
iPoint = DPoint(iPoint.m_x * vSize.m_x * .5, iPoint.m_y * vSize.m_y * .5);
259259
return iPoint + center;
260260
} else { // angle < Math::pi * 7 / 4
261-
return contourPointFromAngle(angle, Shape::Rect, center, vSize);
261+
return contourPointFromAngleOP(angle, Shape::Rect, center, vSize);
262262
}
263263
case Shape::InvParallelogram: {
264-
DPoint p = contourPointFromAngle(Math::pi - angle, Shape::Parallelogram, DPoint(), vSize);
264+
DPoint p = contourPointFromAngleOP(Math::pi - angle, Shape::Parallelogram, DPoint(), vSize);
265265
p.m_x *= -1;
266266
return p + center;
267267
}
@@ -272,29 +272,23 @@ namespace ogdf {
272272
}
273273

274274
bool isArrowEnabled(GraphAttributes &m_attr, adjEntry adj) {
275-
bool result = false;
276-
277-
if (m_attr.has(GraphAttributes::edgeArrow)) {
275+
if (m_attr.has(GraphAttributes::edgeArrow)) {
278276
switch (m_attr.arrowType(*adj)) {
279277
case EdgeArrow::Undefined:
280-
result = !adj->isSource() && m_attr.directed();
281-
break;
278+
return !adj->isSource() && m_attr.directed();
282279
case EdgeArrow::First:
283-
result = adj->isSource();
284-
break;
280+
return adj->isSource();
285281
case EdgeArrow::Last:
286-
result = !adj->isSource();
287-
break;
282+
return !adj->isSource();
288283
case EdgeArrow::Both:
289-
result = true;
290-
break;
291-
case EdgeArrow::None:;
284+
return true;
285+
case EdgeArrow::None:
286+
default:
287+
return false;
292288
}
293289
} else {
294-
result = !adj->isSource() && m_attr.directed();
290+
return !adj->isSource() && m_attr.directed();
295291
}
296-
297-
return result;
298292
}
299293

300294
double getArrowSize(GraphAttributes &m_attr, adjEntry adj) {
@@ -315,7 +309,7 @@ namespace ogdf {
315309
bool isCoveredBy(GraphAttributes &m_attr, const DPoint &point, adjEntry adj) {
316310
node v = adj->theNode();
317311
DPoint vSize = DPoint(m_attr.width(v), m_attr.height(v));
318-
return isPointCoveredByNode(point, m_attr.point(v), vSize, m_attr.shape(v));
312+
return isPointCoveredByNodeOP(point, m_attr.point(v), vSize, m_attr.shape(v));
319313
}
320314

321315
DPolyline drawArrowHead(const DPoint &start, DPoint &end, adjEntry adj, GraphAttributes &m_attr) {

0 commit comments

Comments
 (0)