1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 */
16
17 #pragma once
18
19 /** \file
20 * \ingroup freestyle
21 * \brief Functions to manage I/O for the view map
22 */
23
24 #include <fstream>
25 #include <string>
26
27 #include "ViewMap.h"
28
29 #include "../system/FreestyleConfig.h"
30 #include "../system/ProgressBar.h"
31
32 namespace Freestyle {
33
34 namespace ViewMapIO {
35
36 static const unsigned ZERO = UINT_MAX;
37
38 int load(istream &in, ViewMap *vm, ProgressBar *pb = NULL);
39
40 int save(ostream &out, ViewMap *vm, ProgressBar *pb = NULL);
41
42 namespace Options {
43
44 static const unsigned char FLOAT_VECTORS = 1;
45 static const unsigned char NO_OCCLUDERS = 2;
46
47 void setFlags(const unsigned char flags);
48
49 void addFlags(const unsigned char flags);
50
51 void rmFlags(const unsigned char flags);
52
53 unsigned char getFlags();
54
55 void setModelsPath(const string &path);
56
57 string getModelsPath();
58
59 }; // namespace Options
60
61 #ifdef IRIX
62
63 namespace Internal {
64
write(ostream & out,const char * str)65 template<unsigned S> ostream &write(ostream &out, const char *str)
66 {
67 out.put(str[S - 1]);
68 return write<S - 1>(out, str);
69 }
70
71 template<> ostream &write<1>(ostream &out, const char *str)
72 {
73 return out.put(str[0]);
74 }
75
76 template<> ostream &write<0>(ostream &out, const char *)
77 {
78 return out;
79 }
80
read(istream & in,char * str)81 template<unsigned S> istream &read(istream &in, char *str)
82 {
83 in.get(str[S - 1]);
84 return read<S - 1>(in, str);
85 }
86
87 template<> istream &read<1>(istream &in, char *str)
88 {
89 return in.get(str[0]);
90 }
91
92 template<> istream &read<0>(istream &in, char *)
93 {
94 return in;
95 }
96
97 } // End of namespace Internal
98
99 #endif // IRIX
100
101 } // End of namespace ViewMapIO
102
103 } /* namespace Freestyle */
104