[vtkusers] Bug in vtkDataArrayTemplate.txx?

Berk Geveci berk.geveci at kitware.com
Mon Sep 24 09:45:33 EDT 2007


> Some of the calls (like Initialize()?) might benefit from a
> this->Modified() after the call to this->DataChanged(). Another
> possibility is adding a member to vtkDataArrayTemplate named, for
> example, Altered and using it to bypass checks on MTime() when computing
> the range of some component. Setting Altered=1 in DataChanged() would
> not be expensive and could even take the place of the code that deletes
> the lookup table (by pushing lookup table deletion to places where it is
> requested, although that might be an intrusive change).

I vote for option 1 (adding Modified() to places that won't be called
from tight loops).

-berk


>
> Or I could just drop it. :-) I only mentioned it because I noticed it
> while I was debugging a test (the information object for abstract array
> stuff). A feature is a feature is a feature...
>
>         David
>
> >
> > On 9/20/07, David C Thompson <dcthomp at sandia.gov> wrote:
> > > Hi all,
> > >
> > >         I believe vtkDataArrayTemplate<T>::DataChanged() should invoke
> > > this->Modified(). Otherwise, RemoveTuple, SetArray, Initialize, and
> > > several other methods will not result in the MTime of the array being
> > > updated. Since this MTime is used when comparing the array modification
> > > time to the cached component ranges, it can lead to the array bounds
> > > being incorrect. I have verified this behavior with a modified
> > > Common/Testing/Cxx/TestDataArray.cxx (attached).
> > >
> > >         If no one objects, I will add the call to Modified() and check in the
> > > modified version of Common/Testing/Cxx/TestDataArray.cxx to prevent
> > > regressions.
> > >
> > >         David
> > >
> > > #include "vtkIntArray.h"
> > > #include "vtkDoubleArray.h"
> > >
> > > int TestDataArray(int,char *[])
> > > {
> > >   double range[2];
> > >   vtkIntArray* array = vtkIntArray::New();
> > >   array->GetRange( range, 0 );
> > >   if ( range[0] != VTK_DOUBLE_MAX || range[1] != VTK_DOUBLE_MIN )
> > >     {
> > >     cerr << "Getting range of empty array failed, min: " << range[0] << " max: " << range[1] << "\n";
> > >     array->Delete();
> > >     return 1;
> > >     }
> > >   int cc;
> > >   for ( cc = 0; cc < 10; cc ++ )
> > >     {
> > >     array->InsertNextTuple1(cc);
> > >     }
> > >   array->RemoveFirstTuple();
> > >   array->RemoveTuple(3);
> > >   array->RemoveTuple(4);
> > >   array->GetRange( range, 0 );
> > >   if ( range[0] != 1. || range[1] != 9. )
> > >     {
> > >     cerr << "Getting range of array {1,2,3,5,7,8,9} failed, min: " << range[0] << " max: " << range[1] << "\n";
> > >     array->Delete();
> > >     return 1;
> > >     }
> > >   array->RemoveLastTuple();
> > >   array->GetRange( range, 0 );
> > >   if ( range[0] != 1. || range[1] != 8. )
> > >     {
> > >     cerr << "Getting range of array {1,2,3,5,7,8} failed, min: " << range[0] << " max: " << range[1] << "\n";
> > >     array->Delete();
> > >     return 1;
> > >     }
> > >   int ca[] = { 1, 2, 3, 5, 7, 8 };
> > >   cout << "Array:";
> > >   for ( cc = 0; cc < array->GetNumberOfTuples(); ++cc )
> > >     {
> > >     if ( array->GetTuple1(cc) != ca[cc] )
> > >       {
> > >       cerr << "Problem with array: " << array->GetTuple1(cc) << " <> " << ca[cc] << endl;
> > >       return 1;
> > >       }
> > >     cout << " " << array->GetTuple1(cc);
> > >     }
> > >   cout << endl;
> > >   array->Delete();
> > >
> > >   vtkDoubleArray* farray = vtkDoubleArray::New();
> > >   farray->SetNumberOfComponents(3);
> > >   for ( cc = 0; cc < 10; cc ++ )
> > >     {
> > >     farray->InsertNextTuple3( cc + 0.1, cc + 0.2, cc + 0.3);
> > >     }
> > >   farray->RemoveFirstTuple();
> > >   farray->RemoveTuple(3);
> > >   farray->RemoveTuple(4);
> > >   farray->RemoveLastTuple();
> > >   cout << "Array:";
> > >   for ( cc = 0; cc < farray->GetNumberOfTuples(); ++cc )
> > >     {
> > >     double* fa = farray->GetTuple3(cc);
> > >     double fc[3];
> > >     fc[0] = ca[cc] + .1;
> > >     fc[1] = ca[cc] + .2;
> > >     fc[2] = ca[cc] + .3;
> > >     for (int i = 0; i < 3; i++)
> > >       {
> > >       if (fa[i] != fc[i])
> > >         {
> > >         cerr << "Problem with array: " << fa[i] << " <> " << fc[i] << endl;
> > >         return 1;
> > >         }
> > >       }
> > >     cout << " " << fa[0] << "," << fa[1] << "," << fa[2];
> > >     }
> > >   cout << endl;
> > >   farray->Delete();
> > >   return 0;
> > > }
> > >
> > > _______________________________________________
> > > 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