Builder/Builder/Common/plyfile.c
/******************************************************************************
Write out an item to a file as raw binary bytes.

Entry:
  fp         - file to write to
  int_val    - integer version of item
  uint_val   - unsigned integer version of item
  double_val - double-precision float version of item
  type       - data type to write out
******************************************************************************/
Write out an item to a file as raw binary bytes.
Write out an item to a file as raw binary bytes .
void write_binary_item(
  FILE *fp,
  int file_type,
  int int_val,
  unsigned int uint_val,
  double double_val,
  int type
)
{
  unsigned char uchar_val;
  char char_val;
  unsigned short ushort_val;
  short short_val;
  float float_val;
  void  *value;
  switch (type) {
    case PLY_CHAR:
      char_val = int_val;
      value = &char_val;
      break;
    case PLY_SHORT:
      short_val = int_val;
      value = &short_val;
      break;
    case PLY_INT:
      value = &int_val;
      break;
    case PLY_UCHAR:
      uchar_val = uint_val;
      value = &uchar_val;
      break;
    case PLY_USHORT:
      ushort_val = uint_val;
      value = &ushort_val;
      break;
    case PLY_UINT:
      value = &uint_val;
      break;
    case PLY_FLOAT:
      float_val = double_val;
      value = &float_val;
      break;
    case PLY_DOUBLE:
      value = &double_val;
      break;
    default:
      fprintf (stderr, "write_binary_item: bad type = %d\n", type);
      exit (-1);
  }
  if ((file_type != native_binary_type) && (ply_type_size[type] > 1))
     swap_bytes((char *)value, ply_type_size[type]);
  if (fwrite (value, ply_type_size[type], 1, fp) != 1)
  {
      fprintf(stderr, "PLY ERROR: fwrite() failed -- aborting.\n");
      exit(1);
  }
}
void write_binary_item ( FILE * fp , int file_type , int int_val , unsigned int uint_val , double double_val , int type ) { unsigned char uchar_val ; char char_val ; unsigned short ushort_val ; short short_val ; float float_val ; void * value ; switch ( type ) { case PLY_CHAR : char_val = int_val ; value = & char_val ; break ; case PLY_SHORT : short_val = int_val ; value = & short_val ; break ; case PLY_INT : value = & int_val ; break ; case PLY_UCHAR : uchar_val = uint_val ; value = & uchar_val ; break ; case PLY_USHORT : ushort_val = uint_val ; value = & ushort_val ; break ; case PLY_UINT : value = & uint_val ; break ; case PLY_FLOAT : float_val = double_val ; value = & float_val ; break ; case PLY_DOUBLE : value = & double_val ; break ; default : fprintf ( stderr , " \n " , type ) ; exit ( -1 ) ; } if ( ( file_type != native_binary_type ) && ( ply_type_size [ type ] > 1 ) ) swap_bytes ( ( char * ) value , ply_type_size [ type ] ) ; if ( fwrite ( value , ply_type_size [ type ] , 1 , fp ) != 1 ) { fprintf ( stderr , " \n " ) ; exit ( 1 ) ; } }
Write out an item to a file as raw binary bytes.
Write out an item to a file as raw binary bytes .
//case PLY_FLOAT32: