[vtkusers] normal estimation "z" component
David Doria
daviddoria at gmail.com
Thu Feb 19 11:26:02 EST 2015
On Thu, Feb 19, 2015 at 4:03 AM, seafather <taleb.alashkar at telecom-lille.fr>
wrote:
> Hello,
> I am trying to estimate the normal on a mesh.
> I need only the "z" coponent of each normal for each veterx.
> I am writing this code, but it doesnt work
>
>
> //// Normal
> Estiamtion
>
>
>
> vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
>
>
> vtkSmartPointer<vtkPolyDataNormals> normalGenerator =
> vtkSmartPointer<vtkPolyDataNormals>::New();
>
> #if VTK_MAJOR_VERSION <= 5
>
> normalGenerator->SetInput(FaceImporter);
> #else
>
> normalGenerator->SetInputData(FaceImporter);
> #endif
>
> normalGenerator->ComputePointNormalsOn();
>
> normalGenerator->ComputeCellNormalsOn();
>
> normalGenerator->ConsistencyOn() ;
>
> normalGenerator->AutoOrientNormalsOn() ;
>
> normalGenerator->Update();
>
>
> polydata=normalGenerator->GetOutput();
>
> vtkFloatArray*
> normalDataFloat =
> vtkFloatArray::SafeDownCast(polydata->GetCellData()->GetNormals());
>
>
> int nc =
> normalDataFloat->GetNumberOfTuples();
>
> cout << "There are " << nc
> << " components in normalDataFloat" <<endl;
>
> int nup=nc/3;
> double pN[3];
>
> for(vtkIdType i = 0; i <nup; i++)
> {
> polydata->GetPoint(i, pN);
> cout << "Point ids " << i << ": " << pN[0] << " " << pN[1] << " " << pN[2]
> << endl;
> double testDouble[3];
> normalDataFloat->GetTuple(i, testDouble);
> cout << "Double: " << testDouble[0] << " " << testDouble[1] << " " <<
> testDouble[2] << endl;
>
> }
>
>
> In my understanding that the x,y,z component of the Normal are the
> testDouble[0],testDouble[1],testDouble[2] respectively.
>
> I want to visualize only the "z" components of the normals on the render ,
> how can I add them together to the mapper ?
>
> Greetings
> Taleb
>
> Any suggestion?
>
Here is a new example that shows how to extract a component from an array
using the vtkArrayCalculator filter:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/ExtractArrayComponent
Let us know if that does what you're looking for.
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150219/57326e72/attachment.html>
More information about the vtkusers
mailing list