ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Ply.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "Geometry.h"
#include <vector>
Include dependency graph for Ply.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PlyProperty
 
struct  PlyElement
 
struct  PlyOtherProp
 
struct  OtherData
 
struct  OtherElem
 
struct  PlyOtherElems
 
struct  PlyFile
 
struct  PlyFace
 
class  PlyVertex< Real >
 
class  PlyValueVertex< Real >
 
class  PlyOrientedVertex< Real >
 
class  PlyColorVertex< Real >
 
struct  PlyColorVertex< Real >::_PlyColorVertex
 
class  PlyColorAndValueVertex< Real >
 
struct  PlyColorAndValueVertex< Real >::_PlyColorAndValueVertex
 

Macros

#define USE_PLY_WRAPPER   1
 
#define _strdup   strdup
 
#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_BINARY_NATIVE   4 /* binary PLY file, same endianness as current architecture */
 
#define PLY_OKAY   0 /* ply routine worked okay */
 
#define PLY_ERROR   -1 /* error in ply routine */
 
#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_INT_8   9
 
#define PLY_UINT_8   10
 
#define PLY_INT_16   11
 
#define PLY_UINT_16   12
 
#define PLY_INT_32   13
 
#define PLY_UINT_32   14
 
#define PLY_FLOAT_32   15
 
#define PLY_FLOAT_64   16
 
#define PLY_END_TYPE   17
 
#define PLY_SCALAR   0
 
#define PLY_LIST   1
 
#define PLY_STRIP_COMMENT_HEADER   0
 
#define myalloc(mem_size)   my_alloc((mem_size), __LINE__, __FILE__)
 
#define REALLOCN(PTR, TYPE, OLD_N, NEW_N)
 
#define ALLOCN(PTR, TYPE, N)
 
#define FREE(PTR)   { free((PTR)); (PTR) = NULL; }
 

Typedefs

typedef struct PlyProperty PlyProperty
 
typedef struct PlyElement PlyElement
 
typedef struct PlyOtherProp PlyOtherProp
 
typedef struct OtherData OtherData
 
typedef struct OtherElem OtherElem
 
typedef struct PlyOtherElems PlyOtherElems
 
typedef struct PlyFile PlyFile
 
typedef struct PlyFace PlyFace
 

Functions

char * my_alloc ()
 
PlyFileply_write_custom (FILE *, int, const char **, int)
 
PlyFileply_open_for_writing (char *, int, const char **, int, float *)
 
void ply_describe_element (PlyFile *, char *, int, int, PlyProperty *)
 
void ply_describe_property (PlyFile *, const char *, PlyProperty *)
 
void ply_element_count (PlyFile *, const char *, int)
 
void ply_header_complete (PlyFile *)
 
void ply_put_element_setup (PlyFile *, const char *)
 
void ply_put_element (PlyFile *, void *)
 
void ply_put_comment (PlyFile *, char *)
 
void ply_put_obj_info (PlyFile *, char *)
 
PlyFileply_read_custom (FILE *, int *, char ***)
 
PlyFileply_open_for_reading (char *, int *, char ***, int *, float *)
 
PlyProperty ** ply_get_element_description (PlyFile *, char *, int *, int *)
 
void ply_get_element_setup (PlyFile *, char *, int, PlyProperty *)
 
int ply_get_property (PlyFile *, char *, PlyProperty *)
 
PlyOtherPropply_get_other_properties (PlyFile *, char *, int)
 
void ply_get_element (PlyFile *, void *)
 
char ** ply_get_comments (PlyFile *, int *)
 
char ** ply_get_obj_info (PlyFile *, int *)
 
void ply_close_custom (PlyFile *)
 
void ply_get_info (PlyFile *, float *, int *)
 
PlyOtherElemsply_get_other_element (PlyFile *, char *, int)
 
void ply_describe_other_elements (PlyFile *, PlyOtherElems *)
 
void ply_put_other_elements (PlyFile *)
 
void ply_free_other_elements (PlyOtherElems *)
 
