Visualization of Strings in the 3DVDM System
This web pages describes how to retrieve the string values from the
selected database and visualize the strings with the 3DVDM system.
Four blocks of code are used to read the input as strings and visualize
the strings. The first block (lines 0--19) declares the variables
used in the function. We limit the number of visualized strings to 100
(cf. lines 14--19). The second block (lines 20--28) allocates the memory
for the string primitives. The fourth block (lines 47--48) sends the
visualization primitives to the VR++ subsystem of the 3DVDM system.
The retrieval of the records of the selected database as strings and
preparation of the strings for visualization is done in the third block
(lines 29--46). We use the getString(object_id,
column_id) method of the dataSet
object to retrieve the records of the selected database as strings
(cf. line 34). Then we scan the first 100 records of the dataset and
visualize the X attribute of the database as a string at a random (x,y,z)
position in space.
0 #include <stdlib.h>
1 TaskState NewModuleMapper::calculateProperties()
2 {
3 if ( showObjects == true ){
4 //Text object
5 float x, y, z; //position of a string
6 float size; //size of a string
7 string str; //a string to be drawn
8 unsigned long object_string; // the counter of strings
9
10 /* At least X attribute must be selected in the GUI */
11 if (mappings[X] <= 0)
12 return RECEIVE;
13
14 /* Allocating memory for the visualization primitives */
15 numberOfStrings = dataSet->getRows();
16
17 if (numberOfStrings > 100)
18 numberOfStrings = 100;
19
|
20 if (textProperties == NULL){
21 textProperties = new float[TEXT_PROPERTIES*numberOfStrings];
22 text = "";
23 } else {
24 delete [] textProperties;
25 textProperties = new float[TEXT_PROPERTIES*numberOfStrings];
26 text = "";
27 }
28
|
29 /* Calculating visualization primitives */
30 size = 200.0;
31 for (object_string = 0; object_string < (unsigned long)numberOfStrings;
32 object_string++) {
33 // Placing the tetrahedra into the properties variable
34 str = dataSet->getString(object_string, mappings[X]-1);
35 x = (float)rand() / RAND_MAX;
36 y = (float)rand() / RAND_MAX;
37 z = (float)rand() / RAND_MAX;
38
39 addText(object_string++, str, x, y, z, size);
40 }
41 } else {
42 numberOfStrings = 0;
43 delete [] textProperties;
44 textProperties = NULL;
45 text = "";
46 }
|