ply.h
Go to the documentation of this file.
/* Copyright (c) 1994 The Board of Trustees of The Leland Stanford
Junior University. All rights reserved.
Header for PLY polygon files.
- Greg Turk, March 1994
A PLY file contains a single polygonal _object_.
An object is composed of lists of _elements_. Typical elements are
vertices, faces, edges and materials.
Each type of element for a given object has one or more _properties_
associated with the element type. For instance, a vertex element may
have as properties three floating-point values x,y,z and three unsigned
chars for red, green and blue.
---------------------------------------------------------------
Copyright (c) 1994 The Board of Trustees of The Leland Stanford
Junior University. All rights reserved.
Permission to use, copy, modify and distribute this software and its
documentation for any purpose is hereby granted without fee, provided
that the above copyright notice and this permission notice appear in
all copies of this software and that you do not sell the software.
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef SURGSIM_DATASTRUCTURES_PLY_H
#define SURGSIM_DATASTRUCTURES_PLY_H
#ifdef __cplusplus
#include <cstddef>
namespace SurgSim {
namespace DataStructures {
extern "C" {
#endif
#include <stdio.h>
#include <stddef.h>
#define PLY_ASCII 1 /* ascii PLY file */
#define PLY_BINARY_BE 2 /* binary PLY file, big endian */
#define PLY_BINARY_LE 3 /* binary PLY file, little endian */
#define PLY_OKAY 0 /* ply routine worked okay */
#define PLY_ERROR -1 /* error in ply routine */
/* scalar data types supported by PLY format */
#define PLY_START_TYPE 0
#define PLY_CHAR 1
#define PLY_SHORT 2
#define PLY_INT 3
#define PLY_UCHAR 4
#define PLY_USHORT 5
#define PLY_UINT 6
#define PLY_FLOAT 7
#define PLY_DOUBLE 8
#define PLY_END_TYPE 9
#define PLY_SCALAR 0
#define PLY_LIST 1
typedef struct PlyProperty { /* description of a property */
char *name; /* property name */
int external_type; /* file's data type */
int internal_type; /* program's data type */
int offset; /* offset bytes of prop in a struct */
int is_list; /* 1 = list, 0 = scalar */
int count_external; /* file's count type */
int count_internal; /* program's count type */
int count_offset; /* offset byte for list count */
} PlyProperty;
typedef struct PlyElement { /* description of an element */
char *name; /* element name */
int num; /* number of elements in this object */
int size; /* size of element (bytes) or -1 if variable */
int nprops; /* number of properties for this element */
PlyProperty **props; /* list of properties in the file */
char *store_prop; /* flags: property wanted by user? */
int other_offset; /* offset to un-asked-for props, or -1 if none*/
int other_size; /* size of other_props structure */
} PlyElement;
typedef struct PlyOtherProp { /* describes other properties in an element */
char *name; /* element name */
int size; /* size of other_props */
int nprops; /* number of properties in other_props */
PlyProperty **props; /* list of properties in other_props */
} PlyOtherProp;
typedef struct OtherData { /* for storing other_props for an other element */
void *other_props;
} OtherData;
typedef struct OtherElem { /* data for one "other" element */
char *elem_name; /* names of other elements */
int elem_count; /* count of instances of each element */
OtherData **other_data; /* actual property data for the elements */
PlyOtherProp *other_props; /* description of the property data */
} OtherElem;
typedef struct PlyOtherElems { /* "other" elements, not interpreted by user */
int num_elems; /* number of other elements */
OtherElem *other_list; /* list of data for other elements */
} PlyOtherElems;
typedef struct PlyFile { /* description of PLY file */
FILE *fp; /* file pointer */
int file_type; /* ascii or binary */
float version; /* version number of file */
int nelems; /* number of elements of object */
PlyElement **elems; /* list of elements */
int num_comments; /* number of comments */
char **comments; /* list of comments */
int num_obj_info; /* number of items of object information */
char **obj_info; /* list of object info items */
PlyElement *which_elem; /* which element we're currently writing */
PlyOtherElems *other_elems; /* "other" elements from a PLY file */
} PlyFile;
/* memory allocation */
extern char *my_alloc();
#define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__)
/*** delcaration of routines ***/
extern PlyFile *ply_write(FILE *, int, char **, int);
extern PlyFile *ply_open_for_writing(const char *, int, char **, int, float *);
extern void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *);
extern void ply_describe_property(PlyFile *, char *, PlyProperty *);
extern void ply_element_count(PlyFile *, char *, int);
extern void ply_header_complete(PlyFile * plyfile);
extern void ply_put_element_setup(PlyFile *, char *);
extern void ply_put_element(PlyFile *, void *);
extern void ply_put_comment(PlyFile *, char *);
extern void ply_put_obj_info(PlyFile *, char *);
extern PlyFile *ply_read(FILE *, int *, char ***);
extern PlyFile *ply_open_for_reading(const char *, int *, char ***, int *, float *);
extern PlyProperty **ply_get_element_description(PlyFile *, char *, int*, int*);
extern void ply_get_element_setup( PlyFile *, char *, int, PlyProperty *);
extern void ply_get_property(PlyFile *, char *, PlyProperty *);
extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
extern void ply_get_element(PlyFile *, void *);
extern char **ply_get_comments(PlyFile *, int *);
extern char **ply_get_obj_info(PlyFile *, int *);
extern void ply_close(PlyFile * plyfile);
extern void ply_get_info(PlyFile *, float *, int *);
extern PlyOtherElems *ply_get_other_element (PlyFile *, char *, int);
extern void ply_describe_other_elements ( PlyFile *, PlyOtherElems *);
extern void ply_put_other_elements (PlyFile *plyfile);
extern void ply_free_other_elements (PlyOtherElems *elements);
extern int equal_strings(const char *,const char *);
/* find an element in a plyfile's list */
PlyElement *find_element(PlyFile *, const char *);
/* find a property in an element's list */
PlyProperty *find_property(PlyElement *, const char *, int *);
#ifdef __cplusplus
}
}
}
#endif
#endif
PlyFile::num_comments
int num_comments
Definition: ply.h:126
PlyOtherElems::other_list
OtherElem * other_list
Definition: ply.h:117
ply_header_complete
void ply_header_complete(PlyFile *plyfile)
Definition: ply.c:440
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
PlyFile
struct PlyFile PlyFile
PlyProperty::count_internal
int count_internal
Definition: ply.h:81
OtherData
struct OtherData OtherData
ply_get_other_element
PlyOtherElems * ply_get_other_element(PlyFile *, char *, int)
Definition: ply.c:1233
PlyOtherProp
struct PlyOtherProp PlyOtherProp
PlyFile::comments
char ** comments
Definition: ply.h:127
PlyElement::name
char * name
Definition: ply.h:87
OtherElem::elem_name
char * elem_name
Definition: ply.h:109
PlyFile::version
float version
Definition: ply.h:123
PlyElement::other_size
int other_size
Definition: ply.h:94
PlyOtherProp::name
char * name
Definition: ply.h:98
PlyProperty::name
char * name
Definition: ply.h:74
ply_put_comment
void ply_put_comment(PlyFile *, char *)
Definition: ply.c:650
PlyOtherElems
Definition: ply.h:115
equal_strings
int equal_strings(const char *, const char *)
Definition: ply.c:1476
ply_put_element_setup
void ply_put_element_setup(PlyFile *, char *)
Definition: ply.c:513
PlyFile::elems
PlyElement ** elems
Definition: ply.h:125
PlyFile::other_elems
PlyOtherElems * other_elems
Definition: ply.h:131
PlyOtherProp::props
PlyProperty ** props
Definition: ply.h:101
ply_element_count
void ply_element_count(PlyFile *, char *, int)
Definition: ply.c:413
OtherElem::elem_count
int elem_count
Definition: ply.h:110
PlyFile::file_type
int file_type
Definition: ply.h:122
OtherElem::other_props
PlyOtherProp * other_props
Definition: ply.h:112
ply_write
PlyFile * ply_write(FILE *, int, char **, int)
Definition: ply.c:153
ply_read
PlyFile * ply_read(FILE *, int *, char ***)
Definition: ply.c:712
ply_get_other_properties
PlyOtherProp * ply_get_other_properties(PlyFile *, char *, int)
Definition: ply.c:1143
PlyProperty::internal_type
int internal_type
Definition: ply.h:76
PlyElement::num
int num
Definition: ply.h:88
ply_get_property
void ply_get_property(PlyFile *, char *, PlyProperty *)
Definition: ply.c:973
PlyOtherElems
struct PlyOtherElems PlyOtherElems
PlyOtherProp::size
int size
Definition: ply.h:99
PlyFile::nelems
int nelems
Definition: ply.h:124
PlyOtherProp
Definition: ply.h:97
ply_put_other_elements
void ply_put_other_elements(PlyFile *plyfile)
Definition: ply.c:1338
PlyElement::store_prop
char * store_prop
Definition: ply.h:92
PlyProperty::offset
int offset
Definition: ply.h:77
OtherElem::other_data
OtherData ** other_data
Definition: ply.h:111
PlyElement
struct PlyElement PlyElement
PlyProperty
struct PlyProperty PlyProperty
ply_get_element
void ply_get_element(PlyFile *, void *)
Definition: ply.c:1015
find_element
PlyElement * find_element(PlyFile *, const char *)
Definition: ply.c:1501
ply_close
void ply_close(PlyFile *plyfile)
Definition: ply.c:1388
OtherData
Definition: ply.h:104
ply_get_obj_info
char ** ply_get_obj_info(PlyFile *, int *)
Definition: ply.c:1054
PlyElement
Definition: ply.h:86
ply_open_for_reading
PlyFile * ply_open_for_reading(const char *, int *, char ***, int *, float *)
Definition: ply.c:832
PlyProperty::count_offset
int count_offset
Definition: ply.h:82
ply_describe_element
void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *)
Definition: ply.c:262
find_property
PlyProperty * find_property(PlyElement *, const char *, int *)
Definition: ply.c:1525
ply_describe_property
void ply_describe_property(PlyFile *, char *, PlyProperty *)
Definition: ply.c:307
ply_put_element
void ply_put_element(PlyFile *, void *)
Definition: ply.c:537
PlyFile::fp
FILE * fp
Definition: ply.h:121
ply_open_for_writing
PlyFile * ply_open_for_writing(const char *, int, char **, int, float *)
Definition: ply.c:209
ply_get_comments
char ** ply_get_comments(PlyFile *, int *)
Definition: ply.c:1035
PlyProperty::count_external
int count_external
Definition: ply.h:80
ply_get_element_description
PlyProperty ** ply_get_element_description(PlyFile *, char *, int *, int *)
Definition: ply.c:878
OtherElem
struct OtherElem OtherElem
PlyFile::num_obj_info
int num_obj_info
Definition: ply.h:128
PlyElement::props
PlyProperty ** props
Definition: ply.h:91
ply_get_info
void ply_get_info(PlyFile *, float *, int *)
Definition: ply.c:1462
PlyProperty::is_list
int is_list
Definition: ply.h:79
PlyElement::size
int size
Definition: ply.h:89
ply_put_obj_info
void ply_put_obj_info(PlyFile *, char *)
Definition: ply.c:674
PlyFile::which_elem
PlyElement * which_elem
Definition: ply.h:130
ply_get_element_setup
void ply_get_element_setup(PlyFile *, char *, int, PlyProperty *)
Definition: ply.c:922
OtherElem
Definition: ply.h:108
PlyFile
Definition: ply.h:120
PlyFile::obj_info
char ** obj_info
Definition: ply.h:129
ply_free_other_elements
void ply_free_other_elements(PlyOtherElems *elements)
Definition: ply.c:1368
PlyElement::nprops
int nprops
Definition: ply.h:90
PlyOtherElems::num_elems
int num_elems
Definition: ply.h:116
ply_describe_other_elements
void ply_describe_other_elements(PlyFile *, PlyOtherElems *)
Definition: ply.c:1305
PlyProperty::external_type
int external_type
Definition: ply.h:75
my_alloc
char * my_alloc()
PlyElement::other_offset
int other_offset
Definition: ply.h:93
PlyOtherProp::nprops
int nprops
Definition: ply.h:100
OtherData::other_props
void * other_props
Definition: ply.h:105
PlyProperty
Definition: ply.h:72