The calculateProperties Function of a Line Visualization
This web page describes how to visualize a line with the help of the
3DVDM system. In this example we draw a line between points (0, 1/2,
1/2) and (1, 1/2, 1/2). We allow the user to change one parameters of
the visualization: to turn on/off the visualization.
Three blocks of code are used to visualize the tetrahedra: (i) the
allocation of the memory (cf. lines 12-18 of the code below), (ii) the
computation of the visualization parameters (cf. lines 19-26), and the
transfer of the data to the VR++ module of the system (cf. line 33).
The rest of the code is required to implement turning on/off of the
visualization. For example, lines 10-26 implements the scenario, when the
showObjects check box of the GUI is selected, and lines 27-32 implements
the scenario, when the showObjects check box is not selected.
1 TaskState ExampleMapper::calculateProperties()
2 {
3 float start[3]; // beginning of the line
4 float end[3]; // end of the line
5 float color_start[4]; // red,green,blue,alpha of the start point
6 float color_end[4]; // red,green,blue,alpha of the end point
7 unsigned long object_line; // the counter of lines
8
9 numberOfLines = 1;
10
11 if ( showObjects == true ){
|
12 if (lineProperties == NULL){
13 lineProperties = new float[LINE_PROPERTIES*numberOfLines];
14 } else {
15 delete [] lineProperties;
16 lineProperties = new float[LINE_PROPERTIES*numberOfLines];
17 }
18
|
19 start[0] = 0.0; start[1] = 0.5; start[2] = 0.5;
20 end[0] = 1.0; end[1] = 0.5; end[2] = 0.5;
21 color_start[0] = color_start[1] = color_start[2] = color_start[3] = 1.0;
22 color_end[0] = color_end[1] = color_end[2] = color_end[3] = 1.0;
23
24 object_line = 0;
25 setLine(object_line, start, end, color_start, color_end);
26
|
27 } else {
28 numberOfLines = 0;
29 delete [] lineProperties;
30 lineProperties = NULL;
31 }
32
|