[vtkusers] how to calculate normals on the surface of a 3d objectin VTK?
Bernhard Mayrhofer
berninho1 at hotmail.com
Thu Sep 23 06:42:10 EDT 2004
Hello Vidya,
every point in the dataset has its own ID. If you want all normals, you only
need a loop eg:
for(pointID=0;pointID<dataset->GetOutput()->GetNumberOfPoints();pointID++)
GetPointData()->GetNormals()->GetTuple(pointID) gives you the adress of the
first coordinate. add 1 to the pointer you get x, add 2 to get the
z-component.
To display the normals, try vtkHedgeHog. I have never tried it, but i image
this can help you.
Bernhard
---- Original Message -----
From: "Vidya Raghavan" <vidya_raghavan at hotmail.com>
To: <berninho1 at hotmail.com>; <vtkusers at vtk.org>
Sent: Wednesday, September 22, 2004 10:27 PM
Subject: Re: [vtkusers] how to calculate normals on the surface of a 3d
objectin VTK?
>
> Bernhard,
>
> Thanks so much for your help. Now given I get these float values for the
> normals, how do I render these values? I would like to verify them by
> seeing how they are displayed, before I use these values as input for
> other stuff. Here is the code that I have now: Thanks again.
>
>
> #include "vtkPolyDataMapper.h"
> #include "vtkRenderWindow.h"
> #include "vtkCamera.h"
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include "vtkXMLPolyDataReader.h"
> #include "vtkPolyDataNormals.h"
> #include "vtkPolyData.h"
> #include "vtkPointData.h"
>
> int main( int argc, char *argv[] )
> {
>
>
> vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New();
> reader1->SetFileName("model1.vtp");
>
>
> vtkPolyDataNormals *dataset = vtkPolyDataNormals::New();
> dataset->SetInput(reader1->GetOutput());
> dataset->SetFeatureAngle(60.0);
> dataset->FlipNormalsOff();
> dataset->Update();
>
> //to access the values:
>
> float *point;
> int pointID = 1;
> // do I iterate here, instead of getting the first tuple for
> the point?
>
> point =
> (float*)reader1->GetOutput()->GetPointData()->GetNormals()->GetTuple(pointID);
>
> printf("point -> %f",*point);
>
>
>
> reader1->Delete();
> dataset->Delete();
>
> //ren1->Delete();
> //renWin->Delete();
> return 0;
> }
>
>
>
>>From: "Bernhard Mayrhofer" <berninho1 at hotmail.com>
>>To: "Vidya Raghavan" <vidya_raghavan at hotmail.com>
>>Subject: Re: [vtkusers] how to calculate normals on the surface of a 3d
>>objectin VTK?
>>Date: Wed, 22 Sep 2004 09:16:57 +0200
>>
>>
>>hi vidya,
>>
>>the C++ code i used to create normals is:
>>
>>vtkPolyDataNormals *dataset = vtkPolyDataNormals::New ();
>>dataset->SetInput(TrianglesModel->GetOutput());
>>dataset->SetFeatureAngle(60.0);
>>dataset->FlipNormalsOff();
>>dataset->Update();
>>
>>to access the values, i used:
>>float *point;
>>point=Model->GetOutput()->GetPointData()->GetNormals()->GetTuple(pointID);
>>
>>bernhard
>>
>>
>>
>>
>>----- Original Message ----- From: "Vidya Raghavan"
>><vidya_raghavan at hotmail.com>
>>To: <vtkusers at public.kitware.com>
>>Sent: Tuesday, September 21, 2004 6:05 PM
>>Subject: [vtkusers] how to calculate normals on the surface of a 3d
>>objectin VTK?
>>
>>
>>>Hi,
>>>
>>>I currently have code to display 3D segmented data. Is there a way I can
>>>calulate normals at every point on the surface of the object?
>>>
>>>Thanks for any help,
>>>
>>>-vidya
>>>
>>>_________________________________________________________________
>>>Search for your life partner made easy.
>>>http://www.bharatmatrimony.com/cgi-bin/bmclicks1.cgi?74 On
>>>BharatMatrimony.com
>>>
>>>_______________________________________________
>>>This is the private VTK discussion list. Please keep messages on-topic.
>>>Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>>Follow this link to subscribe/unsubscribe:
>>>http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>
>
More information about the vtkusers
mailing list