[vtkusers] help with vtkPolyDataNormals

Bernhard Mayrhofer bernhard at wien-zentral.kolping.at
Tue Mar 16 08:28:56 EST 2004


The code works now(with specific ID). The Problem was a method which modified the data which was not expected.

Bernhard
  ----- Original Message ----- 
  From: Bernhard 
  To: vtkusers at vtk.org 
  Sent: Monday, March 15, 2004 6:24 PM
  Subject: [vtkusers] help with vtkPolyDataNormals


  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/20040316/7254fe94/attachment.htm>


More information about the vtkusers mailing list