opensurgsim
ply.h
1 /* Copyright (c) 1994 The Board of Trustees of The Leland Stanford
2 Junior University. All rights reserved.
3 
4 Header for PLY polygon files.
5 
6 - Greg Turk, March 1994
7 
8 A PLY file contains a single polygonal _object_.
9 
10 An object is composed of lists of _elements_. Typical elements are
11 vertices, faces, edges and materials.
12 
13 Each type of element for a given object has one or more _properties_
14 associated with the element type. For instance, a vertex element may
15 have as properties three floating-point values x,y,z and three unsigned
16 chars for red, green and blue.
17 
18 ---------------------------------------------------------------
19 
20 Copyright (c) 1994 The Board of Trustees of The Leland Stanford
21 Junior University. All rights reserved.
22 
23 Permission to use, copy, modify and distribute this software and its
24 documentation for any purpose is hereby granted without fee, provided
25 that the above copyright notice and this permission notice appear in
26 all copies of this software and that you do not sell the software.
27 
28 THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
29 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
30 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
31 
32 */
33 
34 #ifndef SURGSIM_DATASTRUCTURES_PLY_H
35 #define SURGSIM_DATASTRUCTURES_PLY_H
36 
37 #ifdef __cplusplus
38 #include <cstddef>
39 
40 namespace SurgSim {
41 namespace DataStructures {
42 extern "C" {
43 #endif
44 
45 #include <stdio.h>
46 #include <stddef.h>
47 
48 #define PLY_ASCII 1 /* ascii PLY file */
49 #define PLY_BINARY_BE 2 /* binary PLY file, big endian */
50 #define PLY_BINARY_LE 3 /* binary PLY file, little endian */
51 
52 #define PLY_OKAY 0 /* ply routine worked okay */
53 #define PLY_ERROR -1 /* error in ply routine */
54 
55 /* scalar data types supported by PLY format */
56 
57 #define PLY_START_TYPE 0
58 #define PLY_CHAR 1
59 #define PLY_SHORT 2
60 #define PLY_INT 3
61 #define PLY_UCHAR 4
62 #define PLY_USHORT 5
63 #define PLY_UINT 6
64 #define PLY_FLOAT 7
65 #define PLY_DOUBLE 8
66 #define PLY_END_TYPE 9
67 
68 #define PLY_SCALAR 0
69 #define PLY_LIST 1
70 
71 
72 typedef struct PlyProperty { /* description of a property */
73 
74  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(const 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 *, char *, int);
146 extern void ply_header_complete(PlyFile * plyfile);
147 extern void ply_put_element_setup(PlyFile *, char *);
148 extern void ply_put_element(PlyFile *, void *);
149 extern void ply_put_comment(PlyFile *, char *);
150 extern void ply_put_obj_info(PlyFile *, char *);
151 extern PlyFile *ply_read(FILE *, int *, char ***);
152 extern PlyFile *ply_open_for_reading(const 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 *, 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 * 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 *plyfile);
165 extern void ply_free_other_elements (PlyOtherElems *elements);
166 
167 extern int equal_strings(const char *,const char *);
168 
169 /* find an element in a plyfile's list */
170 PlyElement *find_element(PlyFile *, const char *);
171 
172 /* find a property in an element's list */
173 PlyProperty *find_property(PlyElement *, const char *, int *);
174 
175 
176 #ifdef __cplusplus
177 }
178 }
179 }
180 #endif
181 
182 #endif
183 
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Definition: ply.h:115
Definition: ply.h:97
Definition: ply.h:104
Definition: ply.h:86
Definition: ply.h:108
Definition: ply.h:120
Definition: ply.h:72