[vtkusers] help with vtkPolyDataNormals

Bernhard bernhard at wien-zentral.kolping.at
Mon Mar 15 12:24:10 EST 2004


Hi!

I used vtkpolydatanormals to calculate normals.  I uses a cone to visualize if the calculation is correct. i tried severel input dataset, only vtkplanesource works well. if i use vtksperesource, the normal"cone" shows in the wrong direction. My code looks like this:

vtkSphereSource *cylinder = vtkSphereSource::New();
  cylinder->SetRadius( 1 );
  cylinder->SetThetaResolution(50); 
  cylinder->SetPhiResolution(50);
vtkTriangleFilter *Triangles = vtkTriangleFilter::New();
  Triangles->SetInput(cylinder->GetOutput());
vtkDecimatePro *deci = vtkDecimatePro::New();
 deci->SetInput(Triangles->GetOutput());
 deci->SetTargetReduction(0.0);
 deci->PreserveTopologyOn();
vtkPolyDataNormals *ViewNormals = vtkPolyDataNormals::New  ();
 ViewNormals->SetInput(deci->GetOutput());
 ViewNormals->SetFeatureAngle(60.0);
 ViewNormals->FlipNormalsOff();
 ViewNormals->Update();
......
 vtkPoints *datapoints=vtkPoints::New();
 datapoints=ViewNormals->GetOutput()->GetPoints();
 float points[3];
 float *normalen;
 vtkPolyData *profile=vtkPolyData::New();
 profile=(ViewNormals->GetOutput());

 for(ID=0;ID<nPoints;ID++)
 {
  datapoints->GetPoint(ID,points);
  normalen=profile->GetPointData()->GetNormals()->GetTuple(ID);
 }

vtkConeSource *cone = vtkConeSource::New();
  cone->SetHeight( 0.5 );
  cone->SetRadius( 0.05 );
  cone->SetResolution( 20 );
  cone->SetCenter(points[0],points[1],points[2]);
  cone->SetDirection(normalen[0],normalen[1],normalen[2]);

I expect that the cone shows in the direction of the normal (SetDirection), but it doesn´t. I tried a lot, but i can´t find the mistake. Maybe you have some ideas.

Thanks a lot
Bernhard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040315/bb0b754c/attachment.htm>


More information about the vtkusers mailing list