A $3 \times 3 \times 3$ cube composed of $27$ unit cubes rests on a horizontal plane. Determine the number of ways of selecting two distinct unit cubes from a $3 \times 3 \times 1$ block (the order is irrelevant) with the property that the line joining the centers of the two cubes makes a $45^\circ$ angle with the horizontal plane.

Let's think step by step and output the final answer within \boxed{}.
user