ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
PlyFile.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "Ply.h"
Include dependency graph for PlyFile.cpp:

Go to the source code of this file.

Classes

union  endian_test_type
 

Macros

#define NO_OTHER_PROPS   -1
 
#define DONT_STORE_PROP   0
 
#define STORE_PROP   1
 
#define OTHER_PROP   0
 
#define NAMED_PROP   1
 
#define BIG_STRING   4096
 

Functions

int equal_strings (const char *, const char *)
 
PlyElementfind_element (PlyFile *, const char *)
 
PlyPropertyfind_property (PlyElement *, const char *, int *)
 
void write_scalar_type (FILE *, int)
 
char ** get_words (FILE *, int *, char **)
 
char ** old_get_words (FILE *, int *)
 
void write_binary_item (FILE *, int, int, unsigned int, double, int)
 
void write_ascii_item (FILE *, int, unsigned int, double, int)
 
double old_write_ascii_item (FILE *, char *, int)
 
void add_element (PlyFile *, char **)
 
void add_property (PlyFile *, char **)
 
void add_comment (PlyFile *, char *)
 
void add_obj_info (PlyFile *, char *)
 
void copy_property (PlyProperty *, PlyProperty *)
 
void store_item (char *, int, int, unsigned int, double)
 
void get_stored_item (void *, int, int *, unsigned int *, double *)
 
double get_item_value (char *, int)
 
void get_ascii_item (char *, int, int *, unsigned int *, double *)
 
void get_binary_item (FILE *, int, int, int *, unsigned int *, double *)
 
void ascii_get_element (PlyFile *, char *)
 
void binary_get_element (PlyFile *, char *)
 
char * my_alloc (int, int, const char *)
 
void get_native_binary_type ()
 
void swap_bytes (char *, int)
 
void check_types ()
 
PlyFileply_write_custom (FILE *fp, int nelems, const char **elem_names, int file_type)
 
PlyFileply_open_for_writing (char *filename, int nelems, const char **elem_names, int file_type, float *version)
 
void ply_describe_element (PlyFile *plyfile, char *elem_name, int nelems, int nprops, PlyProperty *prop_list)
 
void ply_describe_property (PlyFile *plyfile, const char *elem_name, PlyProperty *prop)
 
void ply_describe_other_properties (PlyFile *plyfile, PlyOtherProp *other, int offset)
 
void ply_element_count (PlyFile *plyfile, const char *elem_name, int nelems)
 
void ply_header_complete (PlyFile *plyfile)
 
void ply_put_element_setup (PlyFile *plyfile, const char *elem_name)
 
void ply_put_element (PlyFile *plyfile, void *elem_ptr)
 
void ply_put_comment (PlyFile *plyfile, char *comment)
 
void ply_put_obj_info (PlyFile *plyfile, char *obj_info)
 
PlyFileply_read_custom (FILE *fp, int *nelems, char ***elem_names)
 
PlyFileply_open_for_reading (char *filename, int *nelems, char ***elem_names, int *file_type, float *version)
 
PlyProperty ** ply_get_element_description (PlyFile *plyfile, char *elem_name, int *nelems, int *nprops)
 
void ply_get_element_setup (PlyFile *plyfile, char *elem_name, int nprops, PlyProperty *prop_list)
 
int ply_get_property (PlyFile *plyfile, char *elem_name, PlyProperty *prop)
 
void ply_get_element (PlyFile *plyfile, void *elem_ptr)
 
char ** ply_get_comments (PlyFile *plyfile, int *num_comments)
 
char ** ply_get_obj_info (PlyFile *plyfile, int *num_obj_info)
 
void setup_other_props (PlyElement *elem)
 
PlyOtherPropply_get_other_properties (PlyFile *plyfile, char *elem_name, int offset)
 
PlyOtherElemsply_get_other_element (PlyFile *plyfile, char *elem_name, int elem_count)
 
void ply_describe_other_elements (PlyFile *plyfile, PlyOtherElems *other_elems)
 
void ply_put_other_elements (PlyFile *plyfile)
 
void ply_free_other_elements (PlyOtherElems *other_elems)
 
void ply_close_custom (PlyFile *plyfile)
 
void ply_get_info (PlyFile *ply, float *version, int *file_type)
 
int get_prop_type (char *type_name)
 

Variables

const char * type_names []
 
int ply_type_size []
 
static int native_binary_type = -1
 
static int types_checked = 0
 

Macro Definition Documentation

◆ BIG_STRING

#define BIG_STRING   4096

◆ DONT_STORE_PROP

#define DONT_STORE_PROP   0

Definition at line 95 of file PlyFile.cpp.

◆ NAMED_PROP

#define NAMED_PROP   1

Definition at line 99 of file PlyFile.cpp.

