MCPcopy Create free account
hub / github.com/Kitware/VTK / findScanRange

Function findScanRange

Rendering/FreeType/vtkFreeTypeTools.cxx:1628–1673  ·  view source on GitHub ↗

Given the corners of a rectangle (TL, TR, BL, BR), the vectors that separate them (dx = TR - TL = BR - BL, dy = TR - BR = TL - BL), and the y value to scan, return the minimum and maximum x values that the rectangle contains.

Source from the content-addressed store, hash-verified

1626// y value to scan, return the minimum and maximum x values that the rectangle
1627// contains.
1628bool findScanRange(const vtkVector2i& TL, const vtkVector2i& TR, const vtkVector2i& BL,
1629 const vtkVector2i& BR, const vtkVector2i& dx, const vtkVector2i& dy, int y, int& min, int& max)
1630{
1631 // Initialize the min and max to a known invalid range using the bounds of the
1632 // rectangle:
1633 min = std::max({ TL[0], TR[0], BL[0], BR[0] });
1634 max = std::min({ TL[0], TR[0], BL[0], BR[0] });
1635
1636 float lineParam;
1637 int numIntersections = 0;
1638
1639 // Top
1640 if (getIntersectionParameter(TL, dx, y, lineParam))
1641 {
1642 int x = evaluateLineXOnly(TL, dx, lineParam);
1643 min = std::min(min, x);
1644 max = std::max(max, x);
1645 ++numIntersections;
1646 }
1647 // Bottom
1648 if (getIntersectionParameter(BL, dx, y, lineParam))
1649 {
1650 int x = evaluateLineXOnly(BL, dx, lineParam);
1651 min = std::min(min, x);
1652 max = std::max(max, x);
1653 ++numIntersections;
1654 }
1655 // Left
1656 if (getIntersectionParameter(BL, dy, y, lineParam))
1657 {
1658 int x = evaluateLineXOnly(BL, dy, lineParam);
1659 min = std::min(min, x);
1660 max = std::max(max, x);
1661 ++numIntersections;
1662 }
1663 // Right
1664 if (getIntersectionParameter(BR, dy, y, lineParam))
1665 {
1666 int x = evaluateLineXOnly(BR, dy, lineParam);
1667 min = std::min(min, x);
1668 max = std::max(max, x);
1669 ++numIntersections;
1670 }
1671
1672 return numIntersections != 0;
1673}
1674
1675// Clamp value to stay between the minimum and maximum extent for the
1676// specified dimension.

Callers 1

RenderBackgroundMethod · 0.85

Calls 4

getIntersectionParameterFunction · 0.85
evaluateLineXOnlyFunction · 0.85
maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected