[37] | 1 | /*************/ |
---|
| 2 | /* Writing */ |
---|
| 3 | /*************/ |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | /****************************************************************************** |
---|
| 7 | Open a polygon file for writing. |
---|
| 8 | |
---|
| 9 | Entry: |
---|
| 10 | filename - name of file to read from |
---|
| 11 | nelems - number of elements in object |
---|
| 12 | elem_names - list of element names |
---|
| 13 | file_type - file type, either ascii or binary |
---|
| 14 | |
---|
| 15 | Exit: |
---|
| 16 | version - version number of PLY file |
---|
| 17 | returns a file identifier, used to refer to this file, or NULL if error |
---|
| 18 | ******************************************************************************/ |
---|
| 19 | |
---|
| 20 | PlyFile *ply_open_for_writing( |
---|
| 21 | char *filename, |
---|
| 22 | int nelems, |
---|
| 23 | char **elem_names, |
---|
| 24 | int file_type, |
---|
| 25 | float *version |
---|
| 26 | ) |
---|
| 27 | |
---|
| 28 | /****************************************************************************** |
---|
| 29 | Describe an element, including its properties and how many will be written |
---|
| 30 | to the file. |
---|
| 31 | |
---|
| 32 | Entry: |
---|
| 33 | plyfile - file identifier |
---|
| 34 | elem_name - name of element that information is being specified about |
---|
| 35 | nelems - number of elements of this type to be written |
---|
| 36 | nprops - number of properties contained in the element |
---|
| 37 | prop_list - list of properties |
---|
| 38 | ******************************************************************************/ |
---|
| 39 | |
---|
| 40 | void ply_describe_element( |
---|
| 41 | PlyFile *plyfile, |
---|
| 42 | char *elem_name, |
---|
| 43 | int nelems, |
---|
| 44 | int nprops, |
---|
| 45 | PlyProperty *prop_list |
---|
| 46 | ) |
---|
| 47 | |
---|
| 48 | /****************************************************************************** |
---|
| 49 | Signal that we've described everything a PLY file's header and that the |
---|
| 50 | header should be written to the file. |
---|
| 51 | |
---|
| 52 | Entry: |
---|
| 53 | plyfile - file identifier |
---|
| 54 | ******************************************************************************/ |
---|
| 55 | |
---|
| 56 | void ply_header_complete(PlyFile *plyfile) |
---|
| 57 | |
---|
| 58 | /****************************************************************************** |
---|
| 59 | Specify which elements are going to be written. This should be called |
---|
| 60 | before a call to the routine ply_put_elements(). |
---|
| 61 | |
---|
| 62 | Entry: |
---|
| 63 | plyfile - file identifier |
---|
| 64 | elem_name - name of element we're talking about |
---|
| 65 | ******************************************************************************/ |
---|
| 66 | |
---|
| 67 | void ply_put_elements_setup(PlyFile *plyfile, char *elem_name) |
---|
| 68 | |
---|
| 69 | /****************************************************************************** |
---|
| 70 | Write an element to the file. This routine assumes that we're |
---|
| 71 | writing the type of element specified in the last call to the routine |
---|
| 72 | ply_put_element_setup(). |
---|
| 73 | |
---|
| 74 | Entry: |
---|
| 75 | plyfile - file identifier |
---|
| 76 | elem_ptr - pointer to the element |
---|
| 77 | ******************************************************************************/ |
---|
| 78 | |
---|
| 79 | void ply_put_element(PlyFile *plyfile, void *elem_ptr) |
---|
| 80 | |
---|
| 81 | /****************************************************************************** |
---|
| 82 | Specify a comment that will be written in the header. |
---|
| 83 | |
---|
| 84 | Entry: |
---|
| 85 | plyfile - file identifier |
---|
| 86 | comment - the comment to be written |
---|
| 87 | ******************************************************************************/ |
---|
| 88 | |
---|
| 89 | void ply_put_comment(PlyFile *plyfile, char *comment) |
---|
| 90 | |
---|
| 91 | /****************************************************************************** |
---|
| 92 | Specify a piece of object information (arbitrary text) that will be written |
---|
| 93 | in the header. |
---|
| 94 | |
---|
| 95 | Entry: |
---|
| 96 | plyfile - file identifier |
---|
| 97 | obj_info - the text information to be written |
---|
| 98 | ******************************************************************************/ |
---|
| 99 | |
---|
| 100 | void ply_put_obj_info(PlyFile *plyfile, char *obj_info) |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | /*************/ |
---|
| 106 | /* Reading */ |
---|
| 107 | /*************/ |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | /****************************************************************************** |
---|
| 112 | Open a polygon file for reading. |
---|
| 113 | |
---|
| 114 | Entry: |
---|
| 115 | filename - name of file to read from |
---|
| 116 | |
---|
| 117 | Exit: |
---|
| 118 | nelems - number of elements in object |
---|
| 119 | elem_names - list of element names |
---|
| 120 | file_type - file type, either ascii or binary |
---|
| 121 | version - version number of PLY file |
---|
| 122 | returns a file identifier, used to refer to this file, or NULL if error |
---|
| 123 | ******************************************************************************/ |
---|
| 124 | |
---|
| 125 | PlyFile *ply_open_for_reading( |
---|
| 126 | char *filename, |
---|
| 127 | int *nelems, |
---|
| 128 | char ***elem_names, |
---|
| 129 | int *file_type, |
---|
| 130 | float *version |
---|
| 131 | ) |
---|
| 132 | |
---|
| 133 | /****************************************************************************** |
---|
| 134 | Get information about a particular element. |
---|
| 135 | |
---|
| 136 | Entry: |
---|
| 137 | plyfile - file identifier |
---|
| 138 | elem_name - name of element to get information about |
---|
| 139 | |
---|
| 140 | Exit: |
---|
| 141 | nelems - number of elements of this type in the file |
---|
| 142 | nprops - number of properties |
---|
| 143 | returns a list of properties |
---|
| 144 | ******************************************************************************/ |
---|
| 145 | |
---|
| 146 | PlyProperty **ply_get_element_description( |
---|
| 147 | PlyFile *plyfile, |
---|
| 148 | char *elem_name, |
---|
| 149 | int *nelems, |
---|
| 150 | int *nprops |
---|
| 151 | ) |
---|
| 152 | |
---|
| 153 | /****************************************************************************** |
---|
| 154 | Specify which properties of an element are to be returned. This should be |
---|
| 155 | called before a call to the routine ply_get_elements(). |
---|
| 156 | |
---|
| 157 | Entry: |
---|
| 158 | plyfile - file identifier |
---|
| 159 | elem_name - which element we're talking about |
---|
| 160 | nprops - number of properties |
---|
| 161 | prop_list - list of properties |
---|
| 162 | ******************************************************************************/ |
---|
| 163 | |
---|
| 164 | void ply_get_element_setup( |
---|
| 165 | PlyFile *plyfile, |
---|
| 166 | char *elem_name, |
---|
| 167 | int nprops, |
---|
| 168 | PlyProperty *prop_list |
---|
| 169 | ) |
---|
| 170 | |
---|
| 171 | /****************************************************************************** |
---|
| 172 | Read one element from the file. This routine assumes that we're reading |
---|
| 173 | the type of element specified in the last call to the routine |
---|
| 174 | ply_get_element_setup(). |
---|
| 175 | |
---|
| 176 | Entry: |
---|
| 177 | plyfile - file identifier |
---|
| 178 | elem_ptr - pointer to location where the element information should be put |
---|
| 179 | ******************************************************************************/ |
---|
| 180 | |
---|
| 181 | ply_get_element(PlyFile *plyfile, void *elem_ptr) |
---|
| 182 | |
---|
| 183 | /****************************************************************************** |
---|
| 184 | Extract the comments from the header information of a PLY file. |
---|
| 185 | |
---|
| 186 | Entry: |
---|
| 187 | plyfile - file identifier |
---|
| 188 | |
---|
| 189 | Exit: |
---|
| 190 | num_comments - number of comments returned |
---|
| 191 | returns a pointer to a list of comments |
---|
| 192 | ******************************************************************************/ |
---|
| 193 | |
---|
| 194 | char **ply_get_comments(PlyFile *plyfile, int *num_comments) |
---|
| 195 | |
---|
| 196 | /****************************************************************************** |
---|
| 197 | Extract the object information (arbitrary text) from the header information |
---|
| 198 | of a PLY file. |
---|
| 199 | |
---|
| 200 | Entry: |
---|
| 201 | plyfile - file identifier |
---|
| 202 | |
---|
| 203 | Exit: |
---|
| 204 | num_obj_info - number of lines of text information returned |
---|
| 205 | returns a pointer to a list of object info lines |
---|
| 206 | ******************************************************************************/ |
---|
| 207 | |
---|
| 208 | char **ply_get_obj_info(PlyFile *plyfile, int *num_obj_info) |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | /*******************/ |
---|
| 213 | /* Miscellaneous */ |
---|
| 214 | /*******************/ |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | /****************************************************************************** |
---|
| 219 | Close a PLY file. |
---|
| 220 | |
---|
| 221 | Entry: |
---|
| 222 | plyfile - identifier of file to close |
---|
| 223 | ******************************************************************************/ |
---|
| 224 | |
---|
| 225 | void ply_close(PlyFile *plyfile) |
---|
| 226 | |
---|
| 227 | /****************************************************************************** |
---|
| 228 | Compare two strings. Returns 1 if they are the same, 0 if not. |
---|
| 229 | ******************************************************************************/ |
---|
| 230 | |
---|
| 231 | int equal_strings(char *s1, char *s2) |
---|
| 232 | |
---|