[vtkusers] normal estimation "z" component

seafather taleb.alashkar at telecom-lille.fr
Thu Feb 19 04:03:00 EST 2015


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?

							 



--
View this message in context: http://vtk.1045678.n5.nabble.com/normal-estimation-z-component-tp5730441.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list