◆ NO_OTHER_PROPS

#define NO_OTHER_PROPS   -1

Definition at line 93 of file PlyFile.cpp.

◆ OTHER_PROP

#define OTHER_PROP   0

Definition at line 98 of file PlyFile.cpp.

◆ STORE_PROP

#define STORE_PROP   1

Definition at line 96 of file PlyFile.cpp.

Function Documentation

◆ add_comment()

void add_comment ( PlyFile plyfile,
char *  line 
)

Definition at line 2657 of file PlyFile.cpp.

References ply_put_comment().

Referenced by ply_read_custom().

◆ add_element()

void add_element ( PlyFile plyfile,
char **  words 
)

◆ add_obj_info()

void add_obj_info ( PlyFile plyfile,
char *  line 
)

Definition at line 2678 of file PlyFile.cpp.

References ply_put_obj_info().

Referenced by ply_read_custom().

◆ add_property()

◆ ascii_get_element()

◆ binary_get_element()

◆ check_types()

void check_types ( )

◆ copy_property()

◆ equal_strings()

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

◆ find_element()

◆ find_property()

PlyProperty * find_property ( PlyElement elem,
const char *  prop_name,
int *  index 
)

◆ get_ascii_item()

void get_ascii_item ( char *  word,
int  type,
int *  int_val,
unsigned int *  uint_val,
double *  double_val 
)

◆ get_binary_item()

void get_binary_item ( FILE *  fp,
int  file_type,
int  type,
int *  int_val,
unsigned int *  uint_val,
double *  double_val 
)

◆ get_item_value()

double get_item_value ( char *  item,
int  type 
)

◆ get_native_binary_type()

void get_native_binary_type ( )

◆ get_prop_type()

int get_prop_type ( char *  type_name)

Definition at line 2591 of file PlyFile.cpp.

References equal_strings(), PLY_END_TYPE, PLY_START_TYPE, and type_names.

Referenced by add_property().

◆ get_stored_item()

void get_stored_item ( void *  ptr,
int  type,
int *  int_val,
unsigned int *  uint_val,
double *  double_val 
)

◆ get_words()

char ** get_words ( FILE *  fp,
int *  nwords,
char **  orig_line 
)

Definition at line 1862 of file PlyFile.cpp.

References BIG_STRING, myalloc, NULL, and result.

Referenced by ascii_get_element(), and ply_read_custom().

◆ my_alloc()

char * my_alloc ( int  size,
int  lnum,
const char *  fname 
)

Definition at line 2718 of file PlyFile.cpp.

References size.

◆ old_get_words()

char** old_get_words ( FILE *  ,
int *   
)

◆ old_write_ascii_item()

double old_write_ascii_item ( FILE *  fp,
char *  item,
int  type 
)

◆ 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()

◆ setup_other_props()

◆ store_item()

void store_item ( char *  item,
int  type,
int  int_val,
unsigned int  uint_val,
double  double_val 
)

◆ swap_bytes()

void swap_bytes ( char *  bytes,
int  num_bytes 
)

Definition at line 1782 of file PlyFile.cpp.

References bytes.

Referenced by get_binary_item(), and write_binary_item().

◆ write_ascii_item()

void write_ascii_item ( FILE *  fp,
int  int_val,
unsigned int  uint_val,
double  double_val,
int  type 
)

◆ write_binary_item()

void write_binary_item ( FILE *  fp,
int  file_type,
int  int_val,
unsigned int  uint_val,
double  double_val,
int  type 
)

◆ write_scalar_type()

void write_scalar_type ( FILE *  fp,
int  code 
)

Definition at line 1759 of file PlyFile.cpp.

References PLY_END_TYPE, and type_names.

Referenced by ply_header_complete().

Variable Documentation

◆ native_binary_type

int native_binary_type = -1
static

◆ ply_type_size

int ply_type_size[]
Initial value:
= {
0,
1,
2,
4,
1,
2,
4,
4,
8,
1,
1,
2,
2,
4,
4,
4,
8
}

Definition at line 63 of file PlyFile.cpp.

Referenced by ascii_get_element(), binary_get_element(), check_types(), get_binary_item(), ply_put_element(), setup_other_props(), and write_binary_item().

◆ type_names

const char* type_names[]
Initial value:
= {
"invalid",
"char",
"short",
"int",
"uchar",
"ushort",
"uint",
"float",
"double",
"int8",
"uint8",
"int16",
"uint16",
"int32",
"uint32",
"float32",
"float64",
}

Definition at line 41 of file PlyFile.cpp.

Referenced by get_prop_type(), and write_scalar_type().

◆ types_checked

int types_checked = 0
static

Definition at line 91 of file PlyFile.cpp.

Referenced by check_types(), ply_read_custom(), and ply_write_custom().