[vtkusers] About vtkPolyDataNormals....
Bryn Lloyd
blloyd at vision.ee.ethz.ch
Thu Nov 19 03:26:28 EST 2009
If I understand correctly you expect three normals for each cell
(=triangle), since a triangle has three points?
Then you are misinterpreting the cell normals. The triangle is planar
and has only one normal.
If you need point normals (one normal for each point), then you should
compute these, and not the cell normals.
vtkPolyDataNormals *triangleCellNormals = vtkPolyDataNormals::New();
triangleCellNormals->SetInput(triangleCellDataSetSurfaceFilter->GetOutput());
triangleCellNormals->ComputeCellNormalsOff();
triangleCellNormals->ComputePointNormalsOn() ;
triangleCellNormals->ConsistencyOn() ;
triangleCellNormals->AutoOrientNormalsOn() ;
triangleCellNormals->Update() ;
vtkFloatArray *PointNormalArray = vtkFloatArray::SafeDownCast(
triangleCellNormals->GetOutput()->GetPointData()->GetNormals());
Note the only change is in the last line:
triangleCellNormals->GetOutput()->GetPointData()->GetNormals()
-Bryn
renlishen wrote:
> Bill~thank you~
> I'm missing it and one header file "vtkCellData.h"....
> I try again and get the normal successful~
>
> but another question....
> when I change my code to GetPointData() like this
> --------------------------------------------------------------------------------
> vtkFloatArray *PointNormalArray = vtkFloatArray::SafeDownCast(
> triangleCellNormals->GetOutput()->GetPointData()->GetNormals() ) ;
> float pointNormal[ 3 ] ;
>
> for( int i = 0 ; i < PointNormalArray->GetNumberOfTuples() ; i++ )
> {
> PointNormalArray->GetTupleValue( i, pointNormal ) ;
> }
> --------------------------------------------------------------------------------
> why can I get only one normal?
> My data has three points...and the normal result should be having three
> difference answer??
> I'm confused....
>
> does anyone help me?
> Thanks~
>
> P.S. I'm using debug mode to check my pointNormal array...
--
-------------------------------------------------
Bryn Lloyd
Computer Vision Laboratory
ETH Zürich, Sternwartstrasse 7, ETF C110
CH - 8092 Zürich, Switzerland
Tel: +41 44 63 26668
Fax: +41 44 63 21199
-------------------------------------------------
More information about the vtkusers
mailing list