ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Ply.h
Go to the documentation of this file.
1 /*
2 
3  Header for PLY polygon files.
4 
5  - Greg Turk, March 1994
6 
7  A PLY file contains a single polygonal _object_.
8 
9  An object is composed of lists of _elements_. Typical elements are
10  vertices, faces, edges and materials.
11 
12  Each type of element for a given object has one or more _properties_
13  associated with the element type. For instance, a vertex element may
14  have as properties three floating-point values x,y,z and three unsigned
15  chars for red, green and blue.
16 
17  ---------------------------------------------------------------
18 
19  Copyright (c) 1994 The Board of Trustees of The Leland Stanford
20  Junior University. All rights reserved.
21 
22  Permission to use, copy, modify and distribute this software and its
23  documentation for any purpose is hereby granted without fee, provided
24  that the above copyright notice and this permission notice appear in
25  all copies of this software and that you do not sell the software.
26 
27  THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
28  EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
29  WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
30 
31 */
32 
33 #ifndef __PLY_H__
34 #define __PLY_H__
35 
36 #define USE_PLY_WRAPPER 1
37 
38 #ifndef WIN32
39 #define _strdup strdup
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #include <stdlib.h>
47 #include <stdio.h>
48 #include <stddef.h>
49 #include <string.h>
50 
51 #define PLY_ASCII 1 /* ascii PLY file */
52 #define PLY_BINARY_BE 2 /* binary PLY file, big endian */
53 #define PLY_BINARY_LE 3 /* binary PLY file, little endian */
54 #define PLY_BINARY_NATIVE 4 /* binary PLY file, same endianness as current architecture */
55 
56 #define PLY_OKAY 0 /* ply routine worked okay */
57 #define PLY_ERROR -1 /* error in ply routine */
58 
59  /* scalar data types supported by PLY format */
60 
61 #define PLY_START_TYPE 0
62 #define PLY_CHAR 1
63 #define PLY_SHORT 2
64 #define PLY_INT 3
65 #define PLY_UCHAR 4
66 #define PLY_USHORT 5
67 #define PLY_UINT 6
68 #define PLY_FLOAT 7
69 #define PLY_DOUBLE 8
70 #define PLY_INT_8 9
71 #define PLY_UINT_8 10
72 #define PLY_INT_16 11
73 #define PLY_UINT_16 12
74 #define PLY_INT_32 13
75 #define PLY_UINT_32 14
76 #define PLY_FLOAT_32 15
77 #define PLY_FLOAT_64 16
78 
79 #define PLY_END_TYPE 17
80 
81 #define PLY_SCALAR 0
82 #define PLY_LIST 1
83 
84 #define PLY_STRIP_COMMENT_HEADER 0
85 
86 typedef struct PlyProperty { /* description of a property */
87 
88  char *name; /* property name */
89  int external_type; /* file's data type */
90  int internal_type; /* program's data type */
91  int offset; /* offset bytes of prop in a struct */
92 
93  int is_list; /* 1 = list, 0 = scalar */
94  int count_external; /* file's count type */
95  int count_internal; /* program's count type */
96  int count_offset; /* offset byte for list count */
97 
99 
100 typedef struct PlyElement { /* description of an element */
101  char *name; /* element name */
102  int num; /* number of elements in this object */
103  int size; /* size of element (bytes) or -1 if variable */
104  int nprops; /* number of properties for this element */
105  PlyProperty **props; /* list of properties in the file */
106  char *store_prop; /* flags: property wanted by user? */
107  int other_offset; /* offset to un-asked-for props, or -1 if none*/
108  int other_size; /* size of other_props structure */
110 
111 typedef struct PlyOtherProp { /* describes other properties in an element */
112  char *name; /* element name */
113  int size; /* size of other_props */
114  int nprops; /* number of properties in other_props */
115  PlyProperty **props; /* list of properties in other_props */
117 
118 typedef struct OtherData { /* for storing other_props for an other element */
119  void *other_props;
121 
122 typedef struct OtherElem { /* data for one "other" element */
123  char *elem_name; /* names of other elements */
124  int elem_count; /* count of instances of each element */
125  OtherData **other_data; /* actual property data for the elements */
126  PlyOtherProp *other_props; /* description of the property data */
128 
129 typedef struct PlyOtherElems { /* "other" elements, not interpreted by user */
130  int num_elems; /* number of other elements */
131  OtherElem *other_list; /* list of data for other elements */
133 
134 typedef struct PlyFile { /* description of PLY file */
135  FILE *fp; /* file pointer */
136  int file_type; /* ascii or binary */
137  float version; /* version number of file */
138  int nelems; /* number of elements of object */
139  PlyElement **elems; /* list of elements */
140  int num_comments; /* number of comments */
141  char **comments; /* list of comments */
142  int num_obj_info; /* number of items of object information */
143  char **obj_info; /* list of object info items */
144  PlyElement *which_elem; /* which element we're currently writing */
145  PlyOtherElems *other_elems; /* "other" elements from a PLY file */
147 
148  /* memory allocation */
149 extern char *my_alloc();
150 #define myalloc(mem_size) my_alloc((mem_size), __LINE__, __FILE__)
151 
152 #ifndef ALLOCN
153 #define REALLOCN(PTR,TYPE,OLD_N,NEW_N) \
154 { \
155  if ((OLD_N) == 0) \
156 { ALLOCN((PTR),TYPE,(NEW_N));} \
157  else \
158 { \
159  (PTR) = (TYPE *)realloc((PTR),(NEW_N)*sizeof(TYPE)); \
160  if (((PTR) == NULL) && ((NEW_N) != 0)) \
161 { \
162  fprintf(stderr, "Memory reallocation failed on line %d in %s\n", \
163  __LINE__, __FILE__); \
164  fprintf(stderr, " tried to reallocate %d->%d\n", \
165  (OLD_N), (NEW_N)); \
166  exit(-1); \
167 } \
168  if ((NEW_N)>(OLD_N)) \
169  memset((char *)(PTR)+(OLD_N)*sizeof(TYPE), 0, \
170  ((NEW_N)-(OLD_N))*sizeof(TYPE)); \
171 } \
172 }
173 
174 #define ALLOCN(PTR,TYPE,N) \
175 { (PTR) = (TYPE *) calloc(((unsigned)(N)),sizeof(TYPE));\
176  if ((PTR) == NULL) { \
177  fprintf(stderr, "Memory allocation failed on line %d in %s\n", \
178  __LINE__, __FILE__); \
179  exit(-1); \
180  } \
181 }
182 
183 
184 #define FREE(PTR) { free((PTR)); (PTR) = NULL; }
185 #endif
186 
187 
188 /*** delcaration of routines ***/
189 
190 extern PlyFile *ply_write_custom(FILE *, int, const char **, int);
191 extern PlyFile *ply_open_for_writing(char *, int, const char **, int, float *);
192 extern void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *);
193 extern void ply_describe_property(PlyFile *, const char *, PlyProperty *);
194 extern void ply_element_count(PlyFile *, const char *, int);
195 extern void ply_header_complete(PlyFile *);
196 extern void ply_put_element_setup(PlyFile *, const char *);
197 extern void ply_put_element(PlyFile *, void *);
198 extern void ply_put_comment(PlyFile *, char *);
199 extern void ply_put_obj_info(PlyFile *, char *);
200 extern PlyFile *ply_read_custom(FILE *, int *, char ***);
201 extern PlyFile *ply_open_for_reading( char *, int *, char ***, int *, float *);
202 extern PlyProperty **ply_get_element_description(PlyFile *, char *, int*, int*);
203 extern void ply_get_element_setup( PlyFile *, char *, int, PlyProperty *);
204 extern int ply_get_property(PlyFile *, char *, PlyProperty *);
205 extern PlyOtherProp *ply_get_other_properties(PlyFile *, char *, int);
206 extern void ply_get_element(PlyFile *, void *);
207 extern char **ply_get_comments(PlyFile *, int *);
208 extern char **ply_get_obj_info(PlyFile *, int *);
209 extern void ply_close_custom(PlyFile *);
210 extern void ply_get_info(PlyFile *, float *, int *);
211 extern PlyOtherElems *ply_get_other_element (PlyFile *, char *, int);
213 extern void ply_put_other_elements (PlyFile *);
214 extern void ply_free_other_elements (PlyOtherElems *);
215 extern void ply_describe_other_properties(PlyFile *, PlyOtherProp *, int);
216 
217 extern int equal_strings(const char *, const char *);
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 #include "Geometry.h"
223 #include <vector>
224 
225 template< class Real > int PLYType( void );
226 template<> inline int PLYType< int >( void ){ return PLY_INT ; }
227 template<> inline int PLYType< char >( void ){ return PLY_CHAR ; }
228 template<> inline int PLYType< unsigned char >( void ){ return PLY_UCHAR ; }
229 template<> inline int PLYType< float >( void ){ return PLY_FLOAT ; }
230 template<> inline int PLYType< double >( void ){ return PLY_DOUBLE; }
231 template< class Real > inline int PLYType( void ){ fprintf( stderr , "[ERROR] Unrecognized type\n" ) , exit( 0 ); }
232 
233 typedef struct PlyFace
234 {
235  unsigned char nr_vertices;
236  int *vertices;
237  int segment;
240 {
241  { _strdup( "vertex_indices" ) , PLY_INT , PLY_INT , offsetof( PlyFace , vertices ) , 1 , PLY_UCHAR, PLY_UCHAR , offsetof(PlyFace,nr_vertices) },
242 };
243 
244 
246 // PlyVertexType //
248 
249 // The "Wrapper" class indicates the class to cast to/from in order to support linear operations.
250 template< class Real >
252 {
253 public:
255 
256  const static int ReadComponents=3;
257  const static int WriteComponents=3;
260 
262 
263  PlyVertex( void ) { ; }
265  PlyVertex operator + ( PlyVertex p ) const { return PlyVertex( point+p.point ); }
266  PlyVertex operator - ( PlyVertex p ) const { return PlyVertex( point-p.point ); }
267  template< class _Real > PlyVertex operator * ( _Real s ) const { return PlyVertex( point*s ); }
268  template< class _Real > PlyVertex operator / ( _Real s ) const { return PlyVertex( point/s ); }
269  PlyVertex& operator += ( PlyVertex p ) { point += p.point ; return *this; }
270  PlyVertex& operator -= ( PlyVertex p ) { point -= p.point ; return *this; }
271  template< class _Real > PlyVertex& operator *= ( _Real s ) { point *= s ; return *this; }
272  template< class _Real > PlyVertex& operator /= ( _Real s ) { point /= s ; return *this; }
273 };
274 template< class Real , class _Real > PlyVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyVertex< Real > v ) { return PlyVertex< Real >( xForm * v.point ); }
275 template< class Real > PlyProperty PlyVertex< Real >::ReadProperties[]=
276 {
277  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
278  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
279  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 }
280 };
281 template< class Real > PlyProperty PlyVertex< Real >::WriteProperties[]=
282 {
283  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
284  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
285  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 }
286 };
287 template< class Real >
289 {
290 public:
292 
293  const static int ReadComponents=4;
294  const static int WriteComponents=4;
297 
299  Real value;
300 
301  PlyValueVertex( void ) : value( Real(0) ) { ; }
302  PlyValueVertex( Point3D< Real > p , Real v ) : point(p) , value(v) { ; }
305  template< class _Real > PlyValueVertex operator * ( _Real s ) const { return PlyValueVertex( point*s , Real(value*s) ); }
306  template< class _Real > PlyValueVertex operator / ( _Real s ) const { return PlyValueVertex( point/s , Real(value/s) ); }
307  PlyValueVertex& operator += ( PlyValueVertex p ) { point += p.point , value += p.value ; return *this; }
308  PlyValueVertex& operator -= ( PlyValueVertex p ) { point -= p.point , value -= p.value ; return *this; }
309  template< class _Real > PlyValueVertex& operator *= ( _Real s ) { point *= s , value *= Real(s) ; return *this; }
310  template< class _Real > PlyValueVertex& operator /= ( _Real s ) { point /= s , value /= Real(s) ; return *this; }
311 };
312 template< class Real , class _Real > PlyValueVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyValueVertex< Real > v ) { return PlyValueVertex< Real >( xForm * v.point , v.value ); }
313 template< class Real > PlyProperty PlyValueVertex< Real >::ReadProperties[]=
314 {
315  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
316  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
317  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
318  { _strdup( "value" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , value ) ) , 0 , 0 , 0 , 0 }
319 };
321 {
322  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
323  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
324  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
325  { _strdup( "value" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyValueVertex , value ) ) , 0 , 0 , 0 , 0 }
326 };
327 template< class Real >
329 {
330 public:
332 
333  const static int ReadComponents=6;
334  const static int WriteComponents=6;
337 
339 
340  PlyOrientedVertex( void ) { ; }
344  template< class _Real > PlyOrientedVertex operator * ( _Real s ) const { return PlyOrientedVertex( point*s , normal*s ); }
345  template< class _Real > PlyOrientedVertex operator / ( _Real s ) const { return PlyOrientedVertex( point/s , normal/s ); }
348  template< class _Real > PlyOrientedVertex& operator *= ( _Real s ) { point *= s , normal *= s ; return *this; }
349  template< class _Real > PlyOrientedVertex& operator /= ( _Real s ) { point /= s , normal /= s ; return *this; }
350 };
351 template< class Real , class _Real > PlyOrientedVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyOrientedVertex< Real > v ) { return PlyOrientedVertex< Real >( xForm * v.point , xForm.inverse().transpose() * v.normal ); }
353 {
354  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
355  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
356  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
357  { _strdup( "nx" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[0] ) ) , 0 , 0 , 0 , 0 },
358  { _strdup( "ny" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[1] ) ) , 0 , 0 , 0 , 0 },
359  { _strdup( "nz" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[2] ) ) , 0 , 0 , 0 , 0 }
360 };
362 {
363  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
364  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
365  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
366  { _strdup( "nx" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[0] ) ) , 0 , 0 , 0 , 0 },
367  { _strdup( "ny" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[1] ) ) , 0 , 0 , 0 , 0 },
368  { _strdup( "nz" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyOrientedVertex , normal.coords[2] ) ) , 0 , 0 , 0 , 0 }
369 };
370 template< class Real >
372 {
373 public:
375  {
377  _PlyColorVertex( void ) { ; }
379  _PlyColorVertex( PlyColorVertex< Real > p ){ point = p.point ; for( int c=0 ; c<3 ; c++ ) color[c] = (Real) p.color[c]; }
381  {
383  p.point = point;
384  for( int c=0 ; c<3 ; c++ ) p.color[c] = (unsigned char)std::max< int >( 0 , std::min< int >( 255 , (int)( color[c]+0.5 ) ) );
385  return p;
386  }
387 
390  template< class _Real > _PlyColorVertex operator * ( _Real s ) const { return _PlyColorVertex( point*s , color*s ); }
391  template< class _Real > _PlyColorVertex operator / ( _Real s ) const { return _PlyColorVertex( point/s , color/s ); }
392  _PlyColorVertex& operator += ( _PlyColorVertex p ) { point += p.point , color += p.color ; return *this; }
393  _PlyColorVertex& operator -= ( _PlyColorVertex p ) { point -= p.point , color -= p.color ; return *this; }
394  template< class _Real > _PlyColorVertex& operator *= ( _Real s ) { point *= s , color *= s ; return *this; }
395  template< class _Real > _PlyColorVertex& operator /= ( _Real s ) { point /= s , color /= s ; return *this; }
396  };
397 
399 
400  const static int ReadComponents=9;
401  const static int WriteComponents=6;
404 
406  unsigned char color[3];
407 
408  operator Point3D< Real >& (){ return point; }
409  operator const Point3D< Real >& () const { return point; }
410  PlyColorVertex( void ) { point.coords[0] = point.coords[1] = point.coords[2] = 0 , color[0] = color[1] = color[2] = 0; }
411  PlyColorVertex( const Point3D<Real>& p ) { point=p; }
412  PlyColorVertex( const Point3D< Real >& p , const unsigned char c[3] ) { point = p , color[0] = c[0] , color[1] = c[1] , color[2] = c[2]; }
413 };
414 template< class Real , class _Real > PlyColorVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyColorVertex< Real > v ) { return PlyColorVertex< Real >( xForm * v.point , v.color ); }
415 
416 template< class Real > PlyProperty PlyColorVertex< Real >::ReadProperties[]=
417 {
418  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
419  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
420  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
421  { _strdup( "red" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[0] ) ) , 0 , 0 , 0 , 0 },
422  { _strdup( "green" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[1] ) ) , 0 , 0 , 0 , 0 },
423  { _strdup( "blue" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[2] ) ) , 0 , 0 , 0 , 0 },
424  { _strdup( "r" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[0] ) ) , 0 , 0 , 0 , 0 },
425  { _strdup( "g" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[1] ) ) , 0 , 0 , 0 , 0 },
426  { _strdup( "b" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[2] ) ) , 0 , 0 , 0 , 0 }
427 };
429 {
430  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 },
431  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 },
432  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >(), int( offsetof( PlyColorVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 },
433  { _strdup( "red" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[0] ) ) , 0 , 0 , 0 , 0 },
434  { _strdup( "green" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[1] ) ) , 0 , 0 , 0 , 0 },
435  { _strdup( "blue" ) , PLYType< unsigned char >() , PLYType< unsigned char >(), int( offsetof( PlyColorVertex , color[2] ) ) , 0 , 0 , 0 , 0 }
436 };
437 template< class Real >
439 {
440 public:
442  {
444  Real value;
445  _PlyColorAndValueVertex( void ) : value(0) { ; }
447  _PlyColorAndValueVertex( PlyColorAndValueVertex< Real > p ){ point = p.point ; for( int c=0 ; c<3 ; c++ ) color[c] = (Real) p.color[c] ; value = p.value; }
449  {
451  p.point = point;
452  for( int c=0 ; c<3 ; c++ ) p.color[c] = (unsigned char)std::max< int >( 0 , std::min< int >( 255 , (int)( color[c]+0.5 ) ) );
453  p.value = value;
454  return p;
455  }
456 
459  template< class _Real > _PlyColorAndValueVertex operator * ( _Real s ) const { return _PlyColorAndValueVertex( point*s , color*s , value*s ); }
460  template< class _Real > _PlyColorAndValueVertex operator / ( _Real s ) const { return _PlyColorAndValueVertex( point/s , color/s , value/s ); }
463  template< class _Real > _PlyColorAndValueVertex& operator *= ( _Real s ) { point *= s , color *= s , value *= (Real)s ; return *this; }
464  template< class _Real > _PlyColorAndValueVertex& operator /= ( _Real s ) { point /= s , color /= s , value /= (Real)s ; return *this; }
465  };
466 
468 
469  const static int ReadComponents=10;
470  const static int WriteComponents=7;
473 
475  unsigned char color[3];
476  Real value;
477 
478  operator Point3D< Real >& (){ return point; }
479  operator const Point3D< Real >& () const { return point; }
480  PlyColorAndValueVertex( void ) { point.coords[0] = point.coords[1] = point.coords[2] = (Real)0 , color[0] = color[1] = color[2] = 0 , value = (Real)0; }
482  PlyColorAndValueVertex( const Point3D< Real >& p , const unsigned char c[3] , Real v) { point = p , color[0] = c[0] , color[1] = c[1] , color[2] = c[2] , value = v; }
483 };
484 template< class Real , class _Real > PlyColorAndValueVertex< Real > operator * ( XForm4x4< _Real > xForm , PlyColorAndValueVertex< Real > v ) { return PlyColorAndValueVertex< Real >( xForm * v.point , v.color , v.value ); }
486 {
487  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 } ,
488  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 } ,
489  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 } ,
490  { _strdup( "value" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , value ) ) , 0 , 0 , 0 , 0 } ,
491  { _strdup( "red" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[0] ) ) , 0 , 0 , 0 , 0 } ,
492  { _strdup( "green" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[1] ) ) , 0 , 0 , 0 , 0 } ,
493  { _strdup( "blue" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[2] ) ) , 0 , 0 , 0 , 0 } ,
494  { _strdup( "r" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[0] ) ) , 0 , 0 , 0 , 0 } ,
495  { _strdup( "g" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[1] ) ) , 0 , 0 , 0 , 0 } ,
496  { _strdup( "b" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[2] ) ) , 0 , 0 , 0 , 0 }
497 };
499 {
500  { _strdup( "x" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , point.coords[0] ) ) , 0 , 0 , 0 , 0 } ,
501  { _strdup( "y" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , point.coords[1] ) ) , 0 , 0 , 0 , 0 } ,
502  { _strdup( "z" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , point.coords[2] ) ) , 0 , 0 , 0 , 0 } ,
503  { _strdup( "value" ) , PLYType< Real >() , PLYType< Real >() , int( offsetof( PlyColorAndValueVertex , value ) ) , 0 , 0 , 0 , 0 } ,
504  { _strdup( "red" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[0] ) ) , 0 , 0 , 0 , 0 } ,
505  { _strdup( "green" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[1] ) ) , 0 , 0 , 0 , 0 } ,
506  { _strdup( "blue" ) , PLYType< unsigned char >() , PLYType< unsigned char >() , int( offsetof( PlyColorAndValueVertex , color[2] ) ) , 0 , 0 , 0 , 0 }
507 };
508 
509 template< class Vertex , class Real >
510 int PlyWritePolygons( char* fileName , CoredMeshData< Vertex >* mesh , int file_type , const Point3D< float >& translate , float scale , char** comments=NULL , int commentNum=0 , XForm4x4< Real > xForm=XForm4x4< Real >::Identity() );
511 
512 template< class Vertex , class Real >
513 int PlyWritePolygons( char* fileName , CoredMeshData< Vertex >* mesh , int file_type , char** comments=NULL , int commentNum=0 , XForm4x4< Real > xForm=XForm4x4< Real >::Identity() );
514 
515 inline bool PlyReadHeader( char* fileName , PlyProperty* properties , int propertyNum , bool* readFlags , int& file_type )
516 {
517  int nr_elems;
518  char **elist;
519  float version;
520  PlyFile* ply;
521  char* elem_name;
522  int num_elems;
523  int nr_props;
524  PlyProperty** plist;
525 
526  ply = ply_open_for_reading( fileName , &nr_elems , &elist , &file_type , &version );
527  if( !ply ) return false;
528 
529  for( int i=0 ; i<nr_elems ; i++ )
530  {
531  elem_name = elist[i];
532  plist = ply_get_element_description( ply , elem_name , &num_elems , &nr_props );
533  if( !plist )
534  {
535  for( int i=0 ; i<nr_elems ; i++ )
536  {
537  free( ply->elems[i]->name );
538  free( ply->elems[i]->store_prop );
539  for( int j=0 ; j<ply->elems[i]->nprops ; j++ )
540  {
541  free( ply->elems[i]->props[j]->name );
542  free( ply->elems[i]->props[j] );
543  }
544  free( ply->elems[i]->props );
545  }
546  for( int i=0 ; i<nr_elems ; i++ ) free( ply->elems[i] );
547  free( ply->elems );
548  for( int i=0 ; i<ply->num_comments ; i++ ) free( ply->comments[i] );
549  free( ply->comments );
550  for( int i=0 ; i<ply->num_obj_info ; i++ ) free( ply->obj_info[i] );
551  free( ply->obj_info );
553 
554  for( int i=0 ; i<nr_elems ; i++ ) free( elist[i] );
555  free( elist );
556  ply_close_custom( ply );
557  return 0;
558  }
559  if( equal_strings( "vertex" , elem_name ) )
560  for( int i=0 ; i<propertyNum ; i++ )
561  if( readFlags ) readFlags[i] = ply_get_property( ply , elem_name , &properties[i] )!=0;
562 
563  for( int j=0 ; j<nr_props ; j++ )
564  {
565  free( plist[j]->name );
566  free( plist[j] );
567  }
568  free( plist );
569  } // for each type of element
570 
571  for( int i=0 ; i<nr_elems ; i++ )
572  {
573  free( ply->elems[i]->name );
574  free( ply->elems[i]->store_prop );
575  for( int j=0 ; j<ply->elems[i]->nprops ; j++ )
576  {
577  free( ply->elems[i]->props[j]->name );
578  free( ply->elems[i]->props[j] );
579  }
580  if( ply->elems[i]->props && ply->elems[i]->nprops ) free(ply->elems[i]->props);
581  }
582  for( int i=0 ; i<nr_elems ; i++ ) free(ply->elems[i]);
583  free( ply->elems) ;
584  for( int i=0 ; i<ply->num_comments ; i++ ) free( ply->comments[i] );
585  free( ply->comments );
586  for( int i=0 ; i<ply->num_obj_info ; i++ ) free( ply->obj_info[i] );
587  free( ply->obj_info );
589 
590 
591  for( int i=0 ; i<nr_elems ; i++ ) free( elist[i] );
592  free( elist );
593  ply_close_custom( ply );
594  return true;
595 }
596 inline bool PlyReadHeader( char* fileName , PlyProperty* properties , int propertyNum , bool* readFlags )
597 {
598  int file_type;
599  return PlyReadHeader( fileName , properties , propertyNum , readFlags , file_type );
600 }
601 
602 
603 template<class Vertex>
604 int PlyReadPolygons(char* fileName,
605  std::vector<Vertex>& vertices,std::vector<std::vector<int> >& polygons,
606  PlyProperty* properties,int propertyNum,
607  int& file_type,
608  char*** comments=NULL,int* commentNum=NULL , bool* readFlags=NULL );
609 
610 template<class Vertex>
611 int PlyWritePolygons(char* fileName,
612  const std::vector<Vertex>& vertices,const std::vector<std::vector<int> >& polygons,
613  PlyProperty* properties,int propertyNum,
614  int file_type,
615  char** comments=NULL,const int& commentNum=0);
616 
617 template<class Vertex>
618 int PlyWritePolygons(char* fileName,
619  const std::vector<Vertex>& vertices , const std::vector< std::vector< int > >& polygons,
620  PlyProperty* properties,int propertyNum,
621  int file_type,
622  char** comments,const int& commentNum)
623 {
624  int nr_vertices=int(vertices.size());
625  int nr_faces=int(polygons.size());
626  float version;
627  const char *elem_names[] = { "vertex" , "face" };
628  PlyFile *ply = ply_open_for_writing( fileName , 2 , elem_names , file_type , &version );
629  if (!ply){return 0;}
630 
631  //
632  // describe vertex and face properties
633  //
634  ply_element_count(ply, "vertex", nr_vertices);
635  for(int i=0;i<propertyNum;i++)
636  ply_describe_property(ply, "vertex", &properties[i]);
637 
638  ply_element_count(ply, "face", nr_faces);
639  ply_describe_property(ply, "face", &face_props[0]);
640 
641  // Write in the comments
642  if(comments && commentNum)
643  for(int i=0;i<commentNum;i++)
644  ply_put_comment(ply,comments[i]);
645 
646  ply_header_complete(ply);
647 
648  // write vertices
649  ply_put_element_setup(ply, "vertex");
650  for (int i=0; i < int(vertices.size()); i++)
651  ply_put_element(ply, (void *) &vertices[i]);
652 
653  // write faces
654  PlyFace ply_face;
655  int maxFaceVerts=3;
656  ply_face.nr_vertices = 3;
657  ply_face.vertices = new int[3];
658 
659  ply_put_element_setup(ply, "face");
660  for (int i=0; i < nr_faces; i++)
661  {
662  if(int(polygons[i].size())>maxFaceVerts)
663  {
664  delete[] ply_face.vertices;
665  maxFaceVerts=int(polygons[i].size());
666  ply_face.vertices=new int[maxFaceVerts];
667  }
668  ply_face.nr_vertices=int(polygons[i].size());
669  for(int j=0;j<ply_face.nr_vertices;j++)
670  ply_face.vertices[j]=polygons[i][j];
671  ply_put_element(ply, (void *) &ply_face);
672  }
673 
674  delete[] ply_face.vertices;
675  ply_close_custom(ply);
676  return 1;
677 }
678 template<class Vertex>
679 int PlyReadPolygons(char* fileName,
680  std::vector<Vertex>& vertices , std::vector<std::vector<int> >& polygons ,
681  PlyProperty* properties , int propertyNum ,
682  int& file_type ,
683  char*** comments , int* commentNum , bool* readFlags )
684 {
685  int nr_elems;
686  char **elist;
687  float version;
688  int i,j,k;
689  PlyFile* ply;
690  char* elem_name;
691  int num_elems;
692  int nr_props;
693  PlyProperty** plist;
694  PlyFace ply_face;
695 
696  ply = ply_open_for_reading(fileName, &nr_elems, &elist, &file_type, &version);
697  if(!ply) return 0;
698 
699  if(comments)
700  {
701  (*comments)=new char*[*commentNum+ply->num_comments];
702  for(int i=0;i<ply->num_comments;i++)
703  (*comments)[i]=_strdup(ply->comments[i]);
704  *commentNum=ply->num_comments;
705  }
706 
707  for (i=0; i < nr_elems; i++) {
708  elem_name = elist[i];
709  plist = ply_get_element_description(ply, elem_name, &num_elems, &nr_props);
710  if(!plist)
711  {
712  for(i=0;i<nr_elems;i++){
713  free(ply->elems[i]->name);
714  free(ply->elems[i]->store_prop);
715  for(j=0;j<ply->elems[i]->nprops;j++){
716  free(ply->elems[i]->props[j]->name);
717  free(ply->elems[i]->props[j]);
718  }
719  free(ply->elems[i]->props);
720  }
721  for(i=0;i<nr_elems;i++){free(ply->elems[i]);}
722  free(ply->elems);
723  for(i=0;i<ply->num_comments;i++){free(ply->comments[i]);}
724  free(ply->comments);
725  for(i=0;i<ply->num_obj_info;i++){free(ply->obj_info[i]);}
726  free(ply->obj_info);
728 
729  for(i=0;i<nr_elems;i++){free(elist[i]);}
730  free(elist);
731  ply_close_custom(ply);
732  return 0;
733  }
734  if (equal_strings("vertex", elem_name))
735  {
736  for( int i=0 ; i<propertyNum ; i++)
737  {
738  int hasProperty = ply_get_property(ply,elem_name,&properties[i]);
739  if( readFlags ) readFlags[i] = (hasProperty!=0);
740  }
741  vertices.resize(num_elems);
742  for (j=0; j < num_elems; j++) ply_get_element (ply, (void *) &vertices[j]);
743  }
744  else if (equal_strings("face", elem_name))
745  {
746  ply_get_property (ply, elem_name, &face_props[0]);
747  polygons.resize(num_elems);
748  for (j=0; j < num_elems; j++)
749  {
750  ply_get_element (ply, (void *) &ply_face);
751  polygons[j].resize(ply_face.nr_vertices);
752  for(k=0;k<ply_face.nr_vertices;k++) polygons[j][k]=ply_face.vertices[k];
753  delete[] ply_face.vertices;
754  } // for, read faces
755  } // if face
756  else{ply_get_other_element (ply, elem_name, num_elems);}
757 
758  for(j=0;j<nr_props;j++){
759  free(plist[j]->name);
760  free(plist[j]);
761  }
762  free(plist);
763  } // for each type of element
764 
765  for(i=0;i<nr_elems;i++){
766  free(ply->elems[i]->name);
767  free(ply->elems[i]->store_prop);
768  for(j=0;j<ply->elems[i]->nprops;j++){
769  free(ply->elems[i]->props[j]->name);
770  free(ply->elems[i]->props[j]);
771  }
772  if(ply->elems[i]->props && ply->elems[i]->nprops){free(ply->elems[i]->props);}
773  }
774  for(i=0;i<nr_elems;i++){free(ply->elems[i]);}
775  free(ply->elems);
776  for(i=0;i<ply->num_comments;i++){free(ply->comments[i]);}
777  free(ply->comments);
778  for(i=0;i<ply->num_obj_info;i++){free(ply->obj_info[i]);}
779  free(ply->obj_info);
781 
782 
783  for(i=0;i<nr_elems;i++){free(elist[i]);}
784  free(elist);
785  ply_close_custom(ply);
786  return 1;
787 }
788 
789 template< class Vertex , class Real >
790 int PlyWritePolygons( char* fileName , CoredMeshData< Vertex >* mesh , int file_type , const Point3D<float>& translate , float scale , char** comments , int commentNum , XForm4x4< Real > xForm )
791 {
792  int i;
793  int nr_vertices=int(mesh->outOfCorePointCount()+mesh->inCorePoints.size());
794  int nr_faces=mesh->polygonCount();
795  float version;
796  const char *elem_names[] = { "vertex" , "face" };
797  PlyFile *ply = ply_open_for_writing( fileName , 2 , elem_names , file_type , &version );
798  if( !ply ) return 0;
799 
800  mesh->resetIterator();
801 
802  //
803  // describe vertex and face properties
804  //
805  ply_element_count( ply , "vertex" , nr_vertices );
806  for( int i=0 ; i<Vertex::Components ; i++ ) ply_describe_property( ply , "vertex" , &Vertex::Properties[i] );
807 
808  ply_element_count( ply , "face" , nr_faces );
809  ply_describe_property( ply , "face" , &face_props[0] );
810 
811  // Write in the comments
812  for( i=0 ; i<commentNum ; i++ ) ply_put_comment( ply , comments[i] );
813 
814  ply_header_complete( ply );
815 
816  // write vertices
817  ply_put_element_setup( ply , "vertex" );
818  for( i=0 ; i<int( mesh->inCorePoints.size() ) ; i++ )
819  {
820  Vertex vertex = xForm * ( mesh->inCorePoints[i] * scale + translate );
821  ply_put_element(ply, (void *) &vertex);
822  }
823  for( i=0; i<mesh->outOfCorePointCount() ; i++ )
824  {
825  Vertex vertex;
826  mesh->nextOutOfCorePoint( vertex );
827  vertex = xForm * ( vertex * scale +translate );
828  ply_put_element(ply, (void *) &vertex);
829  } // for, write vertices
830 
831  // write faces
832  std::vector< CoredVertexIndex > polygon;
833  ply_put_element_setup( ply , "face" );
834  for( i=0 ; i<nr_faces ; i++ )
835  {
836  //
837  // create and fill a struct that the ply code can handle
838  //
839  PlyFace ply_face;
840  mesh->nextPolygon( polygon );
841  ply_face.nr_vertices = int( polygon.size() );
842  ply_face.vertices = new int[ polygon.size() ];
843  for( int i=0 ; i<int(polygon.size()) ; i++ )
844  if( polygon[i].inCore ) ply_face.vertices[i] = polygon[i].idx;
845  else ply_face.vertices[i] = polygon[i].idx + int( mesh->inCorePoints.size() );
846  ply_put_element( ply, (void *) &ply_face );
847  delete[] ply_face.vertices;
848  } // for, write faces
849 
850  ply_close_custom( ply );
851  return 1;
852 }
853 template< class Vertex , class Real >
854 int PlyWritePolygons( char* fileName , CoredMeshData< Vertex >* mesh , int file_type , char** comments , int commentNum , XForm4x4< Real > xForm )
855 {
856  int i;
857  int nr_vertices=int(mesh->outOfCorePointCount()+mesh->inCorePoints.size());
858  int nr_faces=mesh->polygonCount();
859  float version;
860  const char *elem_names[] = { "vertex" , "face" };
861  PlyFile *ply = ply_open_for_writing( fileName , 2 , elem_names , file_type , &version );
862  if( !ply ) return 0;
863 
864  mesh->resetIterator();
865 
866  //
867  // describe vertex and face properties
868  //
869  ply_element_count( ply , "vertex" , nr_vertices );
870  for( int i=0 ; i<Vertex::WriteComponents ; i++ ) ply_describe_property( ply , "vertex" , &Vertex::WriteProperties[i] );
871 
872  ply_element_count( ply , "face" , nr_faces );
873  ply_describe_property( ply , "face" , &face_props[0] );
874 
875  // Write in the comments
876  for( i=0 ; i<commentNum ; i++ ) ply_put_comment( ply , comments[i] );
877 
878  ply_header_complete( ply );
879 
880  // write vertices
881  ply_put_element_setup( ply , "vertex" );
882  for( i=0 ; i<int( mesh->inCorePoints.size() ) ; i++ )
883  {
884  Vertex vertex = xForm * mesh->inCorePoints[i];
885  ply_put_element(ply, (void *) &vertex);
886  }
887  for( i=0; i<mesh->outOfCorePointCount() ; i++ )
888  {
889  Vertex vertex;
890  mesh->nextOutOfCorePoint( vertex );
891  vertex = xForm * ( vertex );
892  ply_put_element(ply, (void *) &vertex);
893  } // for, write vertices
894 
895  // write faces
896  std::vector< CoredVertexIndex > polygon;
897  ply_put_element_setup( ply , "face" );
898  for( i=0 ; i<nr_faces ; i++ )
899  {
900  //
901  // create and fill a struct that the ply code can handle
902  //
903  PlyFace ply_face;
904  mesh->nextPolygon( polygon );
905  ply_face.nr_vertices = int( polygon.size() );
906  ply_face.vertices = new int[ polygon.size() ];
907  for( int i=0 ; i<int(polygon.size()) ; i++ )
908  if( polygon[i].inCore ) ply_face.vertices[i] = polygon[i].idx;
909  else ply_face.vertices[i] = polygon[i].idx + int( mesh->inCorePoints.size() );
910  ply_put_element( ply, (void *) &ply_face );
911  delete[] ply_face.vertices;
912  } // for, write faces
913 
914  ply_close_custom( ply );
915  return 1;
916 }
917 inline int PlyDefaultFileType(void){return PLY_ASCII;}
918 
919 #endif /* !__PLY_H__ */
double normal[3]
int size
std::string version
std::string name
math::float4 color
void ply_describe_other_properties(PlyFile *, PlyOtherProp *, int)
Definition: PlyFile.cpp:385
PlyOtherElems * ply_get_other_element(PlyFile *, char *, int)
Definition: PlyFile.cpp:1261
PlyOtherProp * ply_get_other_properties(PlyFile *, char *, int)
Definition: PlyFile.cpp:1182
void ply_put_obj_info(PlyFile *, char *)
Definition: PlyFile.cpp:706
void ply_describe_element(PlyFile *, char *, int, int, PlyProperty *)
Definition: PlyFile.cpp:294
void ply_close_custom(PlyFile *)
Definition: PlyFile.cpp:1425
PlyFile * ply_write_custom(FILE *, int, const char **, int)
Definition: PlyFile.cpp:176
void ply_put_element(PlyFile *, void *)
Definition: PlyFile.cpp:569
struct PlyOtherProp PlyOtherProp
struct PlyFile PlyFile
PlyFile * ply_open_for_writing(char *, int, const char **, int, float *)
Definition: PlyFile.cpp:240
void ply_put_element_setup(PlyFile *, const char *)
Definition: PlyFile.cpp:545
struct PlyFace PlyFace
void ply_describe_other_elements(PlyFile *, PlyOtherElems *)
Definition: PlyFile.cpp:1333
struct OtherData OtherData
char * my_alloc()
PlyFile * ply_read_custom(FILE *, int *, char ***)
Definition: PlyFile.cpp:744
int PLYType(void)
Definition: Ply.h:231
void ply_put_other_elements(PlyFile *)
Definition: PlyFile.cpp:1375
#define PLY_ASCII
Definition: Ply.h:51
void ply_describe_property(PlyFile *, const char *, PlyProperty *)
Definition: PlyFile.cpp:339
int PlyReadPolygons(char *fileName, std::vector< Vertex > &vertices, std::vector< std::vector< int > > &polygons, PlyProperty *properties, int propertyNum, int &file_type, char ***comments=NULL, int *commentNum=NULL, bool *readFlags=NULL)
Definition: Ply.h:679
#define PLY_FLOAT
Definition: Ply.h:68
#define PLY_INT
Definition: Ply.h:64
PlyVertex< Real > operator*(XForm4x4< _Real > xForm, PlyVertex< Real > v)
Definition: Ply.h:274
static PlyProperty face_props[]
Definition: Ply.h:239
struct OtherElem OtherElem
void ply_header_complete(PlyFile *)
Definition: PlyFile.cpp:472
char ** ply_get_obj_info(PlyFile *, int *)
Definition: PlyFile.cpp:1093
int PlyWritePolygons(char *fileName, CoredMeshData< Vertex > *mesh, int file_type, const Point3D< float > &translate, float scale, char **comments=NULL, int commentNum=0, XForm4x4< Real > xForm=XForm4x4< Real >::Identity())
Definition: Ply.h:790
int PLYType< char >(void)
Definition: Ply.h:227
#define PLY_DOUBLE
Definition: Ply.h:69
PlyFile * ply_open_for_reading(char *, int *, char ***, int *, float *)
Definition: PlyFile.cpp:860
#define PLY_UCHAR
Definition: Ply.h:65
void ply_get_element_setup(PlyFile *, char *, int, PlyProperty *)
Definition: PlyFile.cpp:959
int PLYType< unsigned char >(void)
Definition: Ply.h:228
void ply_get_info(PlyFile *, float *, int *)
Definition: PlyFile.cpp:1445
int PLYType< float >(void)
Definition: Ply.h:229
int PlyDefaultFileType(void)
Definition: Ply.h:917
struct PlyProperty PlyProperty
struct PlyOtherElems PlyOtherElems
void ply_get_element(PlyFile *, void *)
Definition: PlyFile.cpp:1054
int PLYType< double >(void)
Definition: Ply.h:230
bool PlyReadHeader(char *fileName, PlyProperty *properties, int propertyNum, bool *readFlags, int &file_type)
Definition: Ply.h:515
void ply_element_count(PlyFile *, const char *, int)
Definition: PlyFile.cpp:445
#define _strdup
Definition: Ply.h:39
int ply_get_property(PlyFile *, char *, PlyProperty *)
Definition: PlyFile.cpp:1010
struct PlyElement PlyElement
void ply_free_other_elements(PlyOtherElems *)
Definition: PlyFile.cpp:1405
int equal_strings(const char *, const char *)
Definition: PlyFile.cpp:1459
char ** ply_get_comments(PlyFile *, int *)
Definition: PlyFile.cpp:1074
#define PLY_CHAR
Definition: Ply.h:62
PlyProperty ** ply_get_element_description(PlyFile *, char *, int *, int *)
Definition: PlyFile.cpp:915
void ply_put_comment(PlyFile *, char *)
Definition: PlyFile.cpp:682
int PLYType< int >(void)
Definition: Ply.h:226
boost::geometry::model::polygon< point_xy > polygon
Definition: TreeIso.cpp:37
#define NULL
virtual int polygonCount(void)=0
virtual int nextPolygon(std::vector< CoredVertexIndex > &vertices)=0
virtual int nextOutOfCorePoint(Vertex &p)=0
virtual int outOfCorePointCount(void)=0
std::vector< Vertex > inCorePoints
Definition: Geometry.h:304
virtual void resetIterator(void)=0
static const int WriteComponents
Definition: Ply.h:470
PlyColorAndValueVertex(const Point3D< Real > &p)
Definition: Ply.h:481
PlyColorAndValueVertex(const Point3D< Real > &p, const unsigned char c[3], Real v)
Definition: Ply.h:482
unsigned char color[3]
Definition: Ply.h:475
Point3D< Real > point
Definition: Ply.h:474
static PlyProperty ReadProperties[]
Definition: Ply.h:471
static PlyProperty WriteProperties[]
Definition: Ply.h:472
PlyColorAndValueVertex(void)
Definition: Ply.h:480
_PlyColorAndValueVertex Wrapper
Definition: Ply.h:467
static const int ReadComponents
Definition: Ply.h:469
PlyColorVertex(void)
Definition: Ply.h:410
static const int WriteComponents
Definition: Ply.h:401
unsigned char color[3]
Definition: Ply.h:406
PlyColorVertex(const Point3D< Real > &p, const unsigned char c[3])
Definition: Ply.h:412
static PlyProperty WriteProperties[]
Definition: Ply.h:403
_PlyColorVertex Wrapper
Definition: Ply.h:398
static PlyProperty ReadProperties[]
Definition: Ply.h:402
PlyColorVertex(const Point3D< Real > &p)
Definition: Ply.h:411
Point3D< Real > point
Definition: Ply.h:405
static const int ReadComponents
Definition: Ply.h:400
PlyOrientedVertex operator+(PlyOrientedVertex p) const
Definition: Ply.h:342
PlyOrientedVertex operator/(_Real s) const
Definition: Ply.h:345
static const int WriteComponents
Definition: Ply.h:334
static PlyProperty WriteProperties[]
Definition: Ply.h:336
PlyOrientedVertex & operator*=(_Real s)
Definition: Ply.h:348
PlyOrientedVertex operator*(_Real s) const
Definition: Ply.h:344
static const int ReadComponents
Definition: Ply.h:333
static PlyProperty ReadProperties[]
Definition: Ply.h:335
PlyOrientedVertex(Point3D< Real > p, Point3D< Real > n)
Definition: Ply.h:341
Point3D< Real > normal
Definition: Ply.h:338
PlyOrientedVertex operator-(PlyOrientedVertex p) const
Definition: Ply.h:343
PlyOrientedVertex & operator-=(PlyOrientedVertex p)
Definition: Ply.h:347
PlyOrientedVertex Wrapper
Definition: Ply.h:331
PlyOrientedVertex & operator+=(PlyOrientedVertex p)
Definition: Ply.h:346
Point3D< Real > point
Definition: Ply.h:338
PlyOrientedVertex(void)
Definition: Ply.h:340
PlyOrientedVertex & operator/=(_Real s)
Definition: Ply.h:349
PlyValueVertex & operator*=(_Real s)
Definition: Ply.h:309
static PlyProperty ReadProperties[]
Definition: Ply.h:295
PlyValueVertex operator/(_Real s) const
Definition: Ply.h:306
Real value
Definition: Ply.h:299
PlyValueVertex & operator/=(_Real s)
Definition: Ply.h:310
static PlyProperty WriteProperties[]
Definition: Ply.h:296
PlyValueVertex(void)
Definition: Ply.h:301
static const int WriteComponents
Definition: Ply.h:294
PlyValueVertex operator-(PlyValueVertex p) const
Definition: Ply.h:304
PlyValueVertex operator+(PlyValueVertex p) const
Definition: Ply.h:303
PlyValueVertex operator*(_Real s) const
Definition: Ply.h:305
PlyValueVertex(Point3D< Real > p, Real v)
Definition: Ply.h:302
static const int ReadComponents
Definition: Ply.h:293
PlyValueVertex & operator+=(PlyValueVertex p)
Definition: Ply.h:307
PlyValueVertex Wrapper
Definition: Ply.h:291
Point3D< Real > point
Definition: Ply.h:298
PlyValueVertex & operator-=(PlyValueVertex p)
Definition: Ply.h:308
Definition: Ply.h:252
PlyVertex & operator*=(_Real s)
Definition: Ply.h:271
static const int WriteComponents
Definition: Ply.h:257
static const int ReadComponents
Definition: Ply.h:256
static PlyProperty WriteProperties[]
Definition: Ply.h:259
PlyVertex & operator+=(PlyVertex p)
Definition: Ply.h:269
PlyVertex operator/(_Real s) const
Definition: Ply.h:268
PlyVertex Wrapper
Definition: Ply.h:254
PlyVertex & operator/=(_Real s)
Definition: Ply.h:272
PlyVertex operator-(PlyVertex p) const
Definition: Ply.h:266
PlyVertex(Point3D< Real > p)
Definition: Ply.h:264
static PlyProperty ReadProperties[]
Definition: Ply.h:258
PlyVertex operator+(PlyVertex p) const
Definition: Ply.h:265
PlyVertex operator*(_Real s) const
Definition: Ply.h:267
Point3D< Real > point
Definition: Ply.h:261
PlyVertex(void)
Definition: Ply.h:263
PlyVertex & operator-=(PlyVertex p)
Definition: Ply.h:270
#define offsetof(STRUCTURE, FIELD)
Definition: sqlite3.c:14241
Definition: Ply.h:118
void * other_props
Definition: Ply.h:119
Definition: Ply.h:122
OtherData ** other_data
Definition: Ply.h:125
char * elem_name
Definition: Ply.h:123
PlyOtherProp * other_props
Definition: Ply.h:126
int elem_count
Definition: Ply.h:124
_PlyColorAndValueVertex & operator/=(_Real s)
Definition: Ply.h:464
_PlyColorAndValueVertex & operator-=(_PlyColorAndValueVertex p)
Definition: Ply.h:462
_PlyColorAndValueVertex & operator+=(_PlyColorAndValueVertex p)
Definition: Ply.h:461
_PlyColorAndValueVertex operator-(_PlyColorAndValueVertex p) const
Definition: Ply.h:458
_PlyColorAndValueVertex(Point3D< Real > p, Point3D< Real > c, Real v)
Definition: Ply.h:446
_PlyColorAndValueVertex operator/(_Real s) const
Definition: Ply.h:460
_PlyColorAndValueVertex(PlyColorAndValueVertex< Real > p)
Definition: Ply.h:447
_PlyColorAndValueVertex operator+(_PlyColorAndValueVertex p) const
Definition: Ply.h:457
_PlyColorAndValueVertex & operator*=(_Real s)
Definition: Ply.h:463
_PlyColorAndValueVertex operator*(_Real s) const
Definition: Ply.h:459
_PlyColorVertex operator*(_Real s) const
Definition: Ply.h:390
_PlyColorVertex operator/(_Real s) const
Definition: Ply.h:391
Point3D< Real > point
Definition: Ply.h:376
_PlyColorVertex(Point3D< Real > p, Point3D< Real > c)
Definition: Ply.h:378
_PlyColorVertex & operator-=(_PlyColorVertex p)
Definition: Ply.h:393
_PlyColorVertex operator-(_PlyColorVertex p) const
Definition: Ply.h:389
Point3D< Real > color
Definition: Ply.h:376
_PlyColorVertex(PlyColorVertex< Real > p)
Definition: Ply.h:379
_PlyColorVertex & operator*=(_Real s)
Definition: Ply.h:394
_PlyColorVertex & operator+=(_PlyColorVertex p)
Definition: Ply.h:392
_PlyColorVertex operator+(_PlyColorVertex p) const
Definition: Ply.h:388
_PlyColorVertex & operator/=(_Real s)
Definition: Ply.h:395
int other_offset
Definition: Ply.h:107
int num
Definition: Ply.h:102
int other_size
Definition: Ply.h:108
char * name
Definition: Ply.h:101
char * store_prop
Definition: Ply.h:106
int size
Definition: Ply.h:103
PlyProperty ** props
Definition: Ply.h:105
int nprops
Definition: Ply.h:104
Definition: Ply.h:234
int segment
Definition: Ply.h:237
int * vertices
Definition: Ply.h:236
unsigned char nr_vertices
Definition: Ply.h:235
Definition: Ply.h:134
int num_comments
Definition: Ply.h:140
int nelems
Definition: Ply.h:138
float version
Definition: Ply.h:137
char ** obj_info
Definition: Ply.h:143
PlyElement * which_elem
Definition: Ply.h:144
PlyElement ** elems
Definition: Ply.h:139
int num_obj_info
Definition: Ply.h:142
int file_type
Definition: Ply.h:136
PlyOtherElems * other_elems
Definition: Ply.h:145
char ** comments
Definition: Ply.h:141
FILE * fp
Definition: Ply.h:135
OtherElem * other_list
Definition: Ply.h:131
int num_elems
Definition: Ply.h:130
char * name
Definition: Ply.h:112
PlyProperty ** props
Definition: Ply.h:115
int size
Definition: Ply.h:113
int nprops
Definition: Ply.h:114
int external_type
Definition: Ply.h:89
int count_offset
Definition: Ply.h:96
int count_external
Definition: Ply.h:94
char * name
Definition: Ply.h:88
int count_internal
Definition: Ply.h:95
int internal_type
Definition: Ply.h:90
int is_list
Definition: Ply.h:93
int offset
Definition: Ply.h:91
XForm4x4 inverse(void) const
Definition: Geometry.h:158
XForm4x4 transpose(void) const
Definition: Geometry.h:144
Definition: lsd.c:149