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

Revision 10014, 6.7 kB (checked in by robert, 5 years ago)

From Santosh Gaikwad, 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
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#include <stdio.h>
41#include <stddef.h>
42
43#define PLY_ASCII      1        /* ascii PLY file */
44#define PLY_BINARY_BE  2        /* binary PLY file, big endian */
45#define PLY_BINARY_LE  3        /* binary PLY file, little endian */
46
47#define PLY_OKAY    0           /* ply routine worked okay */
48#define PLY_ERROR  -1           /* error in ply routine */
49
50/* scalar data types supported by PLY format */
51
52#define PLY_START_TYPE 0
53#define PLY_CHAR       1
54#define PLY_SHORT      2
55#define PLY_INT        3
56#define PLY_UCHAR      4
57#define PLY_USHORT     5
58#define PLY_UINT       6
59#define PLY_FLOAT      7
60#define PLY_DOUBLE     8
61#define PLY_FLOAT32    9
62#define PLY_UINT8      10
63#define PLY_INT32      11
64#define PLY_END_TYPE   12
65
66#define  PLY_SCALAR  0
67#define  PLY_LIST    1
68
69
70typedef struct PlyProperty {    /* description of a property */
71
[10014]72  const char *name;                           /* property name */
[10012]73  int external_type;                    /* file's data type */
74  int internal_type;                    /* program's data type */
75  int offset;                           /* offset bytes of prop in a struct */
76
77  int is_list;                          /* 1 = list, 0 = scalar */
78  int count_external;                   /* file's count type */
79  int count_internal;                   /* program's count type */
80  int count_offset;                     /* offset byte for list count */
81
82} PlyProperty;
83
84typedef struct PlyElement {     /* description of an element */
85  char *name;                   /* element name */
86  int num;                      /* number of elements in this object */
87  int size;                     /* size of element (bytes) or -1 if variable */
88  int nprops;                   /* number of properties for this element */
89  PlyProperty **props;          /* list of properties in the file */
90  char *store_prop;             /* flags: property wanted by user? */
91  int other_offset;             /* offset to un-asked-for props, or -1 if none*/
92  int other_size;               /* size of other_props structure */
93} PlyElement;
94
95typedef struct PlyOtherProp {   /* describes other properties in an element */
96  char *name;                   /* element name */
97  int size;                     /* size of other_props */
98  int nprops;                   /* number of properties in other_props */
99  PlyProperty **props;          /* list of properties in other_props */
100} PlyOtherProp;
101
102typedef struct OtherData { /* for storing other_props for an other element */
103  void *other_props;
104} OtherData;
105
106typedef struct OtherElem {     /* data for one "other" element */
107  char *elem_name;             /* names of other elements */
108  int elem_count;              /* count of instances of each element */
109  OtherData **other_data;      /* actual property data for the elements */
110  PlyOtherProp *other_props;   /* description of the property data */
111} OtherElem;
112
113typedef struct PlyOtherElems {  /* "other" elements, not interpreted by user */
114  int num_elems;                /* number of other elements */
115  OtherElem *other_list;        /* list of data for other elements */
116} PlyOtherElems;
117
118typedef struct PlyFile {        /* description of PLY file */
119  FILE *fp;                     /* file pointer */
120  int file_type;                /* ascii or binary */
121  float version;                /* version number of file */
122  int nelems;                   /* number of elements of object */
123  PlyElement **elems;           /* list of elements */
124  int num_comments;             /* number of comments */
125  char **comments;              /* list of comments */
126  int num_obj_info;             /* number of items of object information */
127  char **obj_info;              /* list of object info items */
128  PlyElement *which_elem;       /* which element we're currently writing */
129  PlyOtherElems *other_elems;   /* "other" elements from a PLY file */
130} PlyFile;
131
132/* memory allocation */
133extern char *my_alloc();
134#define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__)
135
136
137/*** delcaration of routines ***/
138
139extern PlyFile *ply_write(FILE *, int, char **, int);
140extern PlyFile *ply_open_for_writing(char *, int, char **, int, float *);
141extern void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *);
142extern void ply_describe_property(PlyFile *, char *, PlyProperty *);
143extern void ply_element_count(PlyFile *, const char *, int);
144extern void ply_header_complete(PlyFile *);
145extern void ply_put_element_setup(PlyFile *, const char *);
146extern void ply_put_element(PlyFile *, void *);
147extern void ply_put_comment(PlyFile *, const char *);
148extern void ply_put_obj_info(PlyFile *, const char *);
149extern PlyFile *ply_read(FILE *, int *, char ***);
150extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *);
151extern PlyProperty **ply_get_element_description(PlyFile *, char *, int*, int*);
152extern void ply_get_element_setup( PlyFile *, char *, int, PlyProperty *);
[10014]153extern void ply_get_property(PlyFile *, const char *, PlyProperty *);
[10012]154extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
155extern void ply_get_element(PlyFile *, void *);
156extern char **ply_get_comments(PlyFile *, int *);
157extern char **ply_get_obj_info(PlyFile *, int *);
158extern void ply_close(PlyFile *);
159extern void ply_get_info(PlyFile *, float *, int *);
160extern PlyOtherElems *ply_get_other_element (PlyFile *, char *, int);
161extern void ply_describe_other_elements ( PlyFile *, PlyOtherElems *);
162extern void ply_put_other_elements (PlyFile *);
163extern void ply_free_other_elements (PlyOtherElems *);
164
165extern int equal_strings(const char *, const char *);
166
167
168#ifdef __cplusplus
169}
170#endif
171#endif /* !__PLY_H__ */
Note: See TracBrowser for help on using the browser.