[vtkusers] write a specific point's normal of polyData
David Doria
daviddoria at gmail.com
Mon Mar 12 10:43:20 EDT 2012
On Sun, Mar 11, 2012 at 2:10 PM, Hila Hiler <hilahiler at gmail.com> wrote:
> Hi David,
>
> I'll try to explain again:
>
> How I can calculate the normal at a specific point (id) on polydata.
> I'd like to visualize that normal too, so how to write that normal (as an
> arrow)?
>
> this is what I use, but it doesn't write the normals:
> void generateNormals(vtkPolyData* polydata)
> {
>
> // Generate normals
> vtkSmartPointer<vtkPolyDataNormals> normalGenerator =
> vtkSmartPointer<vtkPolyDataNormals>::New();
> normalGenerator->SetInput(polydata);
>
> normalGenerator->ComputePointNormalsOn();
> normalGenerator->ComputeCellNormalsOff();
> normalGenerator->Update();
>
> polydata = normalGenerator->GetOutput();
>
> vtkPolyDataWriter* writer = vtkPolyDataWriter::New();
> writer->SetInput(polydata);
> writer->SetFileName("normals.vtk");
> writer->Write();
>
> }
You should use vtkXMLPolyDataWriter instead of vtkPolyDataWriter to
write vtp files instead of vtk files. Also, the normals should be
written to the file automatically. You just need to be sure to display
them. If you are using ParaView (or even your own viewer using VTK) to
view the file you can use the Glyph filter to draw arrows at each
point in the direction of the normal at that point.
David
More information about the vtkusers
mailing list