[vtkusers] resizing a volume
Cory Quammen
cquammen at cs.unc.edu
Wed Sep 12 17:17:25 EDT 2007
Try vtkImageConstantPad:
http://www.vtk.org/doc/nightly/html/classvtkImageConstantPad.html. It
should do exactly what you want.
-Cory
On 9/12/07, Olowoyeye, Adebayo Ol Uwole <aolowoye at indiana.edu> wrote:
> 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!!
>
> _______________________________________________
> 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
>
--
Cory Quammen
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen
More information about the vtkusers
mailing list