PLY reader/writer
1.2.0
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Enumerations
Enumerator
object.h
1
// A C++ reader/writer of .ply files.
2
// Data objects.
3
// These contain the actual data.
4
// Generally, the user will implement subclasses
5
// for their own object types.
6
//
7
//Copyright (C) 2013 INRIA - Sophia Antipolis
8
//
9
//This program is free software: you can redistribute it and/or modify
10
//it under the terms of the GNU General Public License as published by
11
//the Free Software Foundation, either version 3 of the License, or
12
//(at your option) any later version.
13
//
14
//This program is distributed in the hope that it will be useful,
15
//but WITHOUT ANY WARRANTY; without even the implied warranty of
16
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
//GNU General Public License for more details.
18
//
19
//You should have received a copy of the GNU General Public License
20
//along with this program. If not, see <http://www.gnu.org/licenses/>.
21
//
22
// Author(s): Thijs van Lankveld
23
24
25
#ifndef __PLY_OBJECT_H__
26
#define __PLY_OBJECT_H__
27
28
29
#include "header.h"
30
31
namespace
PLY {
33
36
struct
Value
{
38
39
44
virtual
bool
get_scalar
(
const
Property
& prop,
double
& value)
const
{
return
false
;}
45
47
51
virtual
bool
set_scalar
(
const
Property
& prop,
const
double
& value) {
return
false
;}
54
56
61
virtual
bool
get_size
(
const
Property
& prop,
size_t
& size)
const
{
return
false
;}
62
64
69
virtual
bool
get_item
(
const
Property
& prop,
const
size_t
& num,
double
& value)
const
{
return
false
;}
70
72
76
virtual
bool
set_size
(
const
Property
& prop,
const
size_t
& size) {
return
false
;}
77
79
84
virtual
bool
set_item
(
const
Property
& prop,
const
size_t
& num,
const
double
& value) {
return
false
;}
87
89
95
virtual
bool
get_string
(
const
Property
& prop,
char
* str)
const
{
return
false
;}
96
98
102
virtual
bool
set_string
(
const
Property
& prop,
const
char
* str) {
return
false
;}
105
113
bool
copy
(
const
Property
& prop,
Value
& to,
const
Property
& to_prop)
const
;
114
};
// struct Value
115
116
118
121
struct
Object
{
123
125
virtual
void
prepare
(
const
Element
& elem) {}
126
128
133
virtual
Value
*
get_value
(
const
Element
& elem,
const
Property
& prop) = 0;
134
136
141
virtual
bool
make_element
(
Element
& elem)
const
{
return
false
;}
142
144
147
bool
describe_element
(
Header
& header)
const
;
148
150
154
bool
storage_test
(
const
Element
& elem);
155
};
// struct Object
156
157
159
struct
Array
{
161
163
virtual
size_t
size
() = 0;
164
166
168
virtual
void
prepare
(
const
size_t
&
size
) = 0;
169
171
173
void
prepare
(
const
Element
& elem) {
prepare
(elem.
props
.size()); }
174
176
virtual
void
clear
() = 0;
177
179
virtual
void
restart
() = 0;
180
182
184
virtual
Object
&
next_object
() = 0;
185
187
189
template
<
class
T >
190
T&
next
() {
return
dynamic_cast<
T&
>
(
next_object
()); }
191
};
// struct Array
192
193
195
struct
Storage
{
196
Array
**
collect
;
197
199
Storage
():
collect
(0), num(0), unknown(0) {}
201
203
Storage
(
const
Header
& header);
204
~Storage
() { deinit(); }
205
207
209
void
prepare
(
const
Header
& header);
210
212
217
Array
*
get_collection
(
const
Header
& header,
const
Element
& elem);
218
220
225
bool
set_collection
(
const
Header
& header,
const
Element
& elem,
Array
& coll);
226
227
private
:
228
Storage
(
const
Storage
&) {}
// Private copy constructor to protect the collections.
229
230
void
init(
size_t
size);
// Initialize the arrays.
231
void
deinit();
// Deinitialize the arrays.
232
233
size_t
num;
// The number of collections.
234
bool
* unknown;
// The unknown Object collections.
235
};
// struct Storage
236
}
// namespace PLY
237
238
239
#endif // __PLY_OBJECT_H__
Generated on Fri Jul 26 2013 14:39:58 for PLY reader/writer by
1.8.4