1 /* Quat - A 3D fractal generation program */
2 /* Copyright (C) 1997-2000 Dirk Meyer */
3 /* (email: dirk.meyer@studserv.uni-stuttgart.de) */
4 /* mail: Dirk Meyer */
5 /* Marbacher Weg 29 */
6 /* D-71334 Waiblingen */
7 /* Germany */
8 /* */
9 /* This program is free software; you can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation; either version 2 */
12 /* of the License, or (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, write to the Free Software */
21 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <iostream>
28
29 #ifndef NO_NAMESPACE
30 using namespace std;
31 #endif
32
33 #include "structs.h"
34 #include "quat.h"
35
reset()36 void frac_cpp::reset()
37 {
38 view_struct v; realpal_struct r;
39 char col[251]; double cut[140];
40
41 SetDefaults(this, &v, &r, col, cut);
42 // *this = f;
43 }
44
operator =(frac_struct & v)45 frac_cpp frac_cpp::operator = (frac_struct& v)
46 {
47 memcpy(this, &v, sizeof(frac_struct));
48 return *this;
49 }
50
print()51 void frac_cpp::print()
52 {
53 cout << "(" << c[0] << "," << c[1] << "," << c[2] << "," << c[3] << "), "
54 << bailout << ", " << maxiter << ", " << lvalue << ", " << formula << endl;
55 for (int j=0; j<4; ++j) {
56 cout << "Parameter " << j << ": ";
57 for (int i=0; i<4; ++i) cout << p[j][i] << " ";
58 cout << endl;
59 }
60 }
61
reset()62 void view_cpp::reset()
63 {
64 frac_struct f; realpal_struct r;
65 char col[251]; double cut[140];
66
67 SetDefaults(&f, this, &r, col, cut);
68 // *this = v;
69 }
70
operator =(view_struct & v)71 view_cpp view_cpp::operator = (view_struct& v)
72 {
73 memcpy(this, &v, sizeof(view_struct));
74 return *this;
75 }
76
print()77 void view_cpp::print()
78 {
79 cout << "(" << s[0] << "," << s[1] << "," << s[2] << "), "
80 << "(" << up[0] << "," << up[1] << "," << up[2] << "), "
81 << "(" << light[0] << "," << light[1] << "," << light[2] << "), "
82 << "(" << Mov[0] << "," << Mov[1] << "), "
83 << LXR << ", "
84 << "(" << xres << "," << yres << "," << zres << "), "
85 << interocular << ", " << phongmax << ", " << phongsharp << ", "
86 << ambient << ", " << antialiasing << endl;
87 }
88
reset()89 void realpal_cpp::reset()
90 {
91 frac_struct f; view_struct v;
92 char col[251]; double cut[140];
93
94 SetDefaults(&f, &v, this, col, cut);
95 // *this = v;
96 }
97
operator =(realpal_struct & v)98 realpal_cpp realpal_cpp::operator = (realpal_struct& v)
99 {
100 memcpy(this, &v, sizeof(realpal_struct));
101 return *this;
102 }
103
print()104 void realpal_cpp::print()
105 {
106 cout << colnum << endl;
107 for (int i= 0; i<colnum; i++)
108 cout << "(" << cols[i].col1[0] << "," << cols[i].col1[1] << "," << cols[i].col1[2] << "), "
109 << "(" << cols[i].col2[0] << "," << cols[i].col2[1] << "," << cols[i].col2[2] << ")"
110 <<endl;
111 }
112
reset()113 void colscheme_cpp::reset()
114 {
115 frac_struct f; view_struct v; realpal_struct r;
116 double cut[140];
117
118 SetDefaults(&f, &v, &r, _data, cut);
119 // *this = v;
120 }
121
reset()122 void cutbuf_cpp::reset()
123 {
124 frac_struct f; view_struct v; realpal_struct r;
125 char col[251];
126
127 SetDefaults(&f, &v, &r, col, _data);
128 // num = getnum();
129 }
130
print()131 void cutbuf_cpp::print()
132 {
133 int num = getnum();
134 // int idx = 0;
135 // while (*reinterpret_cast<char *>(_data+idx) != CUT_TERMINATOR && idx<20)
136 for (int idx=0; idx<num; idx++)
137 {
138 cout << "CUT_PLANE (" << _data[idx+1] << "," << _data[idx+2] << "," << _data[idx+3] << "), ("
139 << _data[idx+4] << "," << _data[idx+5] << "," << _data[idx+6] << ")" << endl;
140 idx++;
141 }
142 if (num == 0) cout << "empty." << endl;
143
144 }
145
getnum()146 int cutbuf_cpp::getnum()
147 {
148 int tnum = 0, idx = 0;
149 while (tnum < 20 && *reinterpret_cast<char*>(_data+idx) != CUT_TERMINATOR)
150 switch (*reinterpret_cast<char*>(_data+idx)) {
151 case CUT_PLANE: ++tnum; idx += 7; break;
152 default: idx++;
153 }
154 return tnum;
155 }
156
add()157 void cutbuf_cpp::add()
158 {
159 int num = getnum();
160 if (num>=20) return;
161 if (num<19) *reinterpret_cast<char*>(&_data[7*(num+1)]) = CUT_TERMINATOR;
162 *reinterpret_cast<char*>(&_data[7*num]) = CUT_PLANE;
163 num++;
164 }
165
del(int idx)166 void cutbuf_cpp::del(int idx)
167 {
168 int num = getnum();
169 if (num==0) return;
170 if (idx>19) return;
171 memmove(&_data[7*idx], &_data[7*idx+7], (140-7*(idx+1))*sizeof(double));
172 if (num==20) {
173 *reinterpret_cast<char*>(&_data[133]) = CUT_TERMINATOR;
174 _data[134] = 0.0; _data[135] = 0.0; _data[136] = 0.0;
175 _data[137] = 0.0; _data[138] = 0.0; _data[139] = 0.0;
176 }
177 //for (int i=0; i<20; ++i)
178 // cout << (int)*reinterpret_cast<char*>(&_data[7*i]) << ": "
179 // << _data[7*i+1] << ", " << _data[7*i+2] << ", " << _data[7*i+3] << ", "
180 // << _data[7*i+4] << ", " << _data[7*i+5] << ", " << _data[7*i+6] << endl;
181 }
182