Robust Trajectory-based Density Estimation for Geometric Structure Recovery: Theory and Applications