[vtkusers] Does vtkImageBlend or vtkAppendPolyData generate 3D / Volumetric representation of 2D Image Data or PolyData respectively

Neel007 sayanmaity.10 at gmail.com
Mon Jul 20 17:43:24 EDT 2015


Dear Cory,

I tried to  use "vtkThreshold" as you suggested. The code is executing
without any exception but "0 cells after thresholding." the vtkThreshold is
not creating any cells also I tried to visualize the vtkUnstructuredGrid
data generated by "vtkThreshold" but I couldn't see any output in the render
window.

Could you please have a look in the code and give some suggestion if I am
missing something. 

Here is the code & output window:


vtkSmartPointer<vtkTIFFReader> reader =
    vtkSmartPointer<vtkTIFFReader>::New();
  reader->SetFileNameSliceOffset(1);
  reader->SetFileNameSliceSpacing(1);
 
reader->SetFilePattern("S:\\GSoC_2015_Implementation\\test_images\\2.%d.bspline.tif");
  reader->SetDataExtent(0, 63, 0, 63, 1, 551);
  
  reader->SetOrientationType(3);
  reader->Update();
  
  vtkSmartPointer<vtkThreshold> threshold =
vtkSmartPointer<vtkThreshold>::New();
  threshold->SetInputConnection(reader->GetOutputPort());
  threshold->ThresholdByUpper(1);

  vtkUnstructuredGrid* thresholdedPolydata = threshold->GetOutput();
  std::cout << "There are " << thresholdedPolydata->GetNumberOfCells() 
            << " cells after thresholding." << std::endl;

  //Visualization UnstructuredGrid after threshold

  
  // Create a mapper and actor
  vtkSmartPointer<vtkDataSetMapper> mapper = 
    vtkSmartPointer<vtkDataSetMapper>::New();

  mapper->SetInputData(thresholdedPolydata);

  vtkSmartPointer<vtkActor> actor = 
    vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
  actor->GetProperty()->SetColor(1.0, 0.0, 0.0);
  actor->GetProperty()->SetRepresentationToWireframe();
  actor->GetProperty()->SetLineWidth(5);
 
  // Create a renderer, render window, and interactor
  vtkSmartPointer<vtkRenderer> renderer = 
    vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkRenderWindow> renderWindow = 
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = 
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);
 
  // Add the actors to the scene
  renderer->AddActor(actor);
  //renderer->SetBackground(1,1,1); // Background color white
 
  // Render and interact
  renderWindow->Render();
  renderWindowInteractor->Start();

Output windows:

<http://vtk.1045678.n5.nabble.com/file/n5733001/Capture1.png> 

<http://vtk.1045678.n5.nabble.com/file/n5733001/Capture2.png> 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Does-vtkImageBlend-or-vtkAppendPolyData-generate-3D-Volumetric-representation-of-2D-Image-Data-or-Poy-tp5732834p5733001.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list