[vtkusers] Revision on previous question about unsigned char scalars--There was anerror in my previous question

kitware-vtk at kulnet.kuleuven.ac.be kitware-vtk at kulnet.kuleuven.ac.be
Mon Oct 16 04:21:28 EDT 2000


Dear Mario,

To generate scalars having `unsigned char' type simply use following
constructor

vtkScalars*   scalars =
vtkScalars::New(VTK_UNSIGNED_CHAR,nr_of_components);

The nr_of_components variable is self-explaining, it sets the number of
components of which
one scalar exists ..... this comes in handy when using scalars as colors
by using RGB as its three components.

Hope this helps,

Kurt


Mario Biondini wrote:

> I made an error when I typed the C++ code in my previous question. It
> should now read
>
>
> I am running a program designed for volume rendering. Within the
> program I have this code:
>
>   // Create a structure point dataset
>
>   vtkStructuredPoints *vol = vtkStructuredPoints::New();
>       vol->SetDimensions(76,49,45);
>       vol->SetOrigin(100.0,80.0,1.0);
>       sp = 1.0;
>       vol->SetSpacing(sp, sp, sp);
>
> // Creat a scalar and read the scalar data from file
>
>   vtkScalars *scalars = vtkScalars::New();
>    scalars->CreateDefaultLookupTable();
>   for (k=0; k<45; k++)
>     {
>      kOffset = k * 76 * 49;
>      for (j=0; j<49; j++)
>        {
>         jOffset = j * 76;
>         for (i=0; i<76; i++)
>          {
>           in1 >> s;
>           offset = i + jOffset + kOffset;
>           scalars->InsertScalar(offset,s);
>          }
>        }
>     }
>
> // Input the scalar data into the Structure Point Data Set
>
>   vol->GetPointData()->SetScalars(scalars);
>   scalars->Delete();
>
>   // Create the volume mapper and set the ray function and scalar
> input
>
>   vtkVolumeRayCastMapper *volumeMapper =
> vtkVolumeRayCastMapper::New();
>     volumeMapper->SetInput(vol);
>     volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>
> At execution time I get the following error
>
> ERROR: In vtkVolumeRayCastMapper.cxx, line 921
> vtkVolumeRayCastMapper (0x82b3ab0): The scalar data type: 10 is not
> supported when volume rendering. Please
> convert the  data to unsigned char or unsigned short.
>
> Reading Schroeder, Martin and Lorensen book the Visualization Toolkit
> (2nd Edition) I noticed than in version
> 2.0 of VTK there was a function called vtkUnsignedCharScalars to creat
> scalars of the type unsigned char. This
> function however is not availabe in verson 3.1.
>
> Question: is there an error in my code? and how do I create scalars
> that are if type unsigned char?
>
> --
> 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 at ndsu.nodak.edu
> http://www.ndsu.nodak.edu/instruct/biondini/vita/MEBvita.htm
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20001016/54780c42/attachment.htm>


More information about the vtkusers mailing list