Equalizer  1.6.1
seqPly/ply.h
1 /*
2 
3 Header for PLY polygon files.
4 
5 - Greg Turk, March 1994
6 
7 A PLY file contains a single polygonal _object_.
8 
9 An object is composed of lists of _elements_. Typical elements are
10 vertices, faces, edges and materials.
11 
12 Each type of element for a given object has one or more _properties_
13 associated with the element type. For instance, a vertex element may
14 have as properties three floating-point values x,y,z and three unsigned
15 chars for red, green and blue.
16 
17 ---------------------------------------------------------------
18 
19 Copyright (c) 1994 The Board of Trustees of The Leland Stanford
20 Junior University. All rights reserved.
21 
22 Permission to use, copy, modify and distribute this software and its
23 documentation for any purpose is hereby granted without fee, provided
24 that the above copyright notice and this permission notice appear in
25 all copies of this software and that you do not sell the software.
26 
27 THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
28 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
29 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
30 
31 */
32 
33 #ifndef __PLY_H__
34 #define __PLY_H__
35 
36 #include <eq/eq.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #include <stdio.h>
43 #include <stddef.h>
44 
45 #define PLY_ASCII 1 /* ascii PLY file */
46 #define PLY_BINARY_BE 2 /* binary PLY file, big endian */
47 #define PLY_BINARY_LE 3 /* binary PLY file, little endian */
48 
49 #define PLY_OKAY 0 /* ply routine worked okay */
50 #define PLY_ERROR -1 /* error in ply routine */
51 
52 /* scalar data types supported by PLY format */
53 
54 #define PLY_START_TYPE 0
55 #define PLY_CHAR 1
56 #define PLY_SHORT 2
57 #define PLY_INT 3
58 #define PLY_UCHAR 4
59 #define PLY_USHORT 5
60 #define PLY_UINT 6
61 #define PLY_FLOAT 7
62 #define PLY_DOUBLE 8
63 #define PLY_FLOAT32 9
64 #define PLY_UINT8 10
65 #define PLY_INT32 11
66 #define PLY_END_TYPE 12
67 
68 #define PLY_SCALAR 0
69 #define PLY_LIST 1
70 
71 
72 typedef struct PlyProperty { /* description of a property */
73 
74  const char *name; /* property name */
75  int external_type; /* file's data type */
76  int internal_type; /* program's data type */
77  int offset; /* offset bytes of prop in a struct */
78 
79  int is_list; /* 1 = list, 0 = scalar */
80  int count_external; /* file's count type */
81  int count_internal; /* program's count type */
82  int count_offset; /* offset byte for list count */
83 
84 } PlyProperty;
85 
86 typedef struct PlyElement { /* description of an element */
87  char *name; /* element name */
88  int num; /* number of elements in this object */
89  int size; /* size of element (bytes) or -1 if variable */
90  int nprops; /* number of properties for this element */
91  PlyProperty **props; /* list of properties in the file */
92  char *store_prop; /* flags: property wanted by user? */
93  int other_offset; /* offset to un-asked-for props, or -1 if none*/
94  int other_size; /* size of other_props structure */
95 } PlyElement;
96 
97 typedef struct PlyOtherProp { /* describes other properties in an element */
98  char *name; /* element name */
99  int size; /* size of other_props */
100  int nprops; /* number of properties in other_props */
101  PlyProperty **props; /* list of properties in other_props */
102 } PlyOtherProp;
103 
104 typedef struct OtherData { /* for storing other_props for an other element */
105  void *other_props;
106 } OtherData;
107 
108 typedef struct OtherElem { /* data for one "other" element */
109  char *elem_name; /* names of other elements */
110  int elem_count; /* count of instances of each element */
111  OtherData **other_data; /* actual property data for the elements */
112  PlyOtherProp *other_props; /* description of the property data */
113 } OtherElem;
114 
115 typedef struct PlyOtherElems { /* "other" elements, not interpreted by user */
116  int num_elems; /* number of other elements */
117  OtherElem *other_list; /* list of data for other elements */
118 } PlyOtherElems;
119 
120 typedef struct PlyFile { /* description of PLY file */
121  FILE *fp; /* file pointer */
122  int file_type; /* ascii or binary */
123  float version; /* version number of file */
124  int nelems; /* number of elements of object */
125  PlyElement **elems; /* list of elements */
126  int num_comments; /* number of comments */
127  char **comments; /* list of comments */
128  int num_obj_info; /* number of items of object information */
129  char **obj_info; /* list of object info items */
130  PlyElement *which_elem; /* which element we're currently writing */
131  PlyOtherElems *other_elems; /* "other" elements from a PLY file */
132 } PlyFile;
133 
134 /* memory allocation */
135 extern char *my_alloc();
136 #define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__)
137 
138 
139 /*** delcaration of routines ***/
140 
141 extern PlyFile *ply_write(FILE *, int, char **, int);
142 extern PlyFile *ply_open_for_writing(char *, int, char **, int, float *);
143 extern void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *);
144 extern void ply_describe_property(PlyFile *, char *, PlyProperty *);
145 extern void ply_element_count(PlyFile *, const char *, int);
146 extern void ply_header_complete(PlyFile *);
147 extern void ply_put_element_setup(PlyFile *, const char *);
148 extern void ply_put_element(PlyFile *, void *);
149 extern void ply_put_comment(PlyFile *, const char *);
150 extern void ply_put_obj_info(PlyFile *, const char *);
151 extern PlyFile *ply_read(FILE *, int *, char ***);
152 extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *);
153 extern PlyProperty **ply_get_element_description(PlyFile *, char *, int*, int*);
154 extern void ply_get_element_setup( PlyFile *, char *, int, PlyProperty *);
155 extern void ply_get_property(PlyFile *, const char *, PlyProperty *);
156 extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
157 extern void ply_get_element(PlyFile *, void *);
158 extern char **ply_get_comments(PlyFile *, int *);
159 extern char **ply_get_obj_info(PlyFile *, int *);
160 extern void ply_close(PlyFile *);
161 extern void ply_get_info(PlyFile *, float *, int *);
162 extern PlyOtherElems *ply_get_other_element (PlyFile *, char *, int);
163 extern void ply_describe_other_elements ( PlyFile *, PlyOtherElems *);
164 extern void ply_put_other_elements (PlyFile *);
165 extern void ply_free_other_elements (PlyOtherElems *);
166 
167 extern int equal_strings(const char *, const char *);
168 
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 #endif /* !__PLY_H__ */
174