337 |
jab |
1 |
/*
|
|
|
2 |
|
|
|
3 |
Header for PLY polygon files.
|
|
|
4 |
|
|
|
5 |
- Greg Turk
|
|
|
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) 1998 Georgia Institute of Technology. All rights reserved.
|
|
|
20 |
|
|
|
21 |
Permission to use, copy, modify and distribute this software and its
|
|
|
22 |
documentation for any purpose is hereby granted without fee, provided
|
|
|
23 |
that the above copyright notice and this permission notice appear in
|
|
|
24 |
all copies of this software and that you do not sell the software.
|
|
|
25 |
|
|
|
26 |
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
|
27 |
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
|
28 |
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
29 |
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
#ifndef __PLY_H__
|
|
|
33 |
#define __PLY_H__
|
|
|
34 |
|
|
|
35 |
#ifdef __cplusplus
|
|
|
36 |
extern "C" {
|
|
|
37 |
#endif
|
|
|
38 |
|
|
|
39 |
#include <stdio.h>
|
|
|
40 |
#include <stddef.h>
|
|
|
41 |
|
|
|
42 |
#define PLY_ASCII 1 /* ascii PLY file */
|
|
|
43 |
#define PLY_BINARY_BE 2 /* binary PLY file, big endian */
|
|
|
44 |
#define PLY_BINARY_LE 3 /* binary PLY file, little endian */
|
|
|
45 |
|
|
|
46 |
#define PLY_OKAY 0 /* ply routine worked okay */
|
|
|
47 |
#define PLY_ERROR -1 /* error in ply routine */
|
|
|
48 |
|
|
|
49 |
/* scalar data types supported by PLY format */
|
|
|
50 |
|
|
|
51 |
#define StartType 0
|
|
|
52 |
#define Int8 1
|
|
|
53 |
#define Int16 2
|
|
|
54 |
#define Int32 3
|
|
|
55 |
#define Uint8 4
|
|
|
56 |
#define Uint16 5
|
|
|
57 |
#define Uint32 6
|
|
|
58 |
#define Float32 7
|
|
|
59 |
#define Float64 8
|
|
|
60 |
#define EndType 9
|
|
|
61 |
|
|
|
62 |
#define PLY_SCALAR 0
|
|
|
63 |
#define PLY_LIST 1
|
|
|
64 |
#define PLY_STRING 2
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
typedef struct PlyProperty { /* description of a property */
|
|
|
68 |
|
|
|
69 |
char *name; /* property name */
|
|
|
70 |
int external_type; /* file's data type */
|
|
|
71 |
int internal_type; /* program's data type */
|
|
|
72 |
int offset; /* offset bytes of prop in a struct */
|
|
|
73 |
|
|
|
74 |
int is_list; /* 0 = scalar, 1 = list, 2 = char string */
|
|
|
75 |
int count_external; /* file's count type */
|
|
|
76 |
int count_internal; /* program's count type */
|
|
|
77 |
int count_offset; /* offset byte for list count */
|
|
|
78 |
|
|
|
79 |
} PlyProperty;
|
|
|
80 |
|
|
|
81 |
typedef struct PlyElement { /* description of an element */
|
|
|
82 |
char *name; /* element name */
|
|
|
83 |
int num; /* number of elements in this object */
|
|
|
84 |
int size; /* size of element (bytes) or -1 if variable */
|
|
|
85 |
int nprops; /* number of properties for this element */
|
|
|
86 |
PlyProperty **props; /* list of properties in the file */
|
|
|
87 |
char *store_prop; /* flags: property wanted by user? */
|
|
|
88 |
int other_offset; /* offset to un-asked-for props, or -1 if none*/
|
|
|
89 |
int other_size; /* size of other_props structure */
|
|
|
90 |
} PlyElement;
|
|
|
91 |
|
|
|
92 |
typedef struct PlyOtherProp { /* describes other properties in an element */
|
|
|
93 |
char *name; /* element name */
|
|
|
94 |
int size; /* size of other_props */
|
|
|
95 |
int nprops; /* number of properties in other_props */
|
|
|
96 |
PlyProperty **props; /* list of properties in other_props */
|
|
|
97 |
} PlyOtherProp;
|
|
|
98 |
|
|
|
99 |
typedef struct OtherData { /* for storing other_props for an other element */
|
|
|
100 |
void *other_props;
|
|
|
101 |
} OtherData;
|
|
|
102 |
|
|
|
103 |
typedef struct OtherElem { /* data for one "other" element */
|
|
|
104 |
char *elem_name; /* names of other elements */
|
|
|
105 |
int elem_count; /* count of instances of each element */
|
|
|
106 |
OtherData **other_data; /* actual property data for the elements */
|
|
|
107 |
PlyOtherProp *other_props; /* description of the property data */
|
|
|
108 |
} OtherElem;
|
|
|
109 |
|
|
|
110 |
typedef struct PlyOtherElems { /* "other" elements, not interpreted by user */
|
|
|
111 |
int num_elems; /* number of other elements */
|
|
|
112 |
OtherElem *other_list; /* list of data for other elements */
|
|
|
113 |
} PlyOtherElems;
|
|
|
114 |
|
|
|
115 |
#define AVERAGE_RULE 1
|
|
|
116 |
#define MAJORITY_RULE 2
|
|
|
117 |
#define MINIMUM_RULE 3
|
|
|
118 |
#define MAXIMUM_RULE 4
|
|
|
119 |
#define SAME_RULE 5
|
|
|
120 |
#define RANDOM_RULE 6
|
|
|
121 |
|
|
|
122 |
typedef struct PlyPropRules { /* rules for combining "other" properties */
|
|
|
123 |
PlyElement *elem; /* element whose rules we are making */
|
|
|
124 |
int *rule_list; /* types of rules (AVERAGE_PLY, MAJORITY_PLY, etc.) */
|
|
|
125 |
int nprops; /* number of properties we're combining so far */
|
|
|
126 |
int max_props; /* maximum number of properties we have room for now */
|
|
|
127 |
void **props; /* list of properties we're combining */
|
|
|
128 |
float *weights; /* list of weights of the properties */
|
|
|
129 |
} PlyPropRules;
|
|
|
130 |
|
|
|
131 |
typedef struct PlyRuleList {
|
|
|
132 |
char *name; /* name of the rule */
|
|
|
133 |
char *element; /* name of element that rule applies to */
|
|
|
134 |
char *property; /* name of property that rule applies to */
|
|
|
135 |
struct PlyRuleList *next; /* pointer for linked list of rules */
|
|
|
136 |
} PlyRuleList;
|
|
|
137 |
|
|
|
138 |
typedef struct PlyFile { /* description of PLY file */
|
|
|
139 |
FILE *fp; /* file pointer */
|
|
|
140 |
int file_type; /* ascii or binary */
|
|
|
141 |
float version; /* version number of file */
|
|
|
142 |
int num_elem_types; /* number of element types of object */
|
|
|
143 |
PlyElement **elems; /* list of elements */
|
|
|
144 |
int num_comments; /* number of comments */
|
|
|
145 |
char **comments; /* list of comments */
|
|
|
146 |
int num_obj_info; /* number of items of object information */
|
|
|
147 |
char **obj_info; /* list of object info items */
|
|
|
148 |
PlyElement *which_elem; /* element we're currently reading or writing */
|
|
|
149 |
PlyOtherElems *other_elems; /* "other" elements from a PLY file */
|
|
|
150 |
PlyPropRules *current_rules; /* current propagation rules */
|
|
|
151 |
PlyRuleList *rule_list; /* rule list from user */
|
|
|
152 |
} PlyFile;
|
|
|
153 |
|
|
|
154 |
/* memory allocation */
|
|
|
155 |
/*
|
|
|
156 |
extern char *my_alloc();
|
|
|
157 |
*/
|
|
|
158 |
#define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__)
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
/* old routines */
|
|
|
162 |
|
|
|
163 |
#if 0
|
|
|
164 |
extern PlyFile *ply_write(FILE *, int, char **, int);
|
|
|
165 |
extern PlyFile *ply_read(FILE *, int *, char ***);
|
|
|
166 |
extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *);
|
|
|
167 |
extern void ply_close(PlyFile *);
|
|
|
168 |
extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
|
|
|
169 |
#endif
|
|
|
170 |
|
|
|
171 |
extern void ply_describe_property(PlyFile *, char *, PlyProperty *);
|
|
|
172 |
extern void ply_get_property(PlyFile *, char *, PlyProperty *);
|
|
|
173 |
extern void ply_get_element(PlyFile *, void *);
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
/*** delcaration of routines ***/
|
|
|
177 |
|
|
|
178 |
PlyOtherElems *get_other_element_ply (PlyFile *);
|
|
|
179 |
|
|
|
180 |
PlyFile *read_ply(FILE *);
|
|
|
181 |
PlyFile *write_ply(FILE *, int, char **, int);
|
|
|
182 |
extern PlyFile *open_for_writing_ply(char *, int, char **, int);
|
|
|
183 |
void close_ply(PlyFile *);
|
|
|
184 |
void free_ply(PlyFile *);
|
|
|
185 |
|
|
|
186 |
void get_info_ply(PlyFile *, float *, int *);
|
|
|
187 |
void free_other_elements_ply (PlyOtherElems *);
|
|
|
188 |
|
|
|
189 |
void append_comment_ply(PlyFile *, char *);
|
|
|
190 |
void append_obj_info_ply(PlyFile *, char *);
|
|
|
191 |
void copy_comments_ply(PlyFile *, PlyFile *);
|
|
|
192 |
void copy_obj_info_ply(PlyFile *, PlyFile *);
|
|
|
193 |
char **get_comments_ply(PlyFile *, int *);
|
|
|
194 |
char **get_obj_info_ply(PlyFile *, int *);
|
|
|
195 |
|
|
|
196 |
char **get_element_list_ply(PlyFile *, int *);
|
|
|
197 |
void setup_property_ply(PlyFile *, PlyProperty *);
|
|
|
198 |
void get_element_ply (PlyFile *, void *);
|
|
|
199 |
char *setup_element_read_ply (PlyFile *, int, int *);
|
|
|
200 |
PlyOtherProp *get_other_properties_ply(PlyFile *, int);
|
|
|
201 |
|
|
|
202 |
void element_count_ply(PlyFile *, char *, int);
|
|
|
203 |
void describe_element_ply(PlyFile *, char *, int);
|
|
|
204 |
void describe_property_ply(PlyFile *, PlyProperty *);
|
|
|
205 |
void describe_other_properties_ply(PlyFile *, PlyOtherProp *, int);
|
|
|
206 |
void describe_other_elements_ply ( PlyFile *, PlyOtherElems *);
|
|
|
207 |
void get_element_setup_ply(PlyFile *, char *, int, PlyProperty *);
|
|
|
208 |
PlyProperty **get_element_description_ply(PlyFile *, char *, int*, int*);
|
|
|
209 |
void element_layout_ply(PlyFile *, char *, int, int, PlyProperty *);
|
|
|
210 |
|
|
|
211 |
void header_complete_ply(PlyFile *);
|
|
|
212 |
void put_element_setup_ply(PlyFile *, char *);
|
|
|
213 |
void put_element_ply(PlyFile *, void *);
|
|
|
214 |
void put_other_elements_ply(PlyFile *);
|
|
|
215 |
|
|
|
216 |
PlyPropRules *init_rule_ply (PlyFile *, char *);
|
|
|
217 |
void modify_rule_ply (PlyPropRules *, char *, int);
|
|
|
218 |
void start_props_ply (PlyFile *, PlyPropRules *);
|
|
|
219 |
void weight_props_ply (PlyFile *, float, void *);
|
|
|
220 |
void *get_new_props_ply(PlyFile *);
|
|
|
221 |
void set_prop_rules_ply (PlyFile *, PlyRuleList *);
|
|
|
222 |
PlyRuleList *append_prop_rule (PlyRuleList *, char *, char *);
|
|
|
223 |
int matches_rule_name (char *);
|
|
|
224 |
|
|
|
225 |
int equal_strings(char *, char *);
|
|
|
226 |
char *recreate_command_line (int, char *argv[]);
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
#ifdef __cplusplus
|
|
|
230 |
}
|
|
|
231 |
#endif
|
|
|
232 |
#endif /* !__PLY_H__ */
|
|
|
233 |
|