Values in 3D

To make any important software for medicine/ scientific calculus the display of information is important. Normally the display of information will be made by two key points; the first to be able to open the geometry, and the second to display information in the geometry.

As we show in the tutorials from before we opened geometry and we are able to color each node as we wished; this is how we will be able to display the information. In the case we have information in time; we will have a series of values for each time step. For example in the following figures you can appreciate the values at time 0, and time 50 of a heart simulation.

Description: C:\Users\root\Desktop\SharpGLDemos\ReadValues\SharpGLWinformsApplication4\bin\Debug\file.bmp

Description: C:\Users\root\Desktop\SharpGLDemos\ReadValues\SharpGLWinformsApplication4\bin\Debug\file.bmp

As you can see there are several colors that change from image 1 to image 2. These colors are related with the values at each node. The values can be correlated with the bar that appears on the right side of the screen. This bar is a standard as it appears in several applications of 3d graphics and display information. The code for the color bar is:

gl.LineWidth(openGLControl.Width / openGLControl.Height * 3.0f);

    gl.Color(255, 0, 0);

    gl.Begin(OpenGL.GL_LINES);

    for (int i = 0; i < 64; i++)

    {

        //color = Color.FromArgb(255, i * 4, 0);

        gl.Color(1.0f, i * 0.015625f, 0);

       

        //g.FillRectangle(new SolidBrush(color),

        //    10, 50 + i, 20, 1);

 

        gl.Vertex(x0, ybase + (float)i * deltay);

        gl.Vertex(xn, ybase + (float)i * deltay);

 

    }

    for (int i = 0; i < 32; i++)

    {

        //color = Color.FromArgb(255 - i * 8, 255, 0);

        gl.Color(1.0f - (i * 0.03125), 1.0f, 0);

   

        //g.FillRectangle(new SolidBrush(color),

        //    10, 114 + i, 20, 1);

        gl.Vertex(x0, ybase + (float)(i + 64) * deltay);

        gl.Vertex(xn, ybase + (float)(i + 64) * deltay);

 

    }

    for (int i = 0; i < 32; i++)

    {

        //color = Color.FromArgb(0, 255, i * 8);

        gl.Color(0.0f, 1.0f, (i * 0.03125));

 

        //g.FillRectangle(new SolidBrush(color),

        //    10, 146 + i, 20, 1);

        gl.Vertex(x0, ybase + (float)(i + 96) * deltay);

        gl.Vertex(xn, ybase + (float)(i + 96) * deltay);

    }

    for (int i = 0; i < 64; i++)

    {

        //color = Color.FromArgb(0, 255 - i * 4, 255);

        gl.Color(0.0f,1.0f- (i * 0.015625f), 1.0f,0.5f);

        //g.FillRectangle(new SolidBrush(color),

        //    10, 178 + i, 20, 1);

        gl.Vertex(x0, ybase + (float)(i + 128) * deltay);

        gl.Vertex(xn, ybase + (float)(i + 128) * deltay);

 

    }

    gl.End();

We draw lines similar as the grid that appears in the middle of the simulation that are not modified by moving the geometry. The values they used for the increment and decrement were calculated in an empirical form by trying several values in gl.Project and gl.Unproject Instructions as explained to understand the values of the mouse pointer in the world coordinates from the last tutorial.

In these tutorials , and projects we used the following standard for notation of the values. The values will be given or read from a “*.txt” or “*.matrix” file. This file is no other than a ASCII file with the following format:

4
3

1 2 3

4 5 6

7 8 9

10 11 12

The first two values are the rows and the columns in the document. The values are written in each line as shown and separated by just a space. This format is quite simple to understand and either if they are double (float) values or integer it will be the same, they just need to be treated correctly.

For displaying the values in time each column will be equal to a value in time for all the nodes. 10 columns, 10 values in time. The code and examples are given for the tutorial.

For the case of a vector (not a matrix) the values will be read from either a “*.vector” or “*.txt” file. Note: is very easy to add or remove file types, just look at the code. The format of the vectors will be:

3

0.001

0.002

0.003

The first value is the length the rest are the values in one column. The code to open the files goes like this:

double[,] Values = null;

OpenFile.openMatrix(ref Values);

There are easier way to implement this, but we wanted to make a format easily interchangeable with c/c++ applications. (look at our webpage). To code the plot of the geometry with the values:

 

            SharpGLForm plot = new SharpGLForm(Nodes, Triangles,Values);

 

            plot.Show();