void ply_describe_other_properties (PlyFile *, PlyOtherProp *, int)
 
int equal_strings (const char *, const char *)
 
template<class Real >
int PLYType (void)
 
template<>
int PLYType< int > (void)
 
template<>
int PLYType< char > (void)
 
template<>
int PLYType< unsigned char > (void)
 
template<>
int PLYType< float > (void)
 
template<>
int PLYType< double > (void)
 
template<class Real , class _Real >
PlyVertex< Real > operator* (XForm4x4< _Real > xForm, PlyVertex< Real > v)
 
template<class Real , class _Real >
PlyValueVertex< Real > operator* (XForm4x4< _Real > xForm, PlyValueVertex< Real > v)
 
template<class Real , class _Real >
PlyOrientedVertex< Real > operator* (XForm4x4< _Real > xForm, PlyOrientedVertex< Real > v)
 
template<class Real , class _Real >
PlyColorVertex< Real > operator* (XForm4x4< _Real > xForm, PlyColorVertex< Real > v)
 
template<class Real , class _Real >
PlyColorAndValueVertex< Real > operator* (XForm4x4< _Real > xForm, PlyColorAndValueVertex< Real > v)
 
template<class Vertex , class Real >
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())
 
template<class Vertex , class Real >
int PlyWritePolygons (char *fileName, CoredMeshData< Vertex > *mesh, int file_type, char **comments=NULL, int commentNum=0, XForm4x4< Real > xForm=XForm4x4< Real >::Identity())
 
bool PlyReadHeader (char *fileName, PlyProperty *properties, int propertyNum, bool *readFlags, int &file_type)
 
bool PlyReadHeader (char *fileName, PlyProperty *properties, int propertyNum, bool *readFlags)
 
template<class Vertex >
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)
 
template<class Vertex >
int PlyWritePolygons (char *fileName, const std::vector< Vertex > &vertices, const std::vector< std::vector< int > > &polygons, PlyProperty *properties, int propertyNum, int file_type, char **comments=NULL, const int &commentNum=0)
 
int PlyDefaultFileType (void)
 

Variables

static PlyProperty face_props []
 

Macro Definition Documentation

◆ _strdup

#define _strdup   strdup

Definition at line 39 of file Ply.h.

◆ ALLOCN

#define ALLOCN (   PTR,
  TYPE,
 
)
Value:
{ (PTR) = (TYPE *) calloc(((unsigned)(N)),sizeof(TYPE));\
if ((PTR) == NULL) { \
fprintf(stderr, "Memory allocation failed on line %d in %s\n", \
__LINE__, __FILE__); \
exit(-1); \
} \
}
#define NULL

Definition at line 174 of file Ply.h.

◆ FREE

#define FREE (   PTR)    { free((PTR)); (PTR) = NULL; }

Definition at line 184 of file Ply.h.

◆ myalloc

#define myalloc (   mem_size)    my_alloc((mem_size), __LINE__, __FILE__)

Definition at line 150 of file Ply.h.

◆ PLY_ASCII

#define PLY_ASCII   1 /* ascii PLY file */

Definition at line 51 of file Ply.h.

◆ PLY_BINARY_BE

#define PLY_BINARY_BE   2 /* binary PLY file, big endian */

Definition at line 52 of file Ply.h.

◆ PLY_BINARY_LE

#define PLY_BINARY_LE   3 /* binary PLY file, little endian */

Definition at line 53 of file Ply.h.

◆ PLY_BINARY_NATIVE

#define PLY_BINARY_NATIVE   4 /* binary PLY file, same endianness as current architecture */

Definition at line 54 of file Ply.h.

◆ PLY_CHAR

#define PLY_CHAR   1

Definition at line 62 of file Ply.h.

◆ PLY_DOUBLE

#define PLY_DOUBLE   8

Definition at line 69 of file Ply.h.

◆ PLY_END_TYPE

#define PLY_END_TYPE   17

Definition at line 79 of file Ply.h.

