<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<br>Dear Mario,
<p>To generate scalars having `unsigned char' type simply use following
constructor
<p>vtkScalars* scalars = vtkScalars::New(VTK_UNSIGNED_CHAR,nr_of_components);
<p>The nr_of_components variable is self-explaining, it sets the number
of components of which
<br>one scalar exists ..... this comes in handy when using scalars as colors
by using RGB as its three components.
<p>Hope this helps,
<p>Kurt
<br>
<p>Mario Biondini wrote:
<blockquote TYPE=CITE>I made an error when I typed the C++ code in my previous
question. It should now read
<br>
<p>I am running a program designed for volume rendering. Within the program
I have this code:
<p> // Create a structure point dataset
<p> vtkStructuredPoints *vol = vtkStructuredPoints::New();
<br> vol->SetDimensions(76,49,45);
<br> vol->SetOrigin(100.0,80.0,1.0);
<br> sp = 1.0;
<br> vol->SetSpacing(sp, sp, sp);
<p>// Creat a scalar and read the scalar data from file
<p> vtkScalars *scalars = vtkScalars::New();
<br> scalars->CreateDefaultLookupTable();
<br> for (k=0; k<45; k++)
<br> {
<br> kOffset = k * 76 * 49;
<br> for (j=0; j<49; j++)
<br> {
<br> jOffset = j * 76;
<br> for (i=0; i<76; i++)
<br> {
<br> in1 >> s;
<br> offset = i +
jOffset + kOffset;
<br> scalars->InsertScalar(offset,s);
<br> }
<br> }
<br> }
<p>// Input the scalar data into the Structure Point Data Set
<p> vol->GetPointData()->SetScalars(scalars);
<br> scalars->Delete();
<p> // Create the volume mapper and set the ray function and scalar
input
<p> vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
<br> volumeMapper->SetInput(vol);
<br> volumeMapper->SetVolumeRayCastFunction(compositeFunction);
<p>At execution time I get the following error
<p>ERROR: In vtkVolumeRayCastMapper.cxx, line 921
<br>vtkVolumeRayCastMapper (0x82b3ab0): The scalar data type: 10 is not
supported when volume rendering. Please
<br>convert the data to unsigned char or unsigned short.
<p>Reading Schroeder, Martin and Lorensen book the Visualization Toolkit
(2nd Edition) I noticed than in version
<br>2.0 of VTK there was a function called vtkUnsignedCharScalars to creat
scalars of the type unsigned char. This
<br>function however is not availabe in verson 3.1.
<p>Question: is there an error in my code? and how do I create scalars
that are if type unsigned char?
<pre>--
Mario Biondini, Ph.D.
Department of Animal and Range Sciences
North Dakota State University
Fargo, ND 58103
Phone: (701) 231-8208
Fax: (701) 231-7590
e-mail: Mario_Biondini@ndsu.nodak.edu
<a href="http://www.ndsu.nodak.edu/instruct/biondini/vita/MEBvita.htm">http://www.ndsu.nodak.edu/instruct/biondini/vita/MEBvita.htm</a></pre>
</blockquote>
<pre></pre>
</html>