[Insight-users] WG: VTK Marching Cubes Filters / Iso-surfacing filter

salah salah at gris.uni-tuebingen.de
Tue Feb 22 04:40:51 EST 2005


Hello,
I am trying to post this message to the VTK mailing list since yesterday. The delivery
failed many times. Is the server down? or I have some problem?
Thanks,
Zein

>  -----Ursprüngliche Nachricht-----
> Von: 	salah  
> Gesendet:	Dienstag, 22. Februar 2005 10:33
> An:	'vtkusers at vtk.org'
> Betreff:	VTK Marching Cubes Filters / Iso-surfacing filter 
> 
> Hello All,
> 
> Perhaps my questions are stupid, but I am not a vtk expert! unfortunately not even a good user :)
> 
> 1. I am wondering if there is a difference between these itk isosurfacing filter? do they all
>    generate triangulated surfaces? Do they all implement the traditional MC algorithm?
> 
>    vtkMarchingContourFilter, vtkKitwareContourFilter, vtkMarchingCubes, vtkImageMarchingCubes
> 
> 2. Is the filter used in paraview for iso-surfacing (vtkPVKitwareContourFilter) even something different?
> 
> 3. The output of the vtkImageMarchingCubes filter is a vtkPolyData, right? does not this vtkpolydata 
>    have normals informations? 
> 
> 4. I have been using the code segment bellow to generate, visualize, and save iso-surfaces from 
>    ITK 3d images. 
> 
>    Now,
>        - The surface rendered using this piece of code is properly lit. How could this happen if vertices' 
>          normals are not there?
> 
>        - I tried to load the saved vtkpolydata (the ASCII file generated by vtkPolyDataWriter) using
>          paraview. Only a portion of the model is lit fine. Most parts of the model are black! 
>          By openning this ascii file using a text editor. I saw that normal information is written 
>          as the last part of the file. 
> 
> In short, and if I am missing/misunderstanding something, what is the right sequence to generate, render,
> and save triangulated iso-surfaces using vtk? I need normals for further processing.
> 
> Many thanks,
> 
> Zein 
> 
>  
> // =============================== CODE =============================
> 
> // convert to vtk image
>    typedef itk::ImageToVTKImageFilter<ImageType> Itk2VtkType;
>    Itk2VtkType::Pointer  m_Itk2Vtk = Itk2VtkType::New();
> 
>    m_Itk2Vtk->SetInput(inputImage);  // m_Reader reads a binary image
>    m_Itk2Vtk->Update();
>    std::cout << "Image converted to VTK...." << std::endl;
> 
>   
> 
> // generate iso surface
>     vtkImageMarchingCubes *marcher = vtkImageMarchingCubes::New();
>     marcher->SetInput(m_Itk2Vtk->GetOutput());
>     marcher->SetValue(0, 100);
>     marcher->Update();
>     std::cout << "Marching Cube finished...." << std::endl;
> 
> 
>     vtkDecimate *decimator = vtkDecimate::New();
>     decimator->SetInput(marcher->GetOutput());
>     decimator->SetTargetReduction(0.1);
>     decimator->SetMaximumIterations(4);
>     decimator->SetInitialError(0.01);
>     decimator->SetErrorIncrement(0.01);
>     decimator->SetPreserveTopology(1);
>     decimator->Update();
> 
>     vtkSmoothPolyDataFilter* smoother = vtkSmoothPolyDataFilter::New();
>     smoother->SetInput(decimator->GetOutput());
>     smoother->SetNumberOfIterations(5);
>     smoother->SetFeatureAngle(60);
>     smoother->SetRelaxationFactor(0.05);
>     smoother->FeatureEdgeSmoothingOff();
>     std::cout << "VTK Smoothing mesh finished...." << std::endl;
> 
> 
> // Save the mesh in an ASCII file
>     char *meshFname =  fl_file_chooser("Choose VTK Mesh File", "*.msh*", "d:/datanpr");
>    
>     vtkPolyDataWriter *vtkwriter = vtkPolyDataWriter::New();
>     vtkwriter->SetFileName(meshFname);
>     vtkwriter->SetInput(smoother->GetOutput());
>     vtkwriter->SetFileTypeToASCII();
>     vtkwriter->Update();
> 
> // render 3D model
>     vtkPolyDataMapper* isoMapper = vtkPolyDataMapper::New();
>     isoMapper->SetInput(marcher->GetOutput());
>     isoMapper->ScalarVisibilityOff();
> 
>     vtkActor* actor = vtkActor::New();
>     actor->SetMapper(isoMapper);
>     actor->GetProperty()->SetDiffuseColor(1,1,0.9412);
> 
>     vtkRenderer* ren = vtkRenderer::New();> 
>     vtkRenderWindow* renwin = vtkRenderWindow::New();
>     vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
> 
>     renwin->SetSize(500, 500);    
>     renwin->AddRenderer( ren );
>     iren->SetRenderWindow(renwin);
> 
>     ren->SetBackground(0.52, 0.57, 1.0);   
>     ren->AddActor(actor);
> 
>     renwin->Render();
>     iren->Start();
> 
> 


More information about the Insight-users mailing list