[vtkusers] How to extract the vertex normal from vtkPolyDataNormals ?

Yaroslav Tenzer krakadil.gena at gmail.com
Wed Nov 19 08:18:46 EST 2008


Dear Bjoern,

Thank you again for your reply, I have not touched it for a while now but I
do need to finish the project and I still find myself confused. Please do
correct me if I am wrong in my thought pipeline ... :)

1) There are N connected polygons, which are the output from the collision
detection algorithm.
2) for the force reflections I need to find the middle of the area and the
direction of the force, therefore to find the direction I am trying to
calculate the Vertex Normal (the average of the normals) to decide on where
to apply the forces.
3) it seems that vtkPolyDataNormals can do it easily but I do not know how
... hmm .. :(

If I use the following code :
--
vtkPolyDataNormals *PDnormals = vtkPolyDataNormals::New();
PDnormals->SetInput(myMesh);
PDnormals->Update();
vtkNormals *normals = PDnormals->GetPointData()->GetNormals();
float *n = normals->GetNormal(i);
--
It only gives me the normals of the polygons ...
but how do I get the averaged one ? the vertex normal ? it seems that it
does calcualte it somehow ...

any ideas ?
thank you,
yaroslav

On Thu, Sep 25, 2008 at 10:32 AM, "Björn Zehner" <bjoern.zehner at ufz.de>wrote:

> Dear Yaroslav,
> I am not sure, what do you mean by "but vtkPolyDataNormals calculates
> the average normal for all normals as well" and where does it say that
> vtkPolyDataNormals calculates this.
>
> In the documentation it says: "The algorithm works by determining normals
> for each polygon and then averaging them at shared points". Is it this what
> you mean? This would be the way to calculate the normals of a surfaces at
> its vertices. So with vtkPolyDataNormals you need to set
> vtkPolyDataNormals->ComputerPointNormalsOn();
>
> For the Visualization I guess that you could use vtkGlyph3D with
> ->SetVectorModeToUseNormal()
>
> Hope that helps,
> Bjoern Zehner
>
>
> ----- Ursprüngliche Nachricht -----
> Von: Yaroslav Tenzer <krakadil.gena at gmail.com>
> Datum: Mittwoch, 24. September 2008, 15:32
> Betreff: [vtkusers] How to extract the average normal from
> vtkPolyDataNormals ?
> An: vtkusers at vtk.org
> Cc: amy.squillacote at kitware.com
>
>
>
> > Hello Vtk Users,
>
> > I have seen a post by Amy in 2005 on how to access the normals of each
> polygon ... but vtkPolyDataNormals calculates the average normal for all
> normals as well ... how do I extract the averaged one from the filter ?
>
> > Is there any way to show the normals on the screen ?
>
> > I have four polygons ... and I want to find the average normal for them
> ... and show it on the screen ... and I do not want to reinvent the wheel :)
>
> > thank you,
> > yaroslav
>
> > [vtkusers] How should I get the right normal of a polygon defined in
> vtkCellArray?*Amy Squillacote* amy.squillacote at kitware.com
> *> Thu Sep 29 08:59:36 EDT 2005*
>
>
>    - > Previous message: [vtkusers] How should I get the right normal of a
>    polygon defined in vtkCellArray?
>    <http://www.vtk.org/pipermail/vtkusers/2005-September/081956.html>
>    - Next message: [vtkusers] Is it a VTK bug of vtkDelaunay2D ?
>    <http://www.vtk.org/pipermail/vtkusers/2005-September/081958.html>
>    - *Messages sorted by:* [ date ]<http://www.vtk.org/pipermail/vtkusers/2005-September/date.html#81957> [
>    thread ]<http://www.vtk.org/pipermail/vtkusers/2005-September/thread.html#81957> [
>    subject ]<http://www.vtk.org/pipermail/vtkusers/2005-September/subject.html#81957> [
>    author ]<http://www.vtk.org/pipermail/vtkusers/2005-September/author.html#81957>
>
> ------------------------------
>
> > The normals created by this filter are in a float array in CellData,   > not in a vtkCellArray (which only provides information about how   > points are connected to form each cell). To apply the filter to your   > data and then access the normal of each polygon, do the following.  >   > vtkPolyDataNormals *normals = vtkPolyDataNormals::New();  > normals->SetInput(yourData);  > normals->ComputeCellNormalsOn();  > normals->ComputePointNormalsOff();  > normals->Update();  >   > vtkFloatArray *normArray =   > vtkFloatArray::SafeDownCast(normals->GetOutput()->GetCellData()->GetNormals());  > int i;  >   > float point[3];  > for (i = 0; i < normArray->GetNumberOfTuples(); i++)  > {  >      point[0] = normArray->GetValue(i, 0);  // x-component of normal  >      point[1] = normArray->GetValue(i, 1);  // y-component of normal  >      point[2] = normArray->GetValue(i, 2);  // z-component of normal  >   > // Do whatever you need to do to write this value to a file here.  > }  >   > - Amy  >   >
>
>
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQFollow this link to
> > subscribe/unsubscribe:http://www.vtk.org/mailman/listinfo/vtkusers
>
> -------------------------------------------------------------------------
> Dr. Bjoern Zehner
> UFZ Centre for Environmental Research Leipzig-Halle
> Permoserstrasse 15
> 04318 Leipzig
> Germany
> http://www.ufz.de/index.php?en=5673
> Tel: ++49 (341) 235 1979
> Fax: ++49 (341) 235 1939
>
>
>
> _______________________________________________
> 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
>
>


-- 
yaroslav
www.bgu.ac.il/~tenzer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081119/6e323b0b/attachment.htm>


More information about the vtkusers mailing list