[vtkusers] Scalar Array Pointer
    Michnay Balázs 
    michnay at freemail.hu
       
    Wed Jan 19 08:05:46 EST 2005
    
    
  
Dear VTK Users,
Presumably my problem is related more to pointer operations than to 
VTK.
I'd like to perform some pixel operations on a vtkImageData. I use the 
following code:
vtkImageData *labeledImage = vtkImageData::New();
labeledImage->CopyStructure(pDoc->MainImageContainer
[m_lastsel].threshImage);
//getting scalar values
vtkDataArray *scalarArrayOriginal = pDoc->threshImage->GetPointData
()->GetScalars();
//Get the number of pixels: 
int NumberOfPixels = scalarArrayOriginal->GetNumberOfTuples();
//x-y dimensions:
int ImageDimensions[3];
pDoc->threshImage->GetDimensions(ImageDimensions);
//I'd like to make another instance the array containing the scalar 
values, but making a pointer that points to the original one is not good, 
because its modifications would affect the original scalar array.
//The following line gets the scalar dara of the newly instantiated 
image.
vtkDataArray *scalarArrayLabeled = labeledImage->GetPointData()-
>GetScalars();
//This line generated a run-time error.
scalarArrayLabeled->SetNumberOfTuples(NumberOfPixels);
How can I make a whole new copy of my original scalar array that can 
be later associated to the new image ?
Thanks for your help in advance,
All the best,
 MB
    
    
More information about the vtkusers
mailing list