Ejemplo n.º 1
0
template <typename INT> ExoII_Read<INT>::~ExoII_Read()
{
  try {
    SMART_ASSERT(Check_State());

    if (file_id >= 0) {
      std::string err = Close_File();
      if (!err.empty())
        std::cout << "ExoII_Read destructor()  ERROR closing file:"
                  << " \"" << err << "\"" << '\n';
    }

    delete[] eblocks;
    delete[] nsets;
    delete[] ssets;
    delete[] nodes;
    delete[] times;
    if (results) {
      for (unsigned i = 0; i < nodal_vars.size(); ++i)
        delete[] results[i];
      delete[] results;
    }
    delete[] global_vals;
    delete[] global_vals2;
    delete[] node_map;
    delete[] elmt_map;
    delete[] elmt_order;
  }
  catch (...) {
  }
}
Ejemplo n.º 2
0
void Read_Longs(int fd, unsigned char array[], long length)
{
  long n_read;
  long more_read;
  n_read = read(fd,array,MIN(length,32766));
  if (n_read != -1 && n_read != 0) {
    while (n_read < length) {
      more_read = read(fd,&array[n_read],
		       MIN(length-n_read,32766));
      if (more_read == -1 || more_read == 0) break;
      n_read += more_read;
    }
  }
  if (n_read != length) {
    Close_File(fd);
    Error("    Read failed on file %d\n",fd);
  }
#ifdef FLIP
  for (i=0; i<length; i+=4) {
    byte = array[i];
    array[i] = array[i+3];
    array[i+3] = byte;
    byte = array[i+1];
    array[i+1] = array[i+2];
    array[i+2] = byte;
  }
#endif
}
Ejemplo n.º 3
0
void Write_Shorts(int fd, unsigned char array[], long length)
{
  long n_written;
  long more_written;
#ifdef FLIP
  for (i=0; i<length; i+=2) {
    byte = array[i];
    array[i] = array[i+1];
    array[i+1] = byte;
  }
#endif
  n_written = write(fd,array,MIN(length,32766));
  if (n_written != -1) {
    while (n_written < length) {
      more_written = write(fd,&array[n_written],
			   MIN(length-n_written,32766));
      if (more_written == -1) break;
      n_written += more_written;
    }
  }
  if (n_written != length) {
    Close_File(fd);
    Error("    Write failed on file %d\n",fd);
  }
#ifdef FLIP
  for (i=0; i<length; i+=2) {
    byte = array[i];
    array[i] = array[i+1];
    array[i+1] = byte;
  }
#endif
}
Ejemplo n.º 4
0
FileError File::close( FileHandle fh )
{
	if( !Is_Open( fh ) || !Close_File( fh ) )
		return FILE_CLOSE_FAIL;
	else
		return FILE_SUCCESS;
}
Ejemplo n.º 5
0
void Write_Bytes(int fd, unsigned char array[], long length)
{
  long n_written;
  long more_written;
  n_written = write(fd,array,MIN(length,32766));
  if (n_written != -1) {
    while (n_written < length) {
      more_written = write(fd,&array[n_written],
			   MIN(length-n_written,32766));
      if (more_written == -1) break;
      n_written += more_written;
    }
  }
  if (n_written != length) {
    Close_File(fd);
    Error("    Write failed on file %d\n",fd);
  }
}
Ejemplo n.º 6
0
void Read_Bytes(int fd, unsigned char array[], long length)
{
  long n_read;
  long more_read;
  n_read = read(fd,array,MIN(length,32766));
  if (n_read != -1 && n_read != 0) {
    while (n_read < length) {
      more_read = read(fd,&array[n_read],
		       MIN(length-n_read,32766));
      if (more_read == -1 || more_read == 0) break;
      n_read += more_read;
    }
  }
  if (n_read != length) {
    Close_File(fd);
    Error("    Read failed on file %d\n",fd);
  }
}
Ejemplo n.º 7
0
void Store_Opacity(char filename [])
{
  char local_filename[FILENAME_STRING_SIZE];
  int fd;

  strcpy(local_filename,filename);
  strcat(local_filename,".opc");
  fd = Create_File(local_filename);

  opc_version = OPC_CUR_VERSION;
  strcpy(local_filename,filename);
  strcat(local_filename,".opc");
  fd = Create_File(local_filename);
  Write_Shorts(fd,(unsigned char *)&opc_version,(long)sizeof(opc_version));

  Write_Shorts(fd,(unsigned char *)opc_len,(long)sizeof(opc_len));
  Write_Longs(fd,(unsigned char *)&opc_length,(long)sizeof(opc_length));

  printf("    Storing opacity map into .opc file...\n");
  Write_Bytes(fd,(unsigned char *)opc_address,(long)(opc_length*sizeof(OPACITY)));
  Close_File(fd);
}
Ejemplo n.º 8
0
void Load_Opacity(char filename [])
{
  char local_filename[FILENAME_STRING_SIZE];
  int fd;

  strcpy(local_filename,filename);
  strcat(local_filename,".opc");
  fd = Open_File(local_filename);

  Read_Shorts(fd,(unsigned char *)&opc_version, (long)sizeof(opc_version));
  if (opc_version != OPC_CUR_VERSION)
    Error("    Can't load version %d file\n",opc_version);

  Read_Shorts(fd,(unsigned char *)opc_len,(long)sizeof(map_len));

  Read_Longs(fd,(unsigned char *)&opc_length,(long)sizeof(opc_length));

  Allocate_Opacity(&opc_address,opc_length);

  printf("    Loading opacity map from .opc file...\n");
  Read_Bytes(fd,(unsigned char *)opc_address,(long)(opc_length*sizeof(OPACITY)));
  Close_File(fd);
}
Ejemplo n.º 9
0
void Store_Image(char filename[])
{
  char local_filename[FILENAME_STRING_SIZE];
  long fd;
  short pix_version;
  short local_image_len[NI+1]; /* dimension larger than NI for backwards     */
                               /* compatibility of .pix file with no color   */

  local_image_len[X] = image_len[X];
  local_image_len[Y] = image_len[Y];
  local_image_len[2] = 1;

  pix_version = PIX_CUR_VERSION;
  strcpy(local_filename,filename);
  strcat(local_filename,".pix");
  fd = Create_File(local_filename);
  Write_Shorts(fd,(unsigned char *)&pix_version,(long)sizeof(pix_version));

  Write_Shorts(fd,(unsigned char *)local_image_len,(long)sizeof(local_image_len));
  Write_Longs(fd,(unsigned char *)&image_length,(long)sizeof(image_length));

  Write_Bytes(fd,image_address,(long)(image_length*sizeof(PIXEL)));
  Close_File(fd);
}