[vtkusers] vtkPolygon::PoinInPolygon and normals

David Doria daviddoria at gmail.com
Fri Jul 22 07:24:16 EDT 2011


On Fri, Jul 22, 2011 at 5:43 AM, Jothy <jothybasu at gmail.com> wrote:

> Hi all,
>
> I have a vtkPolyData (generated from vtkDiscreteMarchingCubes) and I
> need to find out the points inside this 3D polygon. I looked at this
> example in wiki
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/PointInPolygon.
>
> I tried to calculate the normal like
>
> vtkSmartPointer<vtkPolygon> polygon =
>    vtkSmartPointer<vtkPolygon>::New();
> double n[3];
> //pd=vtkPolyData (mesh)
>  polygon->ComputeNormal(pd->GetPoints()->GetNumberOfPoints(),
>
>  static_cast<double*>(pd->GetPoints()->GetData()->GetVoidPointer(0)),
> n);
>
> but qDebug()<<n;//similar to std::cout
>
> it prints a hexadecimal number.
>
> I don't understand how to do this correctly.
>
> Also, should I calculate this normal for each point I am testing.
>
> Thanks
>
> Jothy
>

'n' is an array, so the hex number you are seeing is a memory address of the
first element of n.

You should see what you expect with

cout << n[0] << " " << n[1] << " " << n[2];

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110722/6c5141a9/attachment.htm>


More information about the vtkusers mailing list