ply.h
Go to the documentation of this file.
00001 /*
00002 
00003 Header for PLY polygon files.
00004 
00005 - Greg Turk, March 1994
00006 
00007 A PLY file contains a single polygonal _object_.
00008 
00009 An object is composed of lists of _elements_.  Typical elements are
00010 vertices, faces, edges and materials.
00011 
00012 Each type of element for a given object has one or more _properties_
00013 associated with the element type.  For instance, a vertex element may
00014 have as properties three floating-point values x,y,z and three unsigned
00015 chars for red, green and blue.
00016 
00017 ---------------------------------------------------------------
00018 
00019 Copyright (c) 1994 The Board of Trustees of The Leland Stanford
00020 Junior University.  All rights reserved.   
00021   
00022 Permission to use, copy, modify and distribute this software and its   
00023 documentation for any purpose is hereby granted without fee, provided   
00024 that the above copyright notice and this permission notice appear in   
00025 all copies of this software and that you do not sell the software.   
00026   
00027 THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,   
00028 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY   
00029 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.   
00030 
00031 */
00032 
00033 #ifndef __PLY_H__
00034 #define __PLY_H__
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 #include <stdio.h>
00041 #include <stddef.h>
00042 
00043 #define PLY_ASCII      1        /* ascii PLY file */
00044 #define PLY_BINARY_BE  2        /* binary PLY file, big endian */
00045 #define PLY_BINARY_LE  3        /* binary PLY file, little endian */
00046 
00047 #define PLY_OKAY    0           /* ply routine worked okay */
00048 #define PLY_ERROR  -1           /* error in ply routine */
00049 
00050 /* scalar data types supported by PLY format */
00051 
00052 #define PLY_START_TYPE 0
00053 #define PLY_CHAR       1
00054 #define PLY_SHORT      2
00055 #define PLY_INT        3
00056 #define PLY_UCHAR      4
00057 #define PLY_USHORT     5
00058 #define PLY_UINT       6
00059 #define PLY_FLOAT      7
00060 #define PLY_DOUBLE     8
00061 #define PLY_END_TYPE   9
00062 
00063 #define  PLY_SCALAR  0
00064 #define  PLY_LIST    1
00065 
00066 
00067 typedef struct PlyProperty {    /* description of a property */
00068 
00069   char *name;                           /* property name */
00070   int external_type;                    /* file's data type */
00071   int internal_type;                    /* program's data type */
00072   int offset;                           /* offset bytes of prop in a struct */
00073 
00074   int is_list;                          /* 1 = list, 0 = scalar */
00075   int count_external;                   /* file's count type */
00076   int count_internal;                   /* program's count type */
00077   int count_offset;                     /* offset byte for list count */
00078 
00079 } PlyProperty;
00080 
00081 typedef struct PlyElement {     /* description of an element */
00082   char *name;                   /* element name */
00083   int num;                      /* number of elements in this object */
00084   int size;                     /* size of element (bytes) or -1 if variable */
00085   int nprops;                   /* number of properties for this element */
00086   PlyProperty **props;          /* list of properties in the file */
00087   char *store_prop;             /* flags: property wanted by user? */
00088   int other_offset;             /* offset to un-asked-for props, or -1 if none*/
00089   int other_size;               /* size of other_props structure */
00090 } PlyElement;
00091 
00092 typedef struct PlyOtherProp {   /* describes other properties in an element */
00093   char *name;                   /* element name */
00094   int size;                     /* size of other_props */
00095   int nprops;                   /* number of properties in other_props */
00096   PlyProperty **props;          /* list of properties in other_props */
00097 } PlyOtherProp;
00098 
00099 typedef struct OtherData { /* for storing other_props for an other element */
00100   void *other_props;
00101 } OtherData;
00102 
00103 typedef struct OtherElem {     /* data for one "other" element */
00104   char *elem_name;             /* names of other elements */
00105   int elem_count;              /* count of instances of each element */
00106   OtherData **other_data;      /* actual property data for the elements */
00107   PlyOtherProp *other_props;   /* description of the property data */
00108 } OtherElem;
00109 
00110 typedef struct PlyOtherElems {  /* "other" elements, not interpreted by user */
00111   int num_elems;                /* number of other elements */
00112   OtherElem *other_list;        /* list of data for other elements */
00113 } PlyOtherElems;
00114 
00115 typedef struct PlyFile {        /* description of PLY file */
00116   FILE *fp;                     /* file pointer */
00117   int file_type;                /* ascii or binary */
00118   float version;                /* version number of file */
00119   int nelems;                   /* number of elements of object */
00120   PlyElement **elems;           /* list of elements */
00121   int num_comments;             /* number of comments */
00122   char **comments;              /* list of comments */
00123   int num_obj_info;             /* number of items of object information */
00124   char **obj_info;              /* list of object info items */
00125   PlyElement *which_elem;       /* which element we're currently writing */
00126   PlyOtherElems *other_elems;   /* "other" elements from a PLY file */
00127 } PlyFile;
00128 
00129 /* memory allocation */
00130 extern char *my_alloc();
00131 #define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__)
00132 
00133 
00134 /*** delcaration of routines ***/
00135 
00136 extern PlyFile *ply_write(FILE *, int, char **, int);
00137 extern PlyFile *ply_open_for_writing(char *, int, char **, int, float *);
00138 extern void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *);
00139 extern void ply_describe_property(PlyFile *, char *, PlyProperty *);
00140 extern void ply_element_count(PlyFile *, char *, int);
00141 extern void ply_header_complete(PlyFile *);
00142 extern void ply_put_element_setup(PlyFile *, char *);
00143 extern void ply_put_element(PlyFile *, void *);
00144 extern void ply_put_comment(PlyFile *, char *);
00145 extern void ply_put_obj_info(PlyFile *, char *);
00146 extern PlyFile *ply_read(FILE *, int *, char ***);
00147 extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *);
00148 extern PlyProperty **ply_get_element_description(PlyFile *, char *, int*, int*);
00149 extern void ply_get_element_setup( PlyFile *, char *, int, PlyProperty *);
00150 extern void ply_get_property(PlyFile *, char *, PlyProperty *);
00151 extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
00152 extern void ply_get_element(PlyFile *, void *);
00153 extern char **ply_get_comments(PlyFile *, int *);
00154 extern char **ply_get_obj_info(PlyFile *, int *);
00155 extern void ply_close(PlyFile *);
00156 extern void ply_get_info(PlyFile *, float *, int *);
00157 extern PlyOtherElems *ply_get_other_element (PlyFile *, char *, int);
00158 extern void ply_describe_other_elements ( PlyFile *, PlyOtherElems *);
00159 extern void ply_put_other_elements (PlyFile *);
00160 extern void ply_free_other_elements (PlyOtherElems *);
00161 
00162 extern int equal_strings(char *, char *);
00163 
00164 
00165 #ifdef __cplusplus
00166 }
00167 #endif
00168 #endif /* !__PLY_H__ */
00169 


blort
Author(s): Thomas Mörwald , Michael Zillich , Andreas Richtsfeld , Johann Prankl , Markus Vincze , Bence Magyar
autogenerated on Wed Aug 26 2015 15:24:12