Elastic scattering of polarized deuterons from 40Ca and 58Ni at intermediate energies