Builder/Builder/Common/plyfile.c
/******************************************************************************
Given a file pointer, get ready to write PLY data to the file.

Entry:
  fp         - the given file pointer
  nelems     - number of elements in object
  elem_names - list of element names
  file_type  - file type, either ascii or binary

Exit:
  returns a pointer to a PlyFile, used to refer to this file, or NULL if error
******************************************************************************/
Given a file pointer, get ready to write PLY data to the file.
Entry:
fp         - the given file pointer
nelems     - number of elements in object
elem_names - list of element names
file_type  - file type, either ascii or binary

returns a pointer to a PlyFile, used to refer to this file, or NULL if error
Given a file pointer get ready to write PLY data to the file . Entry : fp - the given file pointer nelems - number of elements in object elem_names - list of element names file_type - file type either ascii or binary returns a pointer to a PlyFile used to refer to this file or NULL if error
PlyFile *ply_write(
  FILE *fp,
  int nelems,
  char **elem_names,
  int file_type
)
{
  int i;
  PlyFile *plyfile;
  PlyElement *elem;
  if (fp == NULL)
    return (NULL);
  if (native_binary_type == -1)
     get_native_binary_type();
  if (!types_checked)
     check_types();
  plyfile = (PlyFile *) myalloc (sizeof (PlyFile));
  if (file_type == PLY_BINARY_NATIVE)
     plyfile->file_type = native_binary_type;
  else
     plyfile->file_type = file_type;
  plyfile->num_comments = 0;
  plyfile->num_obj_info = 0;
  plyfile->nelems = nelems;
  plyfile->version = 1.0;
  plyfile->fp = fp;
  plyfile->other_elems = NULL;
  plyfile->elems = (PlyElement **) myalloc (sizeof (PlyElement *) * nelems);
  for (i = 0; i < nelems; i++) {
    elem = (PlyElement *) myalloc (sizeof (PlyElement));
    plyfile->elems[i] = elem;
    elem->name = _strdup (elem_names[i]);
    elem->num = 0;
    elem->nprops = 0;
  }
  return (plyfile);
}
PlyFile * ply_write ( FILE * fp , int nelems , char * * elem_names , int file_type ) { int i ; PlyFile * plyfile ; PlyElement * elem ; if ( fp == NULL ) return ( NULL ) ; if ( native_binary_type == -1 ) get_native_binary_type ( ) ; if ( ! types_checked ) check_types ( ) ; plyfile = ( PlyFile * ) myalloc ( sizeof ( PlyFile ) ) ; if ( file_type == PLY_BINARY_NATIVE ) plyfile -> file_type = native_binary_type ; else plyfile -> file_type = file_type ; plyfile -> num_comments = 0 ; plyfile -> num_obj_info = 0 ; plyfile -> nelems = nelems ; plyfile -> version = 1.0 ; plyfile -> fp = fp ; plyfile -> other_elems = NULL ; plyfile -> elems = ( PlyElement * * ) myalloc ( sizeof ( PlyElement * ) * nelems ) ; for ( i = 0 ; i < nelems ; i ++ ) { elem = ( PlyElement * ) myalloc ( sizeof ( PlyElement ) ) ; plyfile -> elems [ i ] = elem ; elem -> name = _strdup ( elem_names [ i ] ) ; elem -> num = 0 ; elem -> nprops = 0 ; } return ( plyfile ) ; }
Given a file pointer, get ready to write PLY data to the file.
Given a file pointer get ready to write PLY data to the file .
/* check for NULL file pointer */ /* create a record for this object */ /* tuck aside the names of the elements */ /* return pointer to the file descriptor */