[vtkusers] Create 3D Volume from 2D DICOM Images

emreturkoz emreturkoz at gmail.com
Tue Aug 2 08:01:05 EDT 2011


Jothy thank you very much for your help. You made me a great progress. 

I also noticed something. With the code I give below, I can visualize
samples (like fish.wrl), which can be seen so to say in "mesh form". There
was an example on this 
http://people.sc.fsu.edu/~jburkardt/data/wrl_2/wrl_2.html link  called
red_chair, where a chair to be seen completely. The code below also failed
to visualize this example.

I get no errors. I only get a blank window as if no actor is loaded. But
paraView doesn't fail on these samples.

Thank you for your help.

int VRMLReader(){

  std::string filename = "fish.wrl";
  std::cout << "Reading " << filename << std::endl;
// VRML Import
vtkVRMLImporter *importer=vtkVRMLImporter::New();
importer->SetFileName(filename.c_str());
importer->Read();
importer->Update();
 
//Convert to vtkDataSet
vtkDataSet *pDataset;
vtkActorCollection *actors = importer->GetRenderer()->GetActors();
actors->InitTraversal();
pDataset = actors->GetNextActor()->GetMapper()->GetInput(); //Problem
happened here
 
//Convert to vtkPolyData
vtkPolyData *polyData = vtkPolyData::SafeDownCast(pDataset);
polyData->Update();
 

// Create Normal Vectors to enhance smoothness & illumination
vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
normals->SetInput(polyData);
normals->SetFeatureAngle(60.0);
 
// Mapper
vtkPolyDataMapper *SolidMapper = vtkPolyDataMapper::New();
SolidMapper->SetInput(normals->GetOutput());
SolidMapper->ScalarVisibilityOff();
 
// Actor
vtkActor *SolidActor = vtkActor::New();
SolidActor->SetMapper(SolidMapper);
//SolidActor->GetProperty()->SetOpacity(1);
 
// Render
vtkRenderer *ren = vtkRenderer::New();
ren->AddActor(SolidActor);
ren->SetBackground(0.1,0.3,0.1);
 
// RenderWindow
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
 
// RenderWindowInteractor
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
 
renWin->Start();
renWin->SetSize(800-5,600-5);
// interact with data
iren->Initialize();
iren->Start();
 
// delete
 
actors->Delete();
normals->Delete();
SolidMapper->Delete();
SolidActor->Delete();
ren->Delete();
renWin->Delete();
iren->Delete();
 
return 0;
       
}

--
View this message in context: http://vtk.1045678.n5.nabble.com/Create-3D-Volume-from-2D-DICOM-Images-tp4656536p4658425.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list