[vtkusers] Point Blanking

Andreas Kuhn kuhnan at control.ee.ethz.ch
Mon May 22 05:23:32 EDT 2006


Dear vtkusers,

I want to use point blanking on a vtkUniformGrid (VTK nightly, Windows XP).
However, I even could not get a very simple example running where the half
of a cube with 1000 points should not be visible. The points just do not
blank out. I have attached the code below. I would appreciate if somebody
could point out the mistake I'm doing.

Thanks a lot,
Andreas




int main( int argc, char **argv )
{
  
  //values for imageData
  vtkFloatArray *farray = vtkFloatArray::New();
    farray->SetNumberOfComponents(1);
    for(int i=0; i<1000; i++){
      farray->InsertNextValue(5);
    }

  //blanking array
  vtkUnsignedCharArray *blanking = vtkUnsignedCharArray::New();
    blanking->SetNumberOfComponents(1);
    for(int j=0; j<1000; j++){
      if(j>500){
        blanking->InsertNextValue(1);
      }
      else{
        blanking->InsertNextValue(0);
      }
    }

  vtkUniformGrid *imageData = vtkUniformGrid::New();
    imageData->SetOrigin(0,0,0);
    imageData->SetSpacing(1,1,1);
    imageData->SetDimensions(10,10,10);
    imageData->GetPointData()->SetScalars(farray);
    imageData->SetPointVisibilityArray(blanking);

  vtkDataSetMapper *mapper = vtkDataSetMapper::New();
    mapper->SetInput(imageData);

  vtkActor *actor = vtkActor::New();
    actor->SetMapper(mapper);

  vtkRenderer *renderer = vtkRenderer::New();
    renderer->AddActor(actor);
    renderer->GetActiveCamera()->Azimuth(30);
    renderer->GetActiveCamera()->Elevation(30);
    renderer->ResetCamera();

  vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(renderer);

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

  renWin->Render();
  renWin->SetSize(600,600); 
  iren->Start();

  return 0;

}




More information about the vtkusers mailing list