Constraints on the CKM angle gamma in B0 -> D0-bar K*0 and B0 -> D0 K*0 from a Dalitz analysis of D0 and D0-bar decays to K0S pi+ pi-