<div dir="ltr"><div> </div>
<div>Hello Vtk Users,</div>
<div> </div>
<div>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 ?</div>
<div> </div>
<div>Is there any way to show the normals on the screen ?</div>
<div> </div>
<div>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 :)</div>
<div> </div>
<div>thank you,</div>
<div>yaroslav<br clear="all"></div>
<h1>[vtkusers] How should I get the right normal of a polygon defined in vtkCellArray?</h1><b>Amy Squillacote</b> <a title="[vtkusers] How should I get the right normal of a polygon
        defined in vtkCellArray?" href="mailto:vtkusers%40vtk.org?Subject=%5Bvtkusers%5D%20How%20should%20I%20get%20the%20right%20normal%20of%20a%20polygon%0A%09defined%20in%20vtkCellArray%3F&In-Reply-To=BAY109-F32A78622FBED72BAF2794BB88C0%40phx.gbl">amy.squillacote at kitware.com </a><br>
<i>Thu Sep 29 08:59:36 EDT 2005</i>
<p>
<ul>
<li>Previous message: <a href="http://www.vtk.org/pipermail/vtkusers/2005-September/081956.html">[vtkusers] How should I get the right normal of a polygon defined in vtkCellArray? </a>
<li>Next message: <a href="http://www.vtk.org/pipermail/vtkusers/2005-September/081958.html">[vtkusers] Is it a VTK bug of vtkDelaunay2D ? </a>
<li><b>Messages sorted by:</b> <a href="http://www.vtk.org/pipermail/vtkusers/2005-September/date.html#81957">[ date ]</a> <a href="http://www.vtk.org/pipermail/vtkusers/2005-September/thread.html#81957">[ thread ]</a> <a href="http://www.vtk.org/pipermail/vtkusers/2005-September/subject.html#81957">[ subject ]</a> <a href="http://www.vtk.org/pipermail/vtkusers/2005-September/author.html#81957">[ author ]</a> </li>
</li></li></ul>
<hr>
<pre>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
</pre></p></div>