[vtkusers] resizing a volume

Olowoyeye, Adebayo Ol Uwole aolowoye at indiana.edu
Wed Sep 12 16:30:42 EDT 2007


Hi all,
  I want to resize a structuredPoints object.  The dimensions are 
initially 128x128x57.  I want to resize this volume to 128x128x128.  
The tricky part is this:
  I want to zero out every point that is not part of the original 
volume.  In other words, I want the small volume inside the bigger one. 
  Is there a way to do this without having to set the points manually 
as I did below:

vtkUnsignedCharArray* vectors = vtkUnsignedCharArray::New();
//vectors->SetNumberOfComponents(3);
//vectors->SetNumberOfTuples(dimX*dimY*dimZ);
		//volData->SetNumberOfComponents(permute->GetOutput()->GetNumberOfScalarComponents());
//volData->SetNumberOfValues(dimX*dimY*dimZ);
int kOffset, jOffset, offset;
for(int k=0; k<dimZ; k++){
        kOffset = k * dimY * dimX;
	for(int j=0; j<dimY; j++){
		jOffset = j * dimX;
		for(int i=0; i<dimX; i++){
			offset = i + jOffset + kOffset;
			if((i>=origDimX) || (j>=origDimY) || (k>=origDimZ)){
						//points->InsertPoint(offset,i,j,k);
				vectors->InsertTuple1(offset, 0.0);
			}
			else{
				//points->InsertPoint(offset,i,j,k);
				vectors->InsertTuple1(offset, 
permute->GetOutput()->GetScalarComponentAsDouble(i,j,k,0));

			}
	       }
	}
}

newVolume->SetDimensions(dimX, dimY, dimZ);
newVolume->SetExtent(0,dimX-1,0,dimY-1,0,dimZ-1);
newVolume->SetScalarType(permute->GetOutput()->GetScalarType());
newVolume->GetPointData()->SetScalars(vectors);
		newVolume->SetNumberOfScalarComponents(permute->GetOutput()->GetNumberOfScalarComponents());
newVolume->GetPointData()->Update();
newVolume->Update();


Thanks in advance!!




More information about the vtkusers mailing list