1 /*!
2 \file cplane.c
3
4 \brief Cutting plane subroutine
5
6 (C) 2011 by the GRASS Development Team
7
8 This program is free software under the GNU General Public
9 License (>=v2). Read the file COPYING that comes with GRASS
10 for details.
11
12 \author Anna Kratochvilova <kratochanna gmail.com> (Google SoC 2010/2011)
13 */
14
15 #include <stdlib.h>
16 #include <string.h>
17
18 #include <grass/glocale.h>
19
20 #include "local_proto.h"
21
22 /*!
23 \brief Draw cutting planes and set their attributes
24
25 \param params module parameters
26 \param data nviz data
27 */
draw_cplane(const struct GParams * params,nv_data * data)28 void draw_cplane(const struct GParams *params, nv_data * data)
29 {
30 int i, id, ncplanes;
31 float trans_x, trans_y, trans_z;
32 float rot_x, rot_y, rot_z;
33 int fence;
34
35 ncplanes = opt_get_num_answers(params->cplane);
36 for (i = 0; i < ncplanes; i++) {
37 id = atoi(params->cplane->answers[i]);
38
39 if (id < 0 || id > Nviz_num_cplanes(data))
40 G_fatal_error(_("Cutting plane number <%d> not found"), id);
41
42 Nviz_on_cplane(data, id);
43
44 trans_x = atof(params->cplane_pos->answers[i * 3 + 0]);
45 trans_y = atof(params->cplane_pos->answers[i * 3 + 1]);
46 trans_z = atof(params->cplane_pos->answers[i * 3 + 2]);
47 Nviz_set_cplane_translation(data, id, trans_x, trans_y, trans_z);
48
49 rot_x = 0;
50 rot_y = atof(params->cplane_tilt->answers[i]);
51 rot_z = atof(params->cplane_rot->answers[i]);
52 Nviz_set_cplane_rotation(data, id, rot_x, rot_y, rot_z);
53 }
54
55 const char *shading = params->cplane_shading->answers[0];
56
57 if (strcmp(shading, "clear") == 0)
58 fence = 0;
59 else if (strcmp(shading, "top") == 0)
60 fence = 1;
61 else if (strcmp(shading, "bottom") == 0)
62 fence = 2;
63 else if (strcmp(shading, "blend") == 0)
64 fence = 3;
65 else if (strcmp(shading, "shaded") == 0)
66 fence = 4;
67 else
68 fence = 0;
69 Nviz_set_fence_color(data, fence);
70
71 return;
72 }
73