author | Radek Brich <radek.brich@devl.cz> |
Tue, 29 Apr 2008 23:31:08 +0200 | |
branch | pyrit |
changeset 90 | f6a72eb99631 |
parent 80 | 907929fa9b59 |
child 91 | 9d66d323c354 |
permissions | -rw-r--r-- |
78
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
/* |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
* serialize.h: object serialization functions |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
* |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
* This file is part of Pyrit Ray Tracer. |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
* |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
* Copyright 2008 Radek Brich |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
* |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
* of this software and associated documentation files (the "Software"), to deal |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
* in the Software without restriction, including without limitation the rights |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
* copies of the Software, and to permit persons to whom the Software is |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
13 |
* furnished to do so, subject to the following conditions: |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
* |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
* The above copyright notice and this permission notice shall be included in |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
* all copies or substantial portions of the Software. |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
* |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
* THE SOFTWARE. |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
*/ |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
#ifndef SERIALIZE_H |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
#define SERIALIZE_H |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
#include <map> |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
#include "shapes.h" |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
#include "container.h" |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
#include "kdtree.h" |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
class Indexer |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
{ |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
38 |
map <void *, int> indexmap; |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
39 |
int index; |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
public: |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
41 |
Indexer(): indexmap(), index(0) {}; |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
42 |
void reset() { indexmap.clear(); index = 0; }; |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
43 |
bool get(void *o, int &retidx); |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
44 |
const int &operator[](void *o) { return indexmap[o]; }; |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
45 |
}; |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
46 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
47 |
extern Indexer vertex_index, shape_index; |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
48 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
49 |
void resetSerializer(); |
80
907929fa9b59
remove forgotten noise.h includes
Radek Brich <radek.brich@devl.cz>
parents:
78
diff
changeset
|
50 |
Shape *loadShape(istream &st, Material *mat); |
78
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
51 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
52 |
ostream & operator<<(ostream &st, Shape &o); |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
53 |
ostream & operator<<(ostream &st, Vertex &o); |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
54 |
ostream & operator<<(ostream &st, Container &o); |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
55 |
istream & operator>>(istream &st, Vector3 &v); |
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
56 |
|
9569e9f35374
move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
57 |
#endif |