Orbiter 2022
Combinatorial Objects
drawable_set_of_objects.cpp
Go to the documentation of this file.
1/*
2 * drawable_set_of_objects.cpp
3 *
4 * Created on: Apr 10, 2020
5 * Author: betten
6 */
7
8
9
10
11
12
13#include "foundations.h"
14
15using namespace std;
16
17
18
19#define EPSILON 0.01
20
21namespace orbiter {
22namespace layer1_foundations {
23namespace graphics {
24
25
26
28{
29 group_idx = 0;
30
31 type = 0;
32 // 1 = sphere
33 // 2 = cylinder
34 // 3 = prisms (faces)
35 // 4 = planes
36 // 5 = lines
37 // 6 = cubics
38 // 7 = quadrics
39 // 8 = quartics
40 // 9 = octics
41 // 10 = label
42
43 d = 0.;
44 d2 = 0.;
45
46 //properties = NULL;
47}
48
50{
51 //freeself();
52}
53
55 double rad, std::string &properties, int verbose_level)
56{
57 int f_v = (verbose_level >= 1);
58
59 if (f_v) {
60 cout << "drawable_set_of_objects::init_spheres" << endl;
61 }
63 type = 1;
64 d = rad;
66
67
68 if (f_v) {
69 cout << "drawable_set_of_objects::init_spheres done" << endl;
70 }
71}
72
74 double rad, std::string &properties, int verbose_level)
75{
76 int f_v = (verbose_level >= 1);
77
78 if (f_v) {
79 cout << "drawable_set_of_objects::init_cylinders" << endl;
80 }
82 type = 2;
83 d = rad;
85
86
87 if (f_v) {
88 cout << "drawable_set_of_objects::init_cylinders done" << endl;
89 }
90}
91
93 double thickness, std::string &properties, int verbose_level)
94{
95 int f_v = (verbose_level >= 1);
96
97 if (f_v) {
98 cout << "drawable_set_of_objects::init_prisms" << endl;
99 }
101 type = 3;
102 d = thickness;
104
105
106 if (f_v) {
107 cout << "drawable_set_of_objects::init_prisms done" << endl;
108 }
109}
110
112 std::string &properties, int verbose_level)
113{
114 int f_v = (verbose_level >= 1);
115
116 if (f_v) {
117 cout << "drawable_set_of_objects::init_planes" << endl;
118 }
120 type = 4;
121 //d = thickness;
123
124
125 if (f_v) {
126 cout << "drawable_set_of_objects::init_planes done" << endl;
127 }
128}
129
131 double rad, std::string &properties, int verbose_level)
132{
133 int f_v = (verbose_level >= 1);
134
135 if (f_v) {
136 cout << "drawable_set_of_objects::init_lines" << endl;
137 }
139 type = 5;
140 d = rad;
142
143
144 if (f_v) {
145 cout << "drawable_set_of_objects::init_lines done" << endl;
146 }
147}
148
150 std::string &properties, int verbose_level)
151{
152 int f_v = (verbose_level >= 1);
153
154 if (f_v) {
155 cout << "drawable_set_of_objects::init_cubics" << endl;
156 }
158 type = 6;
159 //d = rad;
161
162
163 if (f_v) {
164 cout << "drawable_set_of_objects::init_cubics done" << endl;
165 }
166}
167
169 std::string &properties, int verbose_level)
170{
171 int f_v = (verbose_level >= 1);
172
173 if (f_v) {
174 cout << "drawable_set_of_objects::init_quadrics" << endl;
175 }
177 type = 7;
178 //d = rad;
180
181
182 if (f_v) {
183 cout << "drawable_set_of_objects::init_quadrics done" << endl;
184 }
185}
186
188 std::string &properties, int verbose_level)
189{
190 int f_v = (verbose_level >= 1);
191
192 if (f_v) {
193 cout << "drawable_set_of_objects::init_quartics" << endl;
194 }
196 type = 8;
197 //d = rad;
199
200
201 if (f_v) {
202 cout << "drawable_set_of_objects::init_quartics done" << endl;
203 }
204}
205
207 std::string &properties, int verbose_level)
208{
209 int f_v = (verbose_level >= 1);
210
211 if (f_v) {
212 cout << "drawable_set_of_objects::init_quintics" << endl;
213 }
215 type = 9;
216 //d = rad;
218
219
220 if (f_v) {
221 cout << "drawable_set_of_objects::init_quintics done" << endl;
222 }
223}
224
226 std::string &properties, int verbose_level)
227{
228 int f_v = (verbose_level >= 1);
229
230 if (f_v) {
231 cout << "drawable_set_of_objects::init_octics" << endl;
232 }
234 type = 10;
235 //d = rad;
237
238
239 if (f_v) {
240 cout << "drawable_set_of_objects::init_octics done" << endl;
241 }
242}
243
245 double thickness_half, double scale, std::string &properties, int verbose_level)
246{
247 int f_v = (verbose_level >= 1);
248
249 if (f_v) {
250 cout << "drawable_set_of_objects::init_labels" << endl;
251 }
253 type = 11;
254 d = thickness_half;
255 d2 = scale;
257
258
259 if (f_v) {
260 cout << "drawable_set_of_objects::init_labels done" << endl;
261 }
262}
263
264
265void drawable_set_of_objects::draw(animate *Anim, ostream &ost,
266 int f_group_is_animated, int frame, int verbose_level)
267{
268 int f_v = (verbose_level >= 1);
269 int sz;
270 int *Selection;
271 int j;
272
273 if (f_v) {
274 cout << "drawable_set_of_objects::draw" << endl;
275 }
276 if (f_v) {
277 cout << "group_idx = " << group_idx << endl;
278 cout << "f_group_is_animated = " << f_group_is_animated << endl;
279 }
280
281 sz = Anim->S->group_of_things[group_idx].size();
282
283 if (f_group_is_animated) {
284 if (frame < sz) {
285 sz = 1;
286 Selection = NEW_int(1);
287 Selection[0] = Anim->S->group_of_things[group_idx][frame];
288 }
289 else {
290 return;
291 }
292 }
293 else {
294 Selection = NEW_int(sz);
295 for (j = 0; j < sz; j++) {
296 Selection[j] = Anim->S->group_of_things[group_idx][j];
297 }
298 }
299 if (f_v) {
300 cout << "sz = " << sz << endl;
301 }
302
303 if (f_v) {
304 cout << "Selection: " << endl;
305 Int_vec_print(cout, Selection, sz);
306 cout << endl;
307 }
308 if (type == 1) {
309 if (f_v) {
310 cout << "type == 1" << endl;
311 }
312 Anim->S->draw_points_with_selection(Selection, sz,
313 d, properties, ost);
314 }
315 else if (type == 2) {
316 if (f_v) {
317 cout << "type == 2 cylinders = edges" << endl;
318 }
319 Anim->S->line_radius = d;
320 Anim->S->draw_edges_with_selection(Selection, sz,
321 properties, ost);
322 }
323 else if (type == 3) {
324 if (f_v) {
325 cout << "type == 3 prisms = faces" << endl;
326 }
327 Anim->S->draw_faces_with_selection(Selection, sz,
328 d, properties, ost);
329 }
330 else if (type == 4) {
331 if (f_v) {
332 cout << "type == 4 planes" << endl;
333 }
334 Anim->S->draw_planes_with_selection(Selection, sz,
335 properties, ost);
336 }
337 else if (type == 5) {
338 if (f_v) {
339 cout << "type == 5 lines" << endl;
340 }
341 Anim->S->line_radius = d;
342 Anim->S->draw_lines_with_selection(Selection, sz,
343 properties, ost);
344 }
345 else if (type == 6) {
346 if (f_v) {
347 cout << "type == 6 cubics" << endl;
348 }
349 Anim->S->draw_cubic_with_selection(Selection, sz,
350 properties, ost);
351 }
352 else if (type == 7) {
353 if (f_v) {
354 cout << "type == 7 quadrics" << endl;
355 }
356 Anim->S->draw_quadric_with_selection(Selection, sz,
357 properties, ost);
358 }
359 else if (type == 8) {
360 if (f_v) {
361 cout << "type == 8 quartics" << endl;
362 }
363 Anim->S->draw_quartic_with_selection(Selection, sz,
364 properties, ost);
365 }
366 else if (type == 9) {
367 if (f_v) {
368 cout << "type == 9 quintics" << endl;
369 }
370 Anim->S->draw_quintic_with_selection(Selection, sz,
371 properties, ost);
372 }
373 else if (type == 10) {
374 if (f_v) {
375 cout << "type == 10 octics" << endl;
376 }
377 Anim->S->draw_octic_with_selection(Selection, sz,
378 properties, ost);
379 }
380 else if (type == 11) {
381 if (f_v) {
382 cout << "type == 11 labels" << endl;
383 }
384 string dummy;
385
386 dummy.assign("");
387 Anim->draw_text_with_selection(Selection, sz,
388 d /* thickness_half */, 0. /* extra_spacing */,
389 d2 /* scale */,
390 0. /* off_x */, 0. /* off_y */, 0. /* off_z */,
391 properties, dummy /* group_options */,
392 ost, verbose_level);
393 }
394 else {
395 cout << "drawable type unrecognized" << endl;
396 exit(1);
397 }
398 FREE_int(Selection);
399 if (f_v) {
400 cout << "drawable_set_of_objects::draw done" << endl;
401 }
402}
403
404}}}
405
creates 3D animations using Povray
Definition: graphics.h:29
void draw_text_with_selection(int *selection, int nb_select, double thickness_half, double extra_spacing, double scale, double off_x, double off_y, double off_z, std::string &options, std::string &group_options, std::ostream &ost, int verbose_level)
Definition: animate.cpp:3191
void init_cylinders(int group_idx, double rad, std::string &properties, int verbose_level)
void init_quintics(int group_idx, std::string &properties, int verbose_level)
void init_planes(int group_idx, std::string &properties, int verbose_level)
void init_cubics(int group_idx, std::string &properties, int verbose_level)
void init_octics(int group_idx, std::string &properties, int verbose_level)
void init_quartics(int group_idx, std::string &properties, int verbose_level)
void init_labels(int group_idx, double thickness_half, double scale, std::string &properties, int verbose_level)
void init_lines(int group_idx, double rad, std::string &properties, int verbose_level)
void init_quadrics(int group_idx, std::string &properties, int verbose_level)
void init_spheres(int group_idx, double rad, std::string &properties, int verbose_level)
void draw(animate *Anim, std::ostream &ost, int f_group_is_animated, int frame, int verbose_level)
void init_prisms(int group_idx, double thickness, std::string &properties, int verbose_level)
void draw_planes_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:1851
void draw_points_with_selection(int *selection, int nb_select, double rad, std::string &options, std::ostream &ost)
Definition: scene.cpp:1910
void draw_quadric_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:2092
std::vector< std::vector< int > > group_of_things
Definition: graphics.h:1217
void draw_octic_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:2055
void draw_quintic_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:2018
void draw_edges_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:1694
void draw_quartic_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:1981
void draw_faces_with_selection(int *selection, int nb_select, double thickness_half, std::string &options, std::ostream &ost)
Definition: scene.cpp:1732
void draw_cubic_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:1944
void draw_lines_with_selection(int *selection, int nb_select, std::string &options, std::ostream &ost)
Definition: scene.cpp:1457
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_int(n)
Definition: foundations.h:625
#define Int_vec_print(A, B, C)
Definition: foundations.h:685
the orbiter library for the classification of combinatorial objects