comparison OrthancStone/Sources/Toolbox/DicomStructureSet.cpp @ 1838:80e029f8ec91

fix wrong display of RTStruct when an RTStruct point has exactly the same X or Y coordinates as the origin
author Alain Mazy <alain@mazy.be>
date Thu, 17 Jun 2021 17:00:06 +0200
parents 126522623e20
children 3889ae96d2e9
comparison
equal deleted inserted replaced
1836:5a6adbc20ace 1838:80e029f8ec91
340 double curX, curY; 340 double curX, curY;
341 geometry_.ProjectPoint2(curX, curY, points_[i]); 341 geometry_.ProjectPoint2(curX, curY, points_[i]);
342 342
343 // if prev* and cur* are on opposite sides of y, this means that the 343 // if prev* and cur* are on opposite sides of y, this means that the
344 // segment intersects the plane. 344 // segment intersects the plane.
345 if ((prevY < y && curY > y) || 345 if ((prevY <= y && curY >= y) ||
346 (prevY > y && curY < y)) 346 (prevY >= y && curY <= y))
347 { 347 {
348 double p = (curX * prevY - curY * prevX + y * (prevX - curX)) / (prevY - curY); 348 double p = (curX * prevY - curY * prevX + y * (prevX - curX)) / (prevY - curY);
349 xmin = std::min(xmin, p); 349 xmin = std::min(xmin, p);
350 xmax = std::max(xmax, p); 350 xmax = std::max(xmax, p);
351 isFirst = false; 351 isFirst = false;
411 { 411 {
412 // Reference: ../../Resources/Computations/IntersectSegmentAndVerticalLine.py 412 // Reference: ../../Resources/Computations/IntersectSegmentAndVerticalLine.py
413 double curX, curY; 413 double curX, curY;
414 geometry_.ProjectPoint2(curX, curY, points_[i]); 414 geometry_.ProjectPoint2(curX, curY, points_[i]);
415 415
416 if ((prevX < x && curX > x) || 416 if ((prevX <= x && curX >= x) ||
417 (prevX > x && curX < x)) 417 (prevX >= x && curX <= x))
418 { 418 {
419 double p = (curX * prevY - curY * prevX + x * (curY - prevY)) / (curX - prevX); 419 double p = (curX * prevY - curY * prevX + x * (curY - prevY)) / (curX - prevX);
420 ymin = std::min(ymin, p); 420 ymin = std::min(ymin, p);
421 ymax = std::max(ymax, p); 421 ymax = std::max(ymax, p);
422 isFirst = false; 422 isFirst = false;