fixed getComponentsInDirection, don't use the rightBoundary, it may skip components