◆ PLY_ERROR

#define PLY_ERROR   -1 /* error in ply routine */

Definition at line 57 of file Ply.h.

◆ PLY_FLOAT

#define PLY_FLOAT   7

Definition at line 68 of file Ply.h.

◆ PLY_FLOAT_32

#define PLY_FLOAT_32   15

Definition at line 76 of file Ply.h.

◆ PLY_FLOAT_64

#define PLY_FLOAT_64   16

Definition at line 77 of file Ply.h.

◆ PLY_INT

#define PLY_INT   3

Definition at line 64 of file Ply.h.

◆ PLY_INT_16

#define PLY_INT_16   11

Definition at line 72 of file Ply.h.

◆ PLY_INT_32

#define PLY_INT_32   13

Definition at line 74 of file Ply.h.

◆ PLY_INT_8

#define PLY_INT_8   9

Definition at line 70 of file Ply.h.

◆ PLY_LIST

#define PLY_LIST   1

Definition at line 82 of file Ply.h.

◆ PLY_OKAY

#define PLY_OKAY   0 /* ply routine worked okay */

Definition at line 56 of file Ply.h.

◆ PLY_SCALAR

#define PLY_SCALAR   0

Definition at line 81 of file Ply.h.

◆ PLY_SHORT

#define PLY_SHORT   2

Definition at line 63 of file Ply.h.

◆ PLY_START_TYPE

#define PLY_START_TYPE   0

Definition at line 61 of file Ply.h.

◆ PLY_STRIP_COMMENT_HEADER

#define PLY_STRIP_COMMENT_HEADER   0

Definition at line 84 of file Ply.h.

◆ PLY_UCHAR

#define PLY_UCHAR   4

Definition at line 65 of file Ply.h.

◆ PLY_UINT

#define PLY_UINT   6

Definition at line 67 of file Ply.h.

◆ PLY_UINT_16

#define PLY_UINT_16   12

Definition at line 73 of file Ply.h.

◆ PLY_UINT_32

#define PLY_UINT_32   14

Definition at line 75 of file Ply.h.

◆ PLY_UINT_8

#define PLY_UINT_8   10

Definition at line 71 of file Ply.h.

◆ PLY_USHORT

#define PLY_USHORT   5

Definition at line 66 of file Ply.h.

◆ REALLOCN

#define REALLOCN (   PTR,
  TYPE,
  OLD_N,
  NEW_N 
)
Value:
{ \
if ((OLD_N) == 0) \
{ ALLOCN((PTR),TYPE,(NEW_N));} \
else \
{ \
(PTR) = (TYPE *)realloc((PTR),(NEW_N)*sizeof(TYPE)); \
if (((PTR) == NULL) && ((NEW_N) != 0)) \
{ \
fprintf(stderr, "Memory reallocation failed on line %d in %s\n", \
__LINE__, __FILE__); \
fprintf(stderr, " tried to reallocate %d->%d\n", \
(OLD_N), (NEW_N)); \
exit(-1); \
} \
if ((NEW_N)>(OLD_N)) \
memset((char *)(PTR)+(OLD_N)*sizeof(TYPE), 0, \
((NEW_N)-(OLD_N))*sizeof(TYPE)); \
} \
}
#define ALLOCN(PTR, TYPE, N)
Definition: Ply.h:174

Definition at line 153 of file Ply.h.

◆ USE_PLY_WRAPPER

#define USE_PLY_WRAPPER   1

Definition at line 36 of file Ply.h.

Typedef Documentation

◆ OtherData

typedef struct OtherData OtherData

◆ OtherElem

typedef struct OtherElem OtherElem

◆ PlyElement

typedef struct PlyElement PlyElement

◆ PlyFace

typedef struct PlyFace PlyFace

◆ PlyFile

typedef struct PlyFile PlyFile

◆ PlyOtherElems

typedef struct PlyOtherElems PlyOtherElems

◆ PlyOtherProp

typedef struct PlyOtherProp PlyOtherProp

◆ PlyProperty

