[vtkusers] surface normal and curvatures calculation
Ismail Elkhrachy
I.Elkhrachy at tu-bs.de
Sun Nov 26 08:34:51 EST 2006
dear All,
I have point cloud xyz coordinates of surface i want to claculate
surface normal and curvatures (Min and Max).
I use visual c++6 with vtk 5.0. I am beginner with c++ op. I used the
following code, i have got a stack!!
Theres is any one help thanks in advanced
ismail
#include "vtkPolyDataNormals.h"
#include "vtkCurvatures.h"
#include "vtkPointData.h"
#include "vtkPoints.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
int main()
{
FILE *fp;
vtkPoints* cloud1 = vtkPoints::New();
static float mypoint_1[3];
fp=fopen("data\\scan4.nor","rb"); // cloud points X Y Z coordinates
if(fp==NULL)
{
puts("Cannot open file");
exit(0);
}
while(fscanf (fp,"%f %f
%f\n",&mypoint_1[0],&mypoint_1[1],&mypoint_1[2]) != EOF)
{
cloud1->InsertNextPoint(mypoint_1);
}
fclose(fp);
vtkPolyData* polyData1 = vtkPolyData::New();
polyData1->SetPoints(cloud1);
polyData1->GetPolys();
//Surface Normals calculation for polyData1
vtkPolyDataNormals *Normals1 = vtkPolyDataNormals::New();
Normals1->SetInput(polyData1);
Normals1->SetFeatureAngle(45);
Normals1->FlipNormalsOff();
Normals1->Update();
//I need to calculate Mean and Gauss curvatures But I am not
sure with the following code or not
vtkCurvatures *curvater = vtkCurvatures::New();
curvater->SetInput(polyData1);
// How to print the normal values and the curvature (Min and
Max) foe each vertix
for ( int pointID=0; pointID < polyData1->GetNumberOfPoints();
pointID++)
{
float *point =
(float*)polyData1->GetPointData()->GetNormals()->GetTuple(pointID);
printf("x-> %f",(*point+0) );
printf("y-> %f",(*point+1) );
printf("z-> %f",(*point+2) );
}
return 0;
}
--
M.Sc. Ismail Elkhrachy
PhD student
Institut für Geodäsie und Photogrammetrie
Technische Universität Braunschweig
Gaußstr. 22
38106 Braunschweig
Germany
Mob. : 0049 0163 3623486
Tel. : 0049 0531 3917497
Fax : 0049 0531 3917499
E-mail : I.Elkhrachy at tu-bs.de, I.Elkhrachy at yahoo.com
More information about the vtkusers
mailing list