Bug in vtkRectilinearGrid.cxx
Alexander Prokop
prokop at temf.tu-darmstadt.de
Tue Jul 6 04:33:32 EDT 1999
Hi all,
I found a Bug in vtkRectilinearGrid.cxx
The bug occured, when I used Streamlines.
I use VTK version 2.0, I corrected the bugs in the code below.
For the fixing see the comments NEW INSERTED (2 times)
Dipl.-Ing. Alexander Prokop
Development Engineer
CST Computer Simulation Technology GmbH
Email: prokop at temf.tu-darmstadt.de
Web: http://www.cst.de
---------------------------------------------------------------------
int vtkRectilinearGrid::FindPoint(float x[3])
{
int i, j, loc[3];
float xPrev, xNext;
vtkScalars *scalars[3];
scalars[0] = this->XCoordinates;
scalars[1] = this->YCoordinates;
scalars[2] = this->ZCoordinates;
//
// Find coordinates in x-y-z direction
//
for ( j=0; j < 3; j++ )
{
loc[j] = 0;
xPrev = scalars[j]->GetScalar(0);
xNext = scalars[j]->GetScalar(scalars[j]->GetNumberOfScalars()-1);
if ( x[j] < xPrev || x[j] > xNext ) return -1;
for (i=1; i < scalars[j]->GetNumberOfScalars(); i++)
{
xNext = scalars[j]->GetScalar(i);
xPrev = scalars[j]->GetScalar(i-1); // NEW INSERTED
if ( x[j] >= xPrev && x[j] <= xNext )
{
if ( (x[j]-xPrev) < (xNext-x[j]) ) loc[j] = i-1;
else loc[j] = i;
}
}
}
//
// From this location get the point id
//
return loc[2]*this->Dimensions[0]*this->Dimensions[1] +
loc[1]*this->Dimensions[0] + loc[0];
}
int vtkRectilinearGrid::ComputeStructuredCoordinates(float x[3], int ijk[3],
float pcoords[3])
{
int i, j, loc[3];
float xPrev, xNext;
vtkScalars *scalars[3];
scalars[0] = this->XCoordinates;
scalars[1] = this->YCoordinates;
scalars[2] = this->ZCoordinates;
//
// Find locations in x-y-z direction
//
ijk[0] = ijk[1] = ijk[2] = 0;
pcoords[0] = pcoords[1] = pcoords[2] = 0.0;
for ( j=0; j < 3; j++ )
{
loc[j] = 0;
xPrev = scalars[j]->GetScalar(0);
xNext = scalars[j]->GetScalar(scalars[j]->GetNumberOfScalars()-1);
if ( x[j] < xPrev || x[j] > xNext ) return 0;
for (i=1; i < scalars[j]->GetNumberOfScalars(); i++)
{
xNext = scalars[j]->GetScalar(i);
xPrev = scalars[j]->GetScalar(i-1); // NEW INSERTED
if ( x[j] >= xPrev && x[j] < xNext )
{
ijk[j] = i - 1;
pcoords[j] = (x[j]-xPrev) / (xNext-xPrev);
break;
}
else if ( x[j] == xNext )
{
ijk[j] = i - 1;
pcoords[j] = 1.0;
break;
}
}
}
return 1;
}
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list