00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00097 #ifndef __vtkPLY_h
00098 #define __vtkPLY_h
00099
00100 #include <stdio.h>
00101 #include <stddef.h>
00102 #include "vtkObject.h"
00103
00104 #define PLY_ASCII 1
00105 #define PLY_BINARY_BE 2
00106 #define PLY_BINARY_LE 3
00107
00108 #define PLY_OKAY 0
00109 #define PLY_ERROR -1
00110
00111
00112
00113 #define PLY_START_TYPE 0
00114 #define PLY_CHAR 1
00115 #define PLY_SHORT 2
00116 #define PLY_INT 3
00117 #define PLY_UCHAR 4
00118 #define PLY_USHORT 5
00119 #define PLY_UINT 6
00120 #define PLY_FLOAT 7
00121 #define PLY_DOUBLE 8
00122 #define PLY_END_TYPE 9
00123
00124 #define PLY_SCALAR 0
00125 #define PLY_LIST 1
00126
00127 typedef struct PlyProperty {
00128
00129 const char *name;
00130 int external_type;
00131 int internal_type;
00132 int offset;
00133
00134 int is_list;
00135 int count_external;
00136 int count_internal;
00137 int count_offset;
00138
00139 } PlyProperty;
00140
00141 typedef struct PlyElement {
00142 char *name;
00143 int num;
00144 int size;
00145 int nprops;
00146 PlyProperty **props;
00147 char *store_prop;
00148 int other_offset;
00149 int other_size;
00150 } PlyElement;
00151
00152 typedef struct PlyOtherProp {
00153 char *name;
00154 int size;
00155 int nprops;
00156 PlyProperty **props;
00157 } PlyOtherProp;
00158
00159 typedef struct OtherData {
00160 void *other_props;
00161 } OtherData;
00162
00163 typedef struct OtherElem {
00164 char *elem_name;
00165 int elem_count;
00166 OtherData **other_data;
00167 PlyOtherProp *other_props;
00168 } OtherElem;
00169
00170 typedef struct PlyOtherElems {
00171 int num_elems;
00172 OtherElem *other_list;
00173 } PlyOtherElems;
00174
00175 typedef struct PlyFile {
00176 FILE *fp;
00177 int file_type;
00178 float version;
00179 int nelems;
00180 PlyElement **elems;
00181 int num_comments;
00182 char **comments;
00183 int num_obj_info;
00184 char **obj_info;
00185 PlyElement *which_elem;
00186 PlyOtherElems *other_elems;
00187 } PlyFile;
00188
00189
00190 #define myalloc(mem_size) vtkPLY::my_alloc((mem_size), __LINE__, __FILE__)
00191
00192 class VTK_IO_EXPORT vtkPLY
00193 {
00194 public:
00195
00196 static PlyFile *ply_write(FILE *, int, const char **, int);
00197 static PlyFile *ply_open_for_writing(char *, int, const char **, int, float *);
00198 static void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *);
00199 static void ply_describe_property(PlyFile *, char *, PlyProperty *);
00200 static void ply_element_count(PlyFile *, char *, int);
00201 static void ply_header_complete(PlyFile *);
00202 static void ply_put_element_setup(PlyFile *, char *);
00203 static void ply_put_element(PlyFile *, void *);
00204 static void ply_put_comment(PlyFile *, char *);
00205 static void ply_put_obj_info(PlyFile *, char *);
00206 static PlyFile *ply_read(FILE *, int *, char ***);
00207 static PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *);
00208 static PlyElement *ply_get_element_description(PlyFile *, char *, int*, int*);
00209 static void ply_get_element_setup( PlyFile *, char *, int, PlyProperty *);
00210 static void ply_get_property(PlyFile *, char *, PlyProperty *);
00211 static PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
00212 static void ply_get_element(PlyFile *, void *);
00213 static char **ply_get_comments(PlyFile *, int *);
00214 static char **ply_get_obj_info(PlyFile *, int *);
00215 static void ply_close(PlyFile *);
00216 static void ply_get_info(PlyFile *, float *, int *);
00217 static PlyOtherElems *ply_get_other_element (PlyFile *, char *, int);
00218 static void ply_describe_other_elements ( PlyFile *, PlyOtherElems *);
00219 static void ply_put_other_elements (PlyFile *);
00220 static void ply_free_other_elements (PlyOtherElems *);
00221 static void ply_describe_other_properties(PlyFile *, PlyOtherProp *, int);
00222
00223
00224
00225 static int equal_strings(const char *, const char *);
00226 static PlyElement *find_element(PlyFile *, char *);
00227 static PlyProperty *find_property(PlyElement *, const char *, int *);
00228 static void write_scalar_type (FILE *, int);
00229 static char **get_words(FILE *, int *, char **);
00230 static char **old_get_words(FILE *, int *);
00231 static void write_binary_item(FILE *, int, unsigned int, double, int);
00232 static void write_ascii_item(FILE *, int, unsigned int, double, int);
00233 static double old_write_ascii_item(FILE *, char *, int);
00234 static void add_element(PlyFile *, char **, int);
00235 static void add_property(PlyFile *, char **, int);
00236 static void add_comment(PlyFile *, char *);
00237 static void add_obj_info(PlyFile *, char *);
00238 static void copy_property(PlyProperty *, PlyProperty *);
00239 static void store_item(char *, int, int, unsigned int, double);
00240 static void get_stored_item( void *, int, int *, unsigned int *, double *);
00241 static double get_item_value(char *, int);
00242 static void get_ascii_item(char *, int, int *, unsigned int *, double *);
00243 static void get_binary_item(FILE *, int, int *, unsigned int *, double *);
00244 static void ascii_get_element(PlyFile *, char *);
00245 static void binary_get_element(PlyFile *, char *);
00246 static char *my_alloc(int, int, char *);
00247 static int get_prop_type(char *);
00248
00249 };
00250
00251 #endif
00252
00253