typedef struct PlyProperty PlyProperty

Function Documentation

◆ equal_strings()

int equal_strings ( const char *  s1,
const char *  s2 
)

◆ my_alloc()

char* my_alloc ( )

◆ operator*() [1/5]

template<class Real , class _Real >
PlyColorAndValueVertex< Real > operator* ( XForm4x4< _Real >  xForm,
PlyColorAndValueVertex< Real >  v 
)

◆ operator*() [2/5]

template<class Real , class _Real >
PlyColorVertex< Real > operator* ( XForm4x4< _Real >  xForm,
PlyColorVertex< Real >  v 
)

Definition at line 414 of file Ply.h.

References PlyColorVertex< Real >::color, and PlyColorVertex< Real >::point.

◆ operator*() [3/5]

template<class Real , class _Real >
PlyOrientedVertex< Real > operator* ( XForm4x4< _Real >  xForm,
PlyOrientedVertex< Real >  v 
)

◆ operator*() [4/5]

template<class Real , class _Real >
PlyValueVertex< Real > operator* ( XForm4x4< _Real >  xForm,
PlyValueVertex< Real >  v 
)

Definition at line 312 of file Ply.h.

References PlyValueVertex< Real >::point, and PlyValueVertex< Real >::value.

◆ operator*() [5/5]

template<class Real , class _Real >
PlyVertex< Real > operator* ( XForm4x4< _Real >  xForm,
PlyVertex< Real >  v 
)

Definition at line 274 of file Ply.h.

References PlyVertex< Real >::point.

◆ ply_close_custom()

void ply_close_custom ( PlyFile plyfile)

Definition at line 1425 of file PlyFile.cpp.

References PlyFile::fp.

Referenced by PlyReadHeader(), PlyReadPolygons(), and PlyWritePolygons().

◆ ply_describe_element()

void ply_describe_element ( PlyFile plyfile,
char *  elem_name,
int  nelems,
int  nprops,
PlyProperty prop_list 
)

◆ ply_describe_other_elements()

◆ ply_describe_other_properties()

◆ ply_describe_property()

void ply_describe_property ( PlyFile plyfile,
const char *  elem_name,
PlyProperty prop 
)

◆ ply_element_count()

void ply_element_count ( PlyFile plyfile,
const char *  elem_name,
int  nelems 
)

Definition at line 445 of file PlyFile.cpp.

References find_element(), NULL, and PlyElement::num.

Referenced by PlyWritePolygons().

◆ ply_free_other_elements()

void ply_free_other_elements ( PlyOtherElems other_elems)

Definition at line 1405 of file PlyFile.cpp.

Referenced by PlyReadHeader(), and PlyReadPolygons().

◆ ply_get_comments()

char** ply_get_comments ( PlyFile plyfile,
int *  num_comments 
)

Definition at line 1074 of file PlyFile.cpp.

References PlyFile::comments, and PlyFile::num_comments.

◆ ply_get_element()

void ply_get_element ( PlyFile plyfile,
void *  elem_ptr 
)

◆ ply_get_element_description()

PlyProperty** ply_get_element_description ( PlyFile plyfile,
char *  elem_name,
int *  nelems,
int *  nprops 
)

◆ ply_get_element_setup()

void ply_get_element_setup ( PlyFile plyfile,
char *  elem_name,
int  nprops,
PlyProperty prop_list 
)

◆ ply_get_info()

void ply_get_info ( PlyFile ply,
float *  version,
int *  file_type 
)

Definition at line 1445 of file PlyFile.cpp.

References PlyFile::file_type, NULL, version, and PlyFile::version.

◆ ply_get_obj_info()

char** ply_get_obj_info ( PlyFile plyfile,
int *  num_obj_info 
)

Definition at line 1093 of file PlyFile.cpp.

References PlyFile::num_obj_info, and PlyFile::obj_info.

◆ ply_get_other_element()

◆ ply_get_other_properties()

◆ ply_get_property()

◆ ply_header_complete()

