<div dir="ltr">On Thu, Feb 19, 2015 at 4:03 AM, seafather <span dir="ltr"><<a href="mailto:taleb.alashkar@telecom-lille.fr" target="_blank">taleb.alashkar@telecom-lille.fr</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
I am trying to estimate the normal on a mesh.<br>
I need only the "z" coponent of each normal for each veterx.<br>
I am writing this code, but it doesnt work<br>
<br>
<br>
                                                        //// Normal Estiamtion<br>
<br>
<br>
                                                        vtkSmartPointer<vtkPolyData> polydata =<br>
vtkSmartPointer<vtkPolyData>::New();<br>
<br>
                                                        vtkSmartPointer<vtkPolyDataNormals> normalGenerator =<br>
vtkSmartPointer<vtkPolyDataNormals>::New();<br>
<br>
                                                #if VTK_MAJOR_VERSION <= 5<br>
                                                        normalGenerator->SetInput(FaceImporter);<br>
                                                #else<br>
                                                        normalGenerator->SetInputData(FaceImporter);<br>
                                                #endif<br>
                                                        normalGenerator->ComputePointNormalsOn();<br>
                                                        normalGenerator->ComputeCellNormalsOn();<br>
                                                    normalGenerator->ConsistencyOn() ;<br>
                                                    normalGenerator->AutoOrientNormalsOn() ;<br>
                                                        normalGenerator->Update();<br>
<br>
                                                        polydata=normalGenerator->GetOutput();<br>
<br>
                                                          vtkFloatArray* normalDataFloat =<br>
vtkFloatArray::SafeDownCast(polydata->GetCellData()->GetNormals());<br>
<br>
<br>
                                                        int nc = normalDataFloat->GetNumberOfTuples();<br>
<br>
                                                cout << "There are " << nc << " components in normalDataFloat" <<endl;<br>
<br>
                                                int nup=nc/3;<br>
                                                 double pN[3];<br>
<br>
        for(vtkIdType i = 0; i &lt;nup; i++)<br>
         {<br>
         polydata->GetPoint(i, pN);<br>
cout << "Point ids " << i << ": " << pN[0] << " " << pN[1] << " " << pN[2]<br>
<< endl;                                                                      double testDouble[3];<br>
          normalDataFloat->GetTuple(i, testDouble);<br>
cout << "Double: " << testDouble[0] << " " << testDouble[1] << " " <<<br>
testDouble[2] << endl;<br>
<br>
}<br>
<br>
<br>
In my understanding  that the x,y,z component of the Normal are the<br>
testDouble[0],testDouble[1],testDouble[2] respectively.<br>
<br>
I want to visualize only the "z" components of the normals on the render ,<br>
how can I add them together to the mapper ?<br>
<br>
Greetings<br>
Taleb<br>
<br>
Any suggestion?<br></blockquote><div><br>Here is a new example that shows how to extract a component from an array using the vtkArrayCalculator filter:<br><br><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/ExtractArrayComponent">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/ExtractArrayComponent</a><br><br clear="all"><div><div class="gmail_signature">Let us know if that does what you're looking for.<br><br>David</div></div> </div></div><br></div></div>