Scene_implicit_function_item::
Scene_implicit_function_item(Implicit_function_interface* f)
  : function_(f)
  , frame_(new ManipulatedFrame())
  , initialized_(false)
  , grid_size_(SCENE_IMPLICIT_GRID_SIZE)
  , max_value_(0.)
  , min_value_(0.)
  , blue_color_ramp_()
  , red_color_ramp_()
{
  blue_color_ramp_.build_blue();
  red_color_ramp_.build_red();
  compute_min_max();
  compute_function_grid();
  
  connect(frame_, SIGNAL(modified()), this, SLOT(compute_function_grid()));
}
Scene_implicit_function_item::
Scene_implicit_function_item(Implicit_function_interface* f)
  : function_(f)
  , frame_(new ManipulatedFrame())
  , grid_size_(SCENE_IMPLICIT_GRID_SIZE)
  , max_value_(0.)
  , min_value_(0.)
  , blue_color_ramp_()
  , red_color_ramp_()
{
  compile_shaders();
  texture = new Texture(grid_size_,grid_size_);
  blue_color_ramp_.build_blue();
  red_color_ramp_.build_red();
  compute_min_max();
  compute_function_grid();
  connect(frame_, SIGNAL(modified()), this, SLOT(compute_function_grid()));
  are_buffers_initialized = false;
  texture_initialized = false;
}
Example #3
0
void jag_store::setup(
  data_reader_jag_conduit_hdf5 *reader,
  bool num_stores,
  int my_rank) {
  double tm1 = get_time();

  m_master = m_comm->am_world_master();
  options *opts = options::get();
  m_reader = reader;

  m_max_samples = INT_MAX;
  if (opts->has_int("max_samples")) {
    m_max_samples = (size_t)opts->get_int("max_samples");
  }

  bool has_conduit_filenames = false;
  if (opts->has_string("conduit_filelist")) {
    std::string f = opts->get_string("conduit_filelist");
    std::ifstream in(f.c_str());
    if (!in) {
      throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: failed to open " + f + " for reading");
    }
    std::string line;
    while (getline(in, line)) {
      m_conduit_filenames.push_back(line);
    }
    in.close();
    if (m_max_samples < m_conduit_filenames.size()) {
      m_conduit_filenames.resize(m_max_samples);
    }
    has_conduit_filenames = true;
  }

  if (m_image_size == 0) {
    throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: image_size = 0; probably set_image_size() has not been called");
  }

  // optionally build an index file, then exit. Each line of the file will
  // contain a conduit filename, followed by the valid sample_ids in
  // the conduit file
  if (opts->has_string("build_conduit_index")) {
    if (! has_conduit_filenames) {
      throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --conduit_filenames=<string> on the cmd line when building a conduit index");
    }
    build_conduit_index(m_conduit_filenames);
    exit(0);
  }

  load_variable_names();
  build_data_sizes();
  report_linearized_sizes();
  allocate_memory();
  load_normalization_values();

  if (!opts->has_int("mode")) {
    throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --mode=<int> on cmd line, where <int> is 1 (to use conduit files) or 2 or 3 (for testing) (to use binary files)");
  }
  m_mode = opts->get_int("mode");
  if (! (m_mode == 1 || m_mode == 2 || m_mode == 3)) {
    throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --mode=<int> on cmd line, where <int> is 1 (to use conduit files) or 2 (to use binary files); or 4 (for testing) you passed: " + std::to_string(m_mode));
  }
  if (m_master) std::cerr << "Running in mode: " << m_mode << "\n";

  // optionally convert conduit files to our binary format, then exit
  if (opts->has_string("convert_conduit")) {
    if (! has_conduit_filenames) {
      throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: you must pass --conduit_filenames=<string> on the cmd line when converting conduit filenames to binary");
    }
    setup_conduit();
    convert_conduit_to_binary(m_conduit_filenames);
    exit(0);
  }

  if (m_mode == 1) {
    setup_conduit();
  } else if (m_mode == 2) {
    setup_binary();
  } else {
    setup_testing();
  }

  if (m_master) {
    std::cerr << "jag_store::setup time: " << get_time() - tm1 << "; num samples: " << m_num_samples << std::endl;
  }

  if (m_mode == 3) {
    test_converted_files();
    m_comm->global_barrier();
    exit(0);
  }

  // optionally compute min/max values, then exit.
  // This is only needed for one-time computation of normalization values
  if (opts->has_string("compute_min_max")) {
    compute_min_max();
    exit(0);
  }

  // optionally check bandwidth (sort of), then exit
  if (opts->has_int("bandwidth")) {
    if (m_mode == 0) {
      compute_bandwidth();
    } else {
      compute_bandwidth_binary();
    }
    exit(0);
  }
}