Polydata Plane Cuter to make a volume render

Hello,

I am using vtk with EGL offscreen rendering due to software limitations. I am rendering patients and I would like to cut them in half and visualize only from the middle of the patient till the end so I could see it`s inside. I am using polydataplanecutter but I was not able to get a satisfactory result as only the tissues that were in the plane were renderend, and I would like to see the rest of the patient, like it was cut in half and we were seeing it from the mid position.

Thank you,

Rafeal O-Scatena,

	void PlaneCutThroughOrigin(vtkPolyData* polyData,int material, int depth){


  	  vtkCellData* cellData = polyData->GetCellData();
	
	  if(cellData){
	    
	  vtkDataArray* cellScalars  = cellData->GetArray("MATERIAL");

	    
	  if(cellScalars){	
	    
	  double range[2];

	   
	  cellScalars->GetRange(range);
	  
	    
	  std::cerr << "Range:  "<<"["<<(int)range[0]<<","<<(int)range[1]<<"]" << std::endl; 
	  
	
	  vtkNew<vtkThreshold> selectCells;
	  selectCells->SetUpperThreshold(material);
	  selectCells->SetLowerThreshold(material);
	//selectCells->UseContinuousCellRangeOn();
	  selectCells->SetInputArrayToProcess(0, 0, 0,vtkDataObject::FIELD_ASSOCIATION_CELLS,"MATERIAL");
	  selectCells->SetInputData(polyData);
	  
	  selectCells->Update();
	  
	  vtkNew<vtkGeometryFilter> geometry;
 	  geometry->SetInputConnection(selectCells->GetOutputPort());
	  geometry->Update();
	  
	  vtkSmartPointer<vtkPolyData> geometry_mesh;
	  geometry_mesh = geometry->GetOutput();

	double origin[3];	origin[0]=SIZE_X/20; origin[1]= depth; origin[3]=SIZE_X/20; 

	vtkNew<vtkPlane> plane;
	plane->SetOrigin(origin);
	plane->SetNormal(0.0, -1.0, 0.0);
	  
	vtkNew<vtkPolyDataPlaneCutter> planeCutter;
	planeCutter->SetPlane(plane);
	planeCutter->SetInputData(geometry_mesh);
	planeCutter->Update();
	
	vtkSmartPointer<vtkPolyData> planecut = planeCutter->GetOutput();
	
	vtkCellData* cellDataGeometry = planecut->GetCellData();
	vtkDataArray* bodyScalars  = cellDataGeometry->GetArray("IBODY");
	  
	  if(planecut->GetNumberOfCells()!=0){
	  
	// PRINT CELL SCALARS
	  	  
	  
	  double bodies[2];
	  std::cerr << "No of Cells:  "<< planecut->GetNumberOfCells() << std::endl;  
	  
	    bodyScalars->GetRange(bodies);
	    
	    std::cerr << "Bodies:  "<< "["<< bodies[0]<<","<<bodies[1]<<"]"<<"  Range: " <<planecut->GetCellData()->GetArray("IBODY")->GetRange(0)[0]<<  std::endl;  
	    
	    // Create a named colors object for setting renderer background and actor color
	    vtkNew<vtkNamedColors> colors;

	    // Create a renderer
	    vtkNew<vtkRenderer> renderer;
	    renderer->SetBackground(colors->GetColor3d("LightSteelBlue").GetData());

	    // Create a render window
	    vtkNew<vtkEGLRenderWindow> renderWindow;
	    renderWindow->OffScreenRenderingOn();
	    renderWindow->SetShowWindow(false);
	    renderWindow->WindowInitialize();
	    renderWindow->SetSize(640, 480);
	    renderWindow->SetWindowName("Mesh Render Window");
	    renderWindow->AddRenderer(renderer);


	    // Create a render window interactor
	    vtkNew<vtkRenderWindowInteractor> interactor;
	    interactor->SetRenderWindow(renderWindow);
	    
	    
	  int n = int(bodies[1]-bodies[0] +1);
	  
	  vtkDataArray* bodyScalars  = cellDataGeometry->GetArray("IBODY");
	  
	  
          vtkSmartPointer<vtkLookupTable> lut = MakeColors(n,planecut);
          
           std::string array_name = "IBODY";

            vtkNew<vtkPolyDataMapper> mapper;
	    mapper->SetInputData(planecut);
	    mapper->ScalarVisibilityOn();
	    mapper->SetColorModeToMapScalars();
	    mapper->SetScalarModeToUsePointData();
	    mapper->SetLookupTable(lut);
	    mapper->InterpolateScalarsBeforeMappingOff();
	    mapper->SetScalarRange(bodies[0], bodies[1]);
	    
	    int scalarValue=1;

	    vtkNew<vtkScalarBarActor> scalarBar;
	    scalarBar->SetTitle("Bodies");
	    scalarBar->SetNumberOfLabels(n);
 	    scalarBar->SetLookupTable(lut);
 	    
 	    std::string legend = "Number of Cells: " + std::to_string(planecut->GetNumberOfCells());
 	    
 	
	    // Create an actor
	    vtkNew<vtkActor> actor;
	    actor->SetMapper(mapper);
//          actor->RotateWXYZ(-90.0, 1.0, 0.0, 0.0);
            actor->GetProperty()->SetInterpolationToFlat();
            actor->SetVisibility(true);
	    actor->Modified();

     	    
	    vtkNew<vtkCubeAxesActor> cubeAxesActor;
	    cubeAxesActor->GetProperty()->SetColor(colors->GetColor3d("Gold").GetData());
            cubeAxesActor->SetBounds(planecut->GetBounds());
	    cubeAxesActor->SetCamera(renderer->GetActiveCamera());
  	    cubeAxesActor->SetXUnits("cm");
	    cubeAxesActor->SetYUnits("cm");	    
	    cubeAxesActor->SetZUnits("cm");
	    // Add the actor to the renderer
	    renderer->AddActor(actor);
	    renderer->AddActor2D(scalarBar);
            renderer->AddActor(cubeAxesActor);	  
	  	    

	  // Render the window

	  renderer->GetActiveCamera()->Elevation(-90);
	  renderer->ResetCamera();
	  renderWindow->Render();
	    
	    
	    vtkNew<vtkWindowToImageFilter> windowToImageFilter;
	    windowToImageFilter->SetInput(renderWindow);
	    windowToImageFilter->Update();
	    
	    std::string body = "planet cut" ;
	  
	    vtkNew<vtkPNGWriter> writer;
	    writer->SetFileName(body.c_str());
	    writer->SetInputConnection(windowToImageFilter->GetOutputPort());
	    writer->Write();std::cerr << "Plane Cut Complete." << std::endl;}else{std::cerr << "Error: No Cells in Plane Cut" << std::endl;}
	 }else{std::cerr << "Error: No Cell Data" << std::endl;}
	 }}

bodies for tissue8
planet cut