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