[vtkusers] Re: Tensor Ellipsoids

Phil Cook p.cook at cs.ucl.ac.uk
Sun Nov 10 08:20:51 EST 2002


On 10 Nov 2002 at 13:18, vtkusers-request at public.kitwa wrote:

On 10 Nov 2002 at 6:32, vtkusers-request at public.kitware.com wrote:

> 
> ------=_NextPart_000_00E1_01C28850.6E4CBFC0
> Content-Type: text/plain;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> Dear VTK Users,
> 
> 
> I am trying to visualize stress tensor data from an experiment using =
> VTK.I would greatly appreciate if anyone can give me any suggestion =
> about how to do the follwoing with VTK.
> 
> 1. Read an ASCII file of tensor data (which will look like this.)
> 
> x    y    z    s11    s12    s13    s21    s22    s33
> 0    0    0    0        0        0        0        0        0
> 0    0    1    0        0        0        1        0        0
> 0    0    2    0        0        0        0        1        1
> 0    0    3    0        0        0        1        1        1
> 0    1    0    0        0        1        1        0        0
> 0    1    1    0        0        2        1        0        1
> 0    1    2    0        0        3        2        4        0
> etc..
> 
> 2. Draw ellipsoids on the x-y-z coordinate by using the tensor =
> components sij.
> 
> I would greatly appreciate if you can provide any help.
> 
> M Yaman
> PhD student, UCT
> Cape Town
> 
> 

There are many ways to read data from the file. My preference is for Python, but it can 
be done in any of the VTK languages without too much difficulty.

Once you have the nine elements of the tensor you can read them into a vtkFloatArray 
(eg, in Java):

        vtkFloatArray tensors = new vtkFloatArray();
        tensors.SetNumberOfComponents(9);
        tensors.SetNumberOfTuples( xLength * yLength * zLength);

In this instance I'm displaying a tensor at each point on a set of structured points, of 
dimension xLength * yLength * zLength.

	for (each tensor) {
		 float[] tensor = new float[9];

                          tensor[0] = xx;
                          tensor[1] = xy;
                          tensor[2] = xz;
                          tensor[3] = xy;
                          tensor[4] = yy;
                          tensor[5] = yz;
                          tensor[6] = xz;
                          tensor[7] = yz;
                          tensor[8] = zz;

                         tensors.SetTuple9( idCounter++, tensor[0], tensor[1], tensor[2], 	
				      tensor[3], tensor[4], tensor[5], tensor[6], tensor[7],
			                   tensor[8] );
	}

Where the tensor is defined as

	xx	xy	xz
	xy	yy	yz
	xz	yz	zz

I then add the tensors to the structured points,

	spts.GetPointData().SetTensors(tensors);

Where the idCounter of each tensor correspsonds to the idCounter of the point (in spts) 
where the tensor is to appear.

The next step is to use vtkTensorGlyph to create a polygonal representation of the 
object.

        vtkSphereSource sphere = new vtkSphereSource();

        sphere.SetThetaResolution(11);
        sphere.SetPhiResolution(11);
        sphere.Update();

        vtkTensorGlyph ellip = new vtkTensorGlyph();
        ellip.SetInput(spts);
        ellip.SetSource(sphere.GetOutput());


See the documentation on vtkTensorGlyph for the options on colouring and scaling your 
tensors.






More information about the vtkusers mailing list