<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi
<p>I would like to know if it is an error or no in method CopyAndCastFrom
of vtkImageData class
<br>Here is the code of the sub-routine vtkImageDataCastExecute called
by CopyAndCastFrom
<p> 1619 void vtkImageDataCastExecute(vtkImageData *inData, IT *inPtr,
<br> 1620
vtkImageData *outData, OT *outPtr,
<br> 1621
int outExt[6])
<br> 1622 {
<br> 1623 int idxR, idxY, idxZ;
<br> 1624 int maxY, maxZ;
<br> 1625 int inIncX, inIncY, inIncZ;
<br> 1626 int outIncX, outIncY, outIncZ;
<br> 1627 int rowLength;
<br> 1628
<br> 1629 // find the region to loop over
<br> 1630 rowLength = (outExt[1] - outExt[0]+1)*inData->GetNumberOfScalarComponents();
<br> 1631 maxY = outExt[3] - outExt[2];
<br> 1632 maxZ = outExt[5] - outExt[4];
<br> 1633
<br> 1634 // Get increments to march through data
<br> 1635 inData->GetContinuousIncrements(outExt, inIncX,
inIncY, inIncZ);
<br> 1636 outData->GetContinuousIncrements(outExt, outIncX,
outIncY, outIncZ);
<br> 1637
<br> 1638 // Loop through ouput pixels
<br> 1639 for (idxZ = 0; idxZ <= maxZ; idxZ++)
<br> 1640 {
<br> 1641 for (idxY = 0; idxY <= maxY;
idxY++)
<br> 1642 {
<br> 1643 for (idxR = 0; idxR
< rowLength; idxR++) <b><i><---------------------- possible error</i></b>
<br> 1644 {
<br> 1645 // Pixel
operation
<br> 1646 *outPtr
= (OT)(*inPtr);
<br> 1647 outPtr++;
<br> 1648 inPtr++;
<br> 1649 }...
<p>Ok, why does it iterate on rowlength and not just on maxR = (outExt[1]
- outExt[0])?
<br>rowLength is two big and it will make a pointer overflow ... I think.
Because it will iterate for (maxZ * maxY * rowLength) while
the vector size is (maxZ * maxY * maxR).
<br>For me it does not work with two images with the same dimensions but
with different scalar types.
<p>Thomas</html>