Builder/Builder/Common/plyfile.c
/******************************************************************************
Signal that we've described everything a PLY file's header and that the
header should be written to the file.

Entry:
  plyfile - file identifier
******************************************************************************/
Signal that we've described everything a PLY file's header and that the
header should be written to the file.

file identifier
Signal that we ' ve described everything a PLY file ' s header and that the header should be written to the file . file identifier
void ply_header_complete(PlyFile *plyfile)
{
  int i,j;
  FILE *fp = plyfile->fp;
  PlyElement *elem;
  PlyProperty *prop;
  fprintf (fp, "ply\n");
  switch (plyfile->file_type) {
    case PLY_ASCII:
      fprintf (fp, "format ascii 1.0\n");
      break;
    case PLY_BINARY_BE:
      fprintf (fp, "format binary_big_endian 1.0\n");
      break;
    case PLY_BINARY_LE:
      fprintf (fp, "format binary_little_endian 1.0\n");
      break;
    default:
      fprintf (stderr, "ply_header_complete: bad file type = %d\n",
               plyfile->file_type);
      exit (-1);
  }
  for (i = 0; i < plyfile->num_comments; i++)
    fprintf (fp, "comment %s\n", plyfile->comments[i]);
  for (i = 0; i < plyfile->num_obj_info; i++)
    fprintf (fp, "obj_info %s\n", plyfile->obj_info[i]);
  for (i = 0; i < plyfile->nelems; i++) {
    elem = plyfile->elems[i];
    fprintf (fp, "element %s %d\n", elem->name, elem->num);
    for (j = 0; j < elem->nprops; j++) {
      prop = elem->props[j];
      if (prop->is_list) {
        fprintf (fp, "property list ");
        write_scalar_type (fp, prop->count_external);
        fprintf (fp, " ");
        write_scalar_type (fp, prop->external_type);
        fprintf (fp, " %s\n", prop->name);
      }
      else {
        fprintf (fp, "property ");
        write_scalar_type (fp, prop->external_type);
        fprintf (fp, " %s\n", prop->name);
      }
    }
  }
  fprintf (fp, "end_header\n");
}
void ply_header_complete ( PlyFile * plyfile ) { int i , j ; FILE * fp = plyfile -> fp ; PlyElement * elem ; PlyProperty * prop ; fprintf ( fp , " \n " ) ; switch ( plyfile -> file_type ) { case PLY_ASCII : fprintf ( fp , " \n " ) ; break ; case PLY_BINARY_BE : fprintf ( fp , " \n " ) ; break ; case PLY_BINARY_LE : fprintf ( fp , " \n " ) ; break ; default : fprintf ( stderr , " \n " , plyfile -> file_type ) ; exit ( -1 ) ; } for ( i = 0 ; i < plyfile -> num_comments ; i ++ ) fprintf ( fp , " \n " , plyfile -> comments [ i ] ) ; for ( i = 0 ; i < plyfile -> num_obj_info ; i ++ ) fprintf ( fp , " \n " , plyfile -> obj_info [ i ] ) ; for ( i = 0 ; i < plyfile -> nelems ; i ++ ) { elem = plyfile -> elems [ i ] ; fprintf ( fp , " \n " , elem -> name , elem -> num ) ; for ( j = 0 ; j < elem -> nprops ; j ++ ) { prop = elem -> props [ j ] ; if ( prop -> is_list ) { fprintf ( fp , " " ) ; write_scalar_type ( fp , prop -> count_external ) ; fprintf ( fp , " " ) ; write_scalar_type ( fp , prop -> external_type ) ; fprintf ( fp , " \n " , prop -> name ) ; } else { fprintf ( fp , " " ) ; write_scalar_type ( fp , prop -> external_type ) ; fprintf ( fp , " \n " , prop -> name ) ; } } } fprintf ( fp , " \n " ) ; }
Signal that we've described everything a PLY file's header and that the
header should be written to the file.
Signal that we ' ve described everything a PLY file ' s header and that the header should be written to the file .
/* write out the comments */ /* write out object information */ /* write out information about each element */ /* write out each property */