[vtkusers] Bug in vtkDataArrayTemplate.txx?
Berk Geveci
berk.geveci at kitware.com
Thu Sep 20 23:19:19 EDT 2007
I object :-) Modified() is a very, very expansive call and calling it
from DataChanged() which gets called from SetTuple() etc. will cause
serious penalty problems. Modified() was left out of those methods on
purpose. Modified() is expansive because it uses a mutex (look at
vtkTimeStamp.cxx). This change would cause tight loops to execute an
order of magnitude slower. However, I would think that if the user
called DataChanged(), it should call Modified(). Maybe
vtkDataArrayTemplate should call something else internally.
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