// Last edited on 2011-04-22 02:37:25 by stolfi
// Generic figure of whole Fukushima Daiichi Unit 1 reactor.

#include "coord_axes.inc"
#include "lamp_array.inc"
#include "camlight.inc"
#include "cutters.inc"
#include "generic_parts.inc"
#include "textures.inc"

background{ color rgb < 0.070, 0.070, 0.040 > }

#include "un1_macros.inc"

#macro fig_un1_building(cut)
  // Generic figure of whole Fukushima Daiichi Unit 1 reactor.
  // {cut} = What to remove (0=nothing, 1=South half, 2=East half, 3=SE quarter)
  // Also positions the camera and lights.
  
  // Choose the cutter and camera placement:
  #if (cut = 1)
    #local CR = object{ cutter_not_S() }
    #declare cam_dir = <0,-1,0>;
    #declare cam_dst = 5000;
  #end
  
  #if (cut = 2)
    #local CR = object{ cutter_not_E() } // Cutter for reactor.
    #declare cam_dir = <1,0,0>;
    #declare cam_dst = 5000;
  #end
  
  #if (cut = 3)
    #local CR = object{ cutter_not_SE() } // Cutter for reactor.
    #declare cam_dir = <5,-4,3>;
    #declare cam_dst = 0; // Decide later.
  #end
  
  #local CB = object{ CR translate un1_building_core_axis } // Cutter for building.
  #local cw = 0; // Water level inside RPV.
  #local dw = 0; // Water level in drywell.
  #local sw = 0; // Water level in suppression pool.
  #local uw = 0; // Water level in shroud cavity.
  #local pw = 0; // Water level in spent-fuel pool.
  
  #local scene = 
    union{
      object{ un1_ground(CB) }
      // object{ un1_sky() }
      object{ un1_whole(CB,cw,dw,sw,uw,pw) }
      // object{ un1_building_structure(CB) }
    }

  #local lo_corner = min_extent(scene);
  #local hi_corner = max_extent(scene);

  #if ((cut = 1) | (cut = 2))
    #declare cam_ctr = un1_building_core_axis + 20.800*z;
    #declare cam_rad = 46.500;
  #else
    #declare cam_ctr = (lo_corner + hi_corner)/2;
    #declare cam_rad = 1.2*vlength(hi_corner - lo_corner)/2;
    #local scene =
      union{ 
        object{ scene} 
        object{ coord_axes(cam_rad) }
      }
  #end
  #if (cam_dst <= 0)
    #declare cam_dst = 8*cam_rad;
  #end

  object{ scene }
  camlight(cam_ctr, cam_rad, cam_dir, cam_dst, z, 1.3, 3,2.0)
#end

#macro fig_un1_pools_and_walls(cut)
  // Generic figure of whole Fukushima Daiichi Unit 1 reactor.
  // {cut} = What to remove (0=nothing, 1=South half, 2=East half, 3=SE quarter)
  // Also positions the camera and lights.
  
  // Choose the cutter and camera placement:
  #if (cut = 1)
    #local CR = object{ cutter_not_S() }
    #declare cam_dir = <0,-1,0>;
    #declare cam_dst = 5000;
  #end
  
  #if (cut = 2)
    #local CR = object{ cutter_not_E() } // Cutter for reactor.
    #declare cam_dir = <1,0,0>;
    #declare cam_dst = 5000;
  #end
  
  #if (cut = 3)
    #local CR = object{ cutter_not_SE() } // Cutter for reactor.
    #declare cam_dir = <5,-4,3>;
    #declare cam_dst = 0; // Decide later.
  #end
  
  #local CB = object{ CR translate un1_building_core_axis } // Cutter for building.
  #local cw = 0; // Water level inside RPV.
  #local dw = 0; // Water level in drywell.
  #local sw = 0; // Water level in suppression pool.
  #local uw = 0; // Water level in shroud cavity.
  #local pw = 0; // Water level in spent-fuel pool.
  
  #local scene = 
    intersection{
      object{ CB texture{ tx_enamel_yellow } }
      difference{
        object{ un1_walls_of_pool_cavities() }
        object{ un1_spent_fuel_pool_cavity(0) }
        object{ un1_drier_storage_pool_cavity(0) }
        object{ un1_cask_loading_pool_cavity(0) }
        object{ un1_elevator_well_cavity(0) }
        texture{ tx_concrete }
      }
    }

  #local lo_corner = min_extent(scene);
  #local hi_corner = max_extent(scene);

  #if ((cut = 1) | (cut = 2))
    #declare cam_ctr = un1_building_core_axis + 20.800*z;
    #declare cam_rad = 46.500;
  #else
    #declare cam_ctr = (lo_corner + hi_corner)/2;
    #declare cam_rad = 1.2*vlength(hi_corner - lo_corner)/2;
    #local scene =
      union{ 
        object{ scene} 
        object{ coord_axes(cam_rad) }
      }
  #end
  #if (cam_dst <= 0)
    #declare cam_dst = 8*cam_rad;
  #end

  object{ scene }
  camlight(cam_ctr, cam_rad, cam_dir, cam_dst, z, 1.3, 3,2.0)
#end