ply.h
Go to the documentation of this file.
00001 /*
00002 
00003 Header for PLY polygon files.
00004 
00005 - Greg Turk
00006 
00007 A PLY file contains a single polygonal _object_.
00008 
00009 An object is composed of lists of _elements_.  Typical elements are
00010 vertices, faces, edges and materials.
00011 
00012 Each type of element for a given object has one or more _properties_
00013 associated with the element type.  For instance, a vertex element may
00014 have as properties three floating-point values x,y,z and three unsigned
00015 chars for red, green and blue.
00016 
00017 -----------------------------------------------------------------------
00018 
00019 Copyright (c) 1998 Georgia Institute of Technology.  All rights reserved.   
00020   
00021 Permission to use, copy, modify and distribute this software and its   
00022 documentation for any purpose is hereby granted without fee, provided   
00023 that the above copyright notice and this permission notice appear in   
00024 all copies of this software and that you do not sell the software.   
00025   
00026 THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,   
00027 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY   
00028 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.   
00029 
00030 */
00031 
00032 #ifndef __PLY_H__
00033 #define __PLY_H__
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 #include <stdio.h>
00040 #include <stddef.h>
00041 
00042 #define PLY_ASCII      1        /* ascii PLY file */
00043 #define PLY_BINARY_BE  2        /* binary PLY file, big endian */
00044 #define PLY_BINARY_LE  3        /* binary PLY file, little endian */
00045 
00046 #define PLY_OKAY    0           /* ply routine worked okay */
00047 #define PLY_ERROR  -1           /* error in ply routine */
00048 
00049 /* scalar data types supported by PLY format */
00050 
00051 #define StartType  0
00052 #define Int8       1
00053 #define Int16      2
00054 #define Int32      3
00055 #define Uint8      4
00056 #define Uint16     5
00057 #define Uint32     6
00058 #define Float32    7
00059 #define Float64    8
00060 #define EndType    9
00061 
00062 #define  PLY_SCALAR  0
00063 #define  PLY_LIST    1
00064 #define  PLY_STRING  2
00065 
00066 
00067 typedef struct PlyProperty {    /* description of a property */
00068 
00069   const char *name;                   /* property name */
00070   int external_type;            /* file's data type */
00071   int internal_type;            /* program's data type */
00072   int offset;                   /* offset bytes of prop in a struct */
00073 
00074   int is_list;                  /* 0 = scalar, 1 = list, 2 = char string */
00075   int count_external;           /* file's count type */
00076   int count_internal;           /* program's count type */
00077   int count_offset;             /* offset byte for list count */
00078 
00079 } PlyProperty;
00080 
00081 typedef struct PlyElement {     /* description of an element */
00082   char *name;                   /* element name */
00083   int num;                      /* number of elements in this object */
00084   int size;                     /* size of element (bytes) or -1 if variable */
00085   int nprops;                   /* number of properties for this element */
00086   PlyProperty **props;          /* list of properties in the file */
00087   char *store_prop;             /* flags: property wanted by user? */
00088   int other_offset;             /* offset to un-asked-for props, or -1 if none*/
00089   int other_size;               /* size of other_props structure */
00090 } PlyElement;
00091 
00092 typedef struct PlyOtherProp {   /* describes other properties in an element */
00093   char *name;                   /* element name */
00094   int size;                     /* size of other_props */
00095   int nprops;                   /* number of properties in other_props */
00096   PlyProperty **props;          /* list of properties in other_props */
00097 } PlyOtherProp;
00098 
00099 typedef struct OtherData { /* for storing other_props for an other element */
00100   void *other_props;
00101 } OtherData;
00102 
00103 typedef struct OtherElem {     /* data for one "other" element */
00104   char *elem_name;             /* names of other elements */
00105   int elem_count;              /* count of instances of each element */
00106   OtherData **other_data;      /* actual property data for the elements */
00107   PlyOtherProp *other_props;   /* description of the property data */
00108 } OtherElem;
00109 
00110 typedef struct PlyOtherElems {  /* "other" elements, not interpreted by user */
00111   int num_elems;                /* number of other elements */
00112   OtherElem *other_list;        /* list of data for other elements */
00113 } PlyOtherElems;
00114 
00115 #define AVERAGE_RULE  1
00116 #define MAJORITY_RULE 2
00117 #define MINIMUM_RULE  3
00118 #define MAXIMUM_RULE  4
00119 #define SAME_RULE     5
00120 #define RANDOM_RULE   6
00121 
00122 typedef struct PlyPropRules {   /* rules for combining "other" properties */
00123   PlyElement *elem;      /* element whose rules we are making */
00124   int *rule_list;        /* types of rules (AVERAGE_PLY, MAJORITY_PLY, etc.) */
00125   int nprops;            /* number of properties we're combining so far */
00126   int max_props;         /* maximum number of properties we have room for now */
00127   void **props;          /* list of properties we're combining */
00128   float *weights;        /* list of weights of the properties */
00129 } PlyPropRules;
00130 
00131 typedef struct PlyRuleList {
00132   char *name;                  /* name of the rule */
00133   char *element;               /* name of element that rule applies to */
00134   char *property;              /* name of property that rule applies to */
00135   struct PlyRuleList *next;    /* pointer for linked list of rules */
00136 } PlyRuleList;
00137 
00138 typedef struct PlyFile {        /* description of PLY file */
00139   FILE *fp;                     /* file pointer */
00140   int file_type;                /* ascii or binary */
00141   float version;                /* version number of file */
00142   int num_elem_types;           /* number of element types of object */
00143   PlyElement **elems;           /* list of elements */
00144   int num_comments;             /* number of comments */
00145   char **comments;              /* list of comments */
00146   int num_obj_info;             /* number of items of object information */
00147   char **obj_info;              /* list of object info items */
00148   PlyElement *which_elem;       /* element we're currently reading or writing */
00149   PlyOtherElems *other_elems;   /* "other" elements from a PLY file */
00150   PlyPropRules *current_rules;  /* current propagation rules */
00151   PlyRuleList *rule_list;       /* rule list from user */
00152 } PlyFile;
00153 
00154 /* memory allocation */
00155 /*
00156 extern char *my_alloc();
00157 */
00158 #define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__)
00159 
00160 
00161 /* old routines */
00162 
00163 #if 0
00164 extern PlyFile *ply_write(FILE *, int, char **, int);
00165 extern PlyFile *ply_read(FILE *, int *, char ***);
00166 extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *);
00167 extern void ply_close(PlyFile *);
00168 extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
00169 #endif
00170 
00171 extern void ply_describe_property(PlyFile *, char *, PlyProperty *);
00172 extern void ply_get_property(PlyFile *, char *, PlyProperty *);
00173 extern void ply_get_element(PlyFile *, void *);
00174 
00175 
00176 /*** delcaration of routines ***/
00177 
00178 PlyOtherElems *get_other_element_ply (PlyFile *);
00179 
00180 PlyFile *read_ply(FILE *);
00181 PlyFile *write_ply(FILE *, int, char **, int);
00182 extern PlyFile *open_for_writing_ply(char *, int, char **, int);
00183 void close_ply(PlyFile *);
00184 void free_ply(PlyFile *);
00185 
00186 void get_info_ply(PlyFile *, float *, int *);
00187 void free_other_elements_ply (PlyOtherElems *);
00188 
00189 void append_comment_ply(PlyFile *, char *);
00190 void append_obj_info_ply(PlyFile *, char *);
00191 void copy_comments_ply(PlyFile *, PlyFile *);
00192 void copy_obj_info_ply(PlyFile *, PlyFile *);
00193 char **get_comments_ply(PlyFile *, int *);
00194 char **get_obj_info_ply(PlyFile *, int *);
00195 
00196 char **get_element_list_ply(PlyFile *, int *);
00197 void setup_property_ply(PlyFile *, PlyProperty *);
00198 void get_element_ply (PlyFile *, void *);
00199 char *setup_element_read_ply (PlyFile *, int, int *);
00200 PlyOtherProp *get_other_properties_ply(PlyFile *, int);
00201 
00202 void element_count_ply(PlyFile *, char *, int);
00203 void describe_element_ply(PlyFile *, char *, int);
00204 void describe_property_ply(PlyFile *, PlyProperty *);
00205 void describe_other_properties_ply(PlyFile *, PlyOtherProp *, int);
00206 void describe_other_elements_ply ( PlyFile *, PlyOtherElems *);
00207 void get_element_setup_ply(PlyFile *, char *, int, PlyProperty *);
00208 PlyProperty **get_element_description_ply(PlyFile *, char *, int*, int*);
00209 void element_layout_ply(PlyFile *, char *, int, int, PlyProperty *);
00210 
00211 void header_complete_ply(PlyFile *);
00212 void put_element_setup_ply(PlyFile *, char *);
00213 void put_element_ply(PlyFile *, void *);
00214 void put_other_elements_ply(PlyFile *);
00215 
00216 PlyPropRules *init_rule_ply (PlyFile *, char *);
00217 void modify_rule_ply (PlyPropRules *, char *, int);
00218 void start_props_ply (PlyFile *, PlyPropRules *);
00219 void weight_props_ply (PlyFile *, float, void *);
00220 void *get_new_props_ply(PlyFile *);
00221 void set_prop_rules_ply (PlyFile *, PlyRuleList *);
00222 PlyRuleList *append_prop_rule (PlyRuleList *, char *, char *);
00223 int matches_rule_name (char *);
00224 
00225 int equal_strings(char *, char *);
00226 char *recreate_command_line (int, char *argv[]);
00227 
00228 
00229 #ifdef __cplusplus
00230 }
00231 #endif
00232 #endif /* !__PLY_H__ */
00233 


household_objects_database
Author(s): Matei Ciocarlie, except for source files individually marked otherwise
autogenerated on Thu Jan 2 2014 11:40:13