[vtkusers] vtkVolumeProperty SetColor (a bug in vtkVolume)

Lisa Avila lisa.avila at kitware.com
Mon Nov 8 17:19:11 EST 2004


Hi Weiguang,

Thanks for catching this - I have fixed it. This piece of code should not 
really be in the Volume and is likely to be overhauled early next year.

Lisa


At 03:02 PM 11/8/2004, Weiguang Guan wrote:
>Hi VTK users,
>
>Since nobody responds to my previous email I started looking into the
>problem myself. I found the bug was at
>         void vtkVolume::UpdateTransferFunctions( vtkRenderer
>*vtkNotUsed(ren) )
>
>......
>     // How many color channels for this component?
>     colorChannels = this->Property->GetColorChannels(c);
>
>     // If we have 1 color channel and no gray array, create it.
>     // Free the rgb array if there is one.
>     if ( colorChannels == 1 && !this->GrayArray[c] )
>       {
>       if ( this->RGBArray[c] )
>         {
>         delete [] this->RGBArray[c];
>         this->RGBArray[c]= NULL; // My fix
>         }
>       this->GrayArray[c] = new float[arraySize];
>       }
>
>     // If we have 3 color channels and no rgb array, create it.
>     // Free the gray array if there is one.
>     if ( colorChannels == 3 && !this->RGBArray[c] )
>       {
>       if ( this->GrayArray[c] )
>         {
>         delete [] this->GrayArray[c];
>         this->GrayArray[c] = NULL; // My fix
>         }
>       this->RGBArray[c] = new float[3*arraySize];
>       }
>.......
>
>Two statements added to fix the bug are labeled with " // My
>fix".
>
>In addition, I think it would make more sense if the code is written as
>follows:
>     // How many color channels for this component?
>     colorChannels = this->Property->GetColorChannels(c);
>
>     // If we have 1 color channel and no gray array, create it.
>     // Free the rgb array if there is one.
>     if ( colorChannels == 1 )
>       {
>       if ( this->RGBArray[c] )
>         {
>         delete [] this->RGBArray[c];
>         this->RGBArray[c]= NULL;
>         }
>       if ( !this->GrayArray[c] )
>         this->GrayArray[c] = new float[arraySize];
>       }
>
>     // If we have 3 color channels and no rgb array, create it.
>     // Free the gray array if there is one.
>     if ( colorChannels == 3 )
>       {
>       if ( this->GrayArray[c] )
>         {
>         delete [] this->GrayArray[c];
>         this->GrayArray[c] = NULL;
>         }
>       if ( !this->RGBArray[c] )
>         this->RGBArray[c] = new float[3*arraySize];
>       }
>
>I'd like to hear your comments, especially from Kitware.
>
>Weiguang
>
>--
>========================================================
>Weiguang Guan, Research Engineer
>RHPCS, McMaster University
>========================================================
>On Mon, 1 Nov 2004, Weiguang Guan wrote:
>
> > Hi everyone,
> >
> > I'm not sure whether this is a bug and it's been reported or not if it's a
> > bug.
> >
> > While I design a GUI to let user choose between gray and color transfer
> > functions in volume raycasting the program crashed with segmentation
> > fault. I checked the vtkVolumeProperty.* and found that the MTime of gray
> > or color won't get updated if one uses the same vtkPiecewiseFunction (or
> > vtkColorTransferFunction) pointer as arg of SetColor even though the
> > transfer function object itself has changed (using AddPoints for example).
> >
> > What puzzles me is that the program crashed as well if I create a new
> > vtkPiecewiseFunction (or vtkColorTransferFunction) each time I'm going to
> > change transfer function.
> >
> > Am I use it in the way it is supported to.
> >
> > Weiguang
> >
> >
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://www.vtk.org/Wiki/VTK_FAQ>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list