◆ ply_open_for_reading()

PlyFile* ply_open_for_reading ( char *  filename,
int *  nelems,
char ***  elem_names,
int *  file_type,
float *  version 
)

◆ ply_open_for_writing()

PlyFile* ply_open_for_writing ( char *  filename,
int  nelems,
const char **  elem_names,
int  file_type,
float *  version 
)

Definition at line 240 of file PlyFile.cpp.

References filename, myalloc, name, NULL, ply_write_custom(), version, and PlyFile::version.

Referenced by PlyWritePolygons().

◆ ply_put_comment()

void ply_put_comment ( PlyFile plyfile,
char *  comment 
)

Definition at line 682 of file PlyFile.cpp.

References _strdup, PlyFile::comments, myalloc, and PlyFile::num_comments.

Referenced by add_comment(), and PlyWritePolygons().

◆ ply_put_element()

◆ ply_put_element_setup()

void ply_put_element_setup ( PlyFile plyfile,
const char *  elem_name 
)

Definition at line 545 of file PlyFile.cpp.

References find_element(), NULL, and PlyFile::which_elem.

Referenced by ply_put_other_elements(), and PlyWritePolygons().

◆ ply_put_obj_info()

void ply_put_obj_info ( PlyFile plyfile,
char *  obj_info 
)

Definition at line 706 of file PlyFile.cpp.

References _strdup, myalloc, PlyFile::num_obj_info, and PlyFile::obj_info.

Referenced by add_obj_info().

◆ ply_put_other_elements()

◆ ply_read_custom()

◆ ply_write_custom()

◆ PlyDefaultFileType()

int PlyDefaultFileType ( void  )
inline

Definition at line 917 of file Ply.h.

References PLY_ASCII.

◆ PlyReadHeader() [1/2]

bool PlyReadHeader ( char *  fileName,
PlyProperty properties,
int  propertyNum,
bool *  readFlags 
)
inline

Definition at line 596 of file Ply.h.

References PlyReadHeader().

◆ PlyReadHeader() [2/2]

◆ PlyReadPolygons()

template<class Vertex >
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 
)

◆ PLYType()

template<class Real >
int PLYType ( void  )
inline

Definition at line 231 of file Ply.h.

◆ PLYType< char >()

template<>
int PLYType< char > ( void  )
inline

Definition at line 227 of file Ply.h.

References PLY_CHAR.

◆ PLYType< double >()

template<>
int PLYType< double > ( void  )
inline

Definition at line 230 of file Ply.h.

References PLY_DOUBLE.

◆ PLYType< float >()

template<>
int PLYType< float > ( void  )
inline

Definition at line 229 of file Ply.h.

References PLY_FLOAT.

◆ PLYType< int >()

template<>
int PLYType< int > ( void  )
inline

Definition at line 226 of file Ply.h.

References PLY_INT.

◆ PLYType< unsigned char >()

template<>
int PLYType< unsigned char > ( void  )
inline

Definition at line 228 of file Ply.h.

References PLY_UCHAR.

◆ PlyWritePolygons() [1/3]

template<class Vertex >
int PlyWritePolygons ( char *  fileName,
const std::vector< Vertex > &  vertices,
const std::vector< std::vector< int > > &  polygons,
PlyProperty properties,
int  propertyNum,
int  file_type,
char **  comments = NULL,
const int &  commentNum = 0 
)

◆ PlyWritePolygons() [2/3]

◆ PlyWritePolygons() [3/3]

Variable Documentation

◆ face_props

PlyProperty face_props[]
static
Initial value:
=
{
{ strdup ( "vertex_indices" ) , 3 , 3 , offsetof( PlyFace , vertices ) , 1 , 4 , 4 , offsetof(PlyFace,nr_vertices) },
}
#define offsetof(STRUCTURE, FIELD)
Definition: sqlite3.c:14241
Definition: Ply.h:234

Definition at line 239 of file Ply.h.

Referenced by PlyReadPolygons(), and PlyWritePolygons().