[vtkusers] Point normals problem

hengdahe hengdahe at hust.edu.cn
Mon Feb 2 21:58:41 EST 2015


I tried to get the point normals of a simple cube , but it turned out to be 
1,0,0 1,0,0 1,0,0 -1,0,0 -1,0,0 -1,0,0 (6 points) 
there must be sth wrong with it   


I need your help, thank you very much~ 



*I used this to compute and get the point normals:*

 vtkSmartPointer<vtkPolyDataNormals> normalGenerator =
vtkSmartPointer<vtkPolyDataNormals>::New(); 
#if VTK_MAJOR_VERSION <= 5 
    normalGenerator->SetInput(polydata); 
#else 
    normalGenerator->SetInputData(polydata); 
#endif 
    normalGenerator->ComputePointNormalsOn(); 
    normalGenerator->ComputeCellNormalsOff(); 
    normalGenerator->SetSplitting(0); 
        normalGenerator->Update(); 
polydata = normalGenerator->GetOutput(); 
  vtkFloatArray* normalDataFloat = 
   
vtkFloatArray::SafeDownCast(polydata->GetPointData()->GetArray("Normals")); 
 int nc = normalDataFloat->GetNumberOfTuples(); 
    std::cout << "There are " << nc 
            << " components in normalDataFloat" << std::endl; 
int nup=nc/3; 
 double pN[3]; 
    for(vtkIdType i = 0; i <nup; i++) 
      { 
      
      polydata->GetPoint(i, pN); 
      std::cout << "Point ids " << i << ": " 
                << pN[0] << " " << pN[1] << " " << pN[2] << std::endl; 
       double testDouble[3]; 
      normalDataFloat->GetTuple(i, testDouble); 
  
      std::cout << "Double: " << testDouble[0] << " " 
              << testDouble[1] << " " << testDouble[2] << std::endl; 
  
}



--
View this message in context: http://vtk.1045678.n5.nabble.com/Point-normals-problem-tp5730290.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list