root/OpenSceneGraph/trunk/src/osgPlugins/ply/ply.h @ 10079

Revision 10079, 6.8 kB (checked in by robert, 6 years ago)

Warning fixes

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