Microscopic structure and structuring of perovskite surfaces and interfaces: SrTiO3, RBa2Cu3O7-δ