Ejemplo n.º 1
0
void ImageHeader::write(std::ofstream& f, bool force_reversed) {
  float tmp;
  unsigned tmpSize;
  if (get_number_of_rows() == 0 || get_number_of_columns() == 0 ||
      get_number_of_slices() == 0) {
    return;
  }
  // Set consistent header before saving
  set_header();
  set_time();
  set_date();
  // Write header
  if (algebra::xorT(reversed_, force_reversed)) {
    reversed_ = true;
    IMP::algebra::reversed_write(&spider_header_, sizeof(float), 36, f, true);
    IMP::algebra::reversed_write(&spider_header_.fGeo_matrix, sizeof(double), 9,
                                 f, true);
    // 14 is the number of float fields after fGeo_matrix in the header__ struct
    IMP::algebra::reversed_write(&spider_header_.fAngle1, sizeof(float), 14, f,
                                 true);
    // 752 is the number of chars to the end of the file
    f.write(spider_header_.empty, sizeof(char) * 752);
  } else {
    reversed_ = false;
    f.write(reinterpret_cast<char*>(&spider_header_), sizeof(SpiderHeader));
  }

  // Write empty filling space (filled with zeros)
  tmpSize = get_spider_header_size();  // Size of whole header
  tmpSize -= sizeof(SpiderHeader);     // Decrease the real header
  tmp = (float)0.0;
  for (unsigned i = 0; i < tmpSize / 4; i++) {
    f.write(reinterpret_cast<char*>(&tmp), sizeof(float));
  }
}
Ejemplo n.º 2
0
static void
update_status (state_t                                   *state,
               ply_upstart_monitor_job_properties_t      *job,
               ply_upstart_monitor_instance_properties_t *instance,
               const char                                *action,
               bool                                       is_okay)
{
  ply_boot_client_update_daemon (state->client, job->name, NULL, NULL, state);

  if (job->description == NULL)
    return;

  printf (" * %s%s%s",
          action ? action : "", action ? " " : "", job->description);

  if (terminal_ignores_new_line_after_80_chars () && can_set_cursor_column ())
    {
      int number_of_columns, column;

      number_of_columns = get_number_of_columns ();

      if (number_of_columns < (int) strlen("[fail]"))
        number_of_columns = 80;

      column = number_of_columns - strlen ("[fail]") - 1;

      set_cursor_column (column);

      if (is_okay)
        puts ("[ OK ]");
      else
        {
          bool supports_color;

          supports_color = can_set_fg_color ();

          fputs ("[", stdout);

          if (supports_color)
            set_fg_color (TERMINAL_COLOR_RED);

          fputs ("fail", stdout);

          if (supports_color)
            unset_fg_color ();

          puts ("]");
        }
    }
  else
    {
      if (is_okay)
        puts ("   ...done.");
      else
        puts ("   ...fail!");
    }
}
Ejemplo n.º 3
0
CellIndex_t get_cell_offset_in_layer
(
    Dimensions_t *dimensions,
    CellIndex_t   row_index,
    CellIndex_t   column_index
)
{
    return row_index * get_number_of_columns (dimensions) + column_index ;
}