PLY reader/writer
1.2.0
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Enumerations
Enumerator
header.h
1
// A C++ reader/writer of .ply files.
2
// The header and its elements.
3
// These describe how the data is stored in the file/stream.
4
//
5
// Adapted to C++ streams by Thijs van Lankveld.
6
7
/*
8
Header for PLY polygon files.
9
10
- Greg Turk
11
12
A PLY file contains a single polygonal _object_.
13
14
An object is composed of lists of _elements_. Typical elements are
15
vertices, faces, edges and materials.
16
17
Each type of element for a given object has one or more _properties_
18
associated with the element type. For instance, a vertex element may
19
have as properties three floating-point values x,y,z and three unsigned
20
chars for red, green and blue.
21
22
-----------------------------------------------------------------------
23
24
Copyright (c) 1998 Georgia Institute of Technology. All rights reserved.
25
26
Permission to use, copy, modify and distribute this software and its
27
documentation for any purpose is hereby granted without fee, provided
28
that the above copyright notice and this permission notice appear in
29
all copies of this software and that you do not sell the software.
30
31
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
32
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
33
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
34
*/
35
36
37
#ifndef __PLY_HEADER_H__
38
#define __PLY_HEADER_H__
39
40
41
#include "base.h"
42
#include <iterator>
43
#include <string>
44
#include <vector>
45
46
namespace
PLY {
48
52
struct
Property
{
53
std::string
name
;
54
Variable_type
type
;
55
56
Scalar_type
data_type
;
57
Scalar_type
size_type
;
58
59
bool
store
;
60
62
Property
():
type
(
SCALAR
),
63
data_type
(
StartType
),
64
size_type
(
StartType
),
65
store
(true) {}
67
74
Property
(
const
char
* n,
const
Variable_type
& t,
75
const
Scalar_type
& dt,
const
Scalar_type
& st =
StartType
)
76
:
name
(n),
type
(t),
data_type
(dt),
size_type
(st),
store
(true) {}
77
};
// struct Property
78
79
81
89
struct
Element
{
90
std::string
name
;
91
size_t
num
;
92
std::vector<Property>
props
;
93
94
bool
store
;
95
97
Element
():
num
(0),
store
(true) {}
99
101
Element
(
const
char
* n):
name
(n),
num
(0),
store
(true) {}
102
104
106
inline
void
add_property
(
const
Property
& prop) {
props
.push_back(prop); }
107
109
113
bool
find_index
(
const
char
*
name
,
size_t
& index)
const
;
114
116
120
Property
*
find_property
(
const
char
*
name
);
121
};
// struct Element
122
123
125
133
struct
Header
{
134
private
:
135
Stream_type
system_type;
// The binary mode of the system.
136
137
Stream_type
is_LE()
const
;
138
139
public
:
140
float
version
;
141
Stream_type
stream_type
;
142
143
std::vector<Element>
elements
;
144
std::vector<std::string>
comments
;
145
std::vector<std::string>
obj_info
;
146
148
150
Header
():
stream_type
(
ASCII
),
version
(1.0), system_type(is_LE()) {}
151
153
155
Stream_type
system
()
const
{
return
system_type;}
156
158
160
inline
void
add_element
(
const
Element
& elem) {
elements
.push_back(elem);}
161
163
167
bool
find_index
(
const
char
* name,
size_t
& index)
const
;
168
170
174
Element
*
find_element
(
const
char
* name);
175
177
184
void
apply_stream_type
(
char
* ptr,
size_t
n);
185
};
// struct Header
186
187
188
// Checks if a character is white-space.
189
struct
WhiteSpace {
190
WhiteSpace() {}
191
bool
operator()(
char
c)
const
;
192
};
// struct WhiteSpace
193
194
195
/* The line Tokenizer extracts words from a line based
196
* on white-space. Any type of white-space is considered
197
* to separate different words.
198
*/
199
struct
Tokenizer {
200
// The current line.
201
char
* line;
202
203
// Constructor.
204
Tokenizer() {}
205
206
// Get the next word.
207
bool
next(
char
* word);
208
};
// class Tokenizer
209
}
// namespace PLY
210
211
212
#endif // __PLY_HEADER_H__
Generated on Fri Jul 26 2013 14:39:58 for PLY reader/writer by
1.8.4