Builder/Builder/Common/plyfile.c
/******************************************************************************
Open a polygon file for writing.

Entry:
  filename   - name of file to read from
  nelems     - number of elements in object
  elem_names - list of element names
  file_type  - file type, either ascii or binary

Exit:
  version - version number of PLY file
  returns a file identifier, used to refer to this file, or NULL if error
******************************************************************************/
Open a polygon file for writing.
Entry:
filename   - name of file to read from
nelems     - number of elements in object
elem_names - list of element names
file_type  - file type, either ascii or binary

version number of PLY file
returns a file identifier, used to refer to this file, or NULL if error
Open a polygon file for writing . Entry : filename - name of file to read from nelems - number of elements in object elem_names - list of element names file_type - file type either ascii or binary version number of PLY file returns a file identifier used to refer to this file or NULL if error
PlyFile *ply_open_for_writing(
  char *filename,
  int nelems,
  char **elem_names,
  int file_type,
  float *version
)
{
  PlyFile *plyfile;
  char *name;
  FILE *fp;
  name = (char *) myalloc (sizeof (char) * (strlen (filename) + 5));
  strcpy (name, filename);
  if (strlen (name) < 4 ||
      strcmp (name + strlen (name) - 4, ".ply") != 0)
      strcat (name, ".ply");
  fp = fopen (name, "w");
  if (fp == NULL) {
    return (NULL);
  }
  plyfile = ply_write (fp, nelems, elem_names, file_type);
  if (plyfile == NULL)
    return (NULL);
  *version = plyfile->version;
  return (plyfile);
}
PlyFile * ply_open_for_writing ( char * filename , int nelems , char * * elem_names , int file_type , float * version ) { PlyFile * plyfile ; char * name ; FILE * fp ; name = ( char * ) myalloc ( sizeof ( char ) * ( strlen ( filename ) + 5 ) ) ; strcpy ( name , filename ) ; if ( strlen ( name ) < 4 || strcmp ( name + strlen ( name ) - 4 , " " ) != 0 ) strcat ( name , " " ) ; fp = fopen ( name , " " ) ; if ( fp == NULL ) { return ( NULL ) ; } plyfile = ply_write ( fp , nelems , elem_names , file_type ) ; if ( plyfile == NULL ) return ( NULL ) ; * version = plyfile -> version ; return ( plyfile ) ; }
Open a polygon file for writing.
Open a polygon file for writing .
/* tack on the extension .ply, if necessary */ /* open the file for writing */ /* create the actual PlyFile structure */ /* say what PLY file version number we're writing */ /* return pointer to the file descriptor */