Looping mechanics of rods and DNA with non-homogeneous and discontinuous stiffness