Michael Klinger and Alex Gidman scored centuries for Gloucestershire on a rain-shortened third day against Glamorgan at Bristol.