[vtkusers] WG: VTK Marching Cubes Filters / Iso-surfacing filter
Amy Henderson
amy.henderson at kitware.com
Tue Feb 22 08:32:31 EST 2005
Your message has appeared now 3 times on the VTK mailing list. The
delivery failure e-mail you received is from an e-mail account belonging to
someone on the list, not from the list itself. This has been difficult to
track down because the address is not actually in the list of subscibers to
the VTK users list. Most likely someone on the list is forwarding their
mail to an e-mail account that is producing the delivery failure messages.
I've provided answers after each of the questions in your e-mail.
- Amy
At 04:40 AM 2/22/2005, salah wrote:
>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
They all generate triangulated surfaces, but they do not all implement the
marching cubes algorithm. vtkMarchingContourFilter uses vtkMarchingSquares
and vtkMarchingCubes if the input is of type vtkImageData (or
vtkStructuredPoints, an empty subclass of vtkImageData); for all other data
set types, it uses vtkContourFilter. vtkKitwareContourFilter uses various
types of the synchronized templates algorithm depending on the input data
set type (image data, structured grid, or rectilinear grid); for other data
set types, vtkContourFilter is used. vtkMarchingCubes and
vtkImageMarchingCubes implement varieties of the marching cubes algorithm.
> >
> > 2. Is the filter used in paraview for iso-surfacing
> (vtkPVKitwareContourFilter) even something different?
vtkPVKitwareContourFilter is a subclass of vtkKitwareContourFilter. The
only benefit it adds is allowing you to select which scalar array to
contour on.
> >
> > 3. The output of the vtkImageMarchingCubes filter is a vtkPolyData,
> right? does not this vtkpolydata
> > have normals informations?
The output will have normals information if ComputeNormals is set to
1. This is its default value.
> >
> > 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();
> >
> >
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
>http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list