Geostat_grid* Cartesian_grid_geometry_xml_io::
  read_grid_geometry(QDir dir,const QDomElement& elem, std::string* errors) const {

	QString grid_name = elem.attribute("name");

	QDomElement elemGeom = elem.firstChildElement("Geometry");

  std::string final_grid_name;
  SmartPtr<Named_interface> ni =
    Root::instance()->new_interface( "cgrid://"+grid_name.toStdString(),
    		gridModels_manager + "/" + grid_name.toStdString());
  Cartesian_grid* grid = dynamic_cast<Cartesian_grid*>( ni.raw_ptr() );
  if(grid == 0) return 0;

  int nx = elemGeom.attribute("nx").toInt();
  int ny = elemGeom.attribute("ny").toInt();
  int nz = elemGeom.attribute("nz").toInt();

  double xsize = elemGeom.attribute("dx").toDouble();
  double ysize = elemGeom.attribute("dy").toDouble();
  double zsize = elemGeom.attribute("dz").toDouble();

  double ox = elemGeom.attribute("ox").toDouble();
  double oy = elemGeom.attribute("oy").toDouble();
  double oz = elemGeom.attribute("oz").toDouble();
  float rotation_z_angle = elemGeom.attribute("rotation_z_angle").toFloat();

  grid->set_dimensions( nx, ny, nz, xsize, ysize, zsize );
  grid->origin( Cartesian_grid::location_type( ox,oy,oz ) );
  grid->set_rotation_z(rotation_z_angle);

  return grid;

}