Hi Giuseppe,
if your goal is to compute the integral of an arbitrary function f(x,y) over a random segment inside your rectangle (you can assume the segment is not parallel to x-axis or y-axis), you could just consider its parametrisation \phi(t), t \in [0,1] so that you have a 1D integral that you can compute. Weights and points in the 1D reference domain can then be asked to dealii.
More advanced users probably have nicer solutions :-)
Best,
Marco