[vtkusers] How to find specific point's normal....?
David Doria
daviddoria+vtk at gmail.com
Thu Apr 8 11:13:12 EDT 2010
On Thu, Apr 8, 2010 at 11:01 AM, renlishen <renlishen at gmail.com> wrote:
>
> David, thanks for your reply
> I'm using
> =============================================================================
> vtkFloatArray *PointNormalArray = vtkFloatArray::SafeDownCast(
> mCubes->GetOutput()->GetPointData()->GetNormals() ) ;
> float Normal2[ 8000 ] ;
> float *pTR = Normal2 ;
> for( int i = 0 ; i < PointNormalArray->GetNumberOfTuples() ; i++ )
> {
> PointNormalArray->GetTupleValue( i, pTR ) ;
> pTR+=3 ;
> }
> ===============================================================================
> to get normals.
> But I don't know how to assign the GetTupleValue to my point data set...
> I try to use point ID to find normal, but some error happen...
> My data set is
> vtkImageData *ImageDataSrc = vtkImageData::New() ;
> ImageDataSrc->SetDimensions(512, 512, 512) ;
> ImageDataSrc->SetScalarType(VTK_UNSIGNED_CHAR) ;
> ImageDataSrc->AllocateScalars() ;
> .....
> .....
> compute normal by
> vtkMarchingCubes *mCubes = vtkMarchingCubes::New() ;
> mCubes->SetInput( ImageDataSrc ) ;
> mCubes->SetValue( 0, 100 ) ;
> mCubes->ComputeNormalsOn() ;
>
> for example: if I want to know the point( 236,236,236 )'s normal...
> how can I get it~?
>
> thanks again...
>
> RenLi~
You can use the ComputePointId function to get the point ID:
int location[3] = {236,236,236};
vtkIdType id = mCubes->GetOutput()->ComputePointId(location);
PointNormalArray->GetTupleValue(id, pTR ) ;
Is that what you are looking for?
Thanks,
David
More information about the vtkusers
mailing list