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