[vtkusers] write a specific point's normal of polyData

Hila Hiler hilahiler at gmail.com
Tue Mar 13 07:33:25 EDT 2012


Thank you David,

I have several questions regarding your answer, I would very appreciate it
if you could answer any further information:

this is my code:

//the first function calculates normals to a member type
void angleCalc::generateNormals(
vtkPolyData *polydata)
{
    m_normalGenerator->SetInput(polydata);
    m_normalGenerator->ComputePointNormalsOn();
    m_normalGenerator->ComputeCellNormalsOff();
    m_normalGenerator->Update();
}

//second function returns the normal at a specific idx from the polydata
double* angleCalc::getNormal(vtkIdType idx)
{
    double arr[3];
    arr[0] =
m_normalGenerator->GetOutput()->GetPointData()->GetComponent(idx,0);
    arr[1] =
m_normalGenerator->GetOutput()->GetPointData()->GetComponent(idx,1);
    arr[2] =
m_normalGenerator->GetOutput()->GetPointData()->GetComponent(idx,2);
    return arr;
}

questions:
-------------
1. why the following window of vtk appears with this massage ?
      "vtkFieldData::GetComponent was deprecated for vtk 5.2 and will be
removed "
2. what's the difference between calculating cell/point normals?

3. regarding the vtkXMLPolyDataWriter:
      - why the .vtp represents in 3d Glyphse arrows in the* same
direction*as the surface and not in the orthogonal plane as supposed
to be? (image
attached)

>
>

Many Thanks!
Best,
Hila

>
> On Mon, Mar 12, 2012 at 4:43 PM, David Doria <daviddoria at gmail.com> wrote:
>
>> 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
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120313/99ed0f41/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: normals.jpg
Type: image/jpeg
Size: 39205 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120313/99ed0f41/attachment.jpg>


More information about the vtkusers mailing list