root/OpenSceneGraph/branches/OpenSceneGraph-2.8/src/osgPlugins/ply/ply.h @ 11274

Revision 11274, 6.7 kB (checked in by paulmartz, 5 years ago)

2.8 branch: Hm, mysteriously, the ply plugin seems to be missing changes that were previously merged. This commit brings them up to date with svn trunk as of r11237.

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