[vtkusers] PointInPolygon returns 1 for all points within bounds
Jothy
jothybasu at gmail.com
Mon Jul 25 05:07:01 EDT 2011
Thanks for your reply Bryn!
vtkPolygon is meant to be used for 2D polygons, but the pointInPolygon uses
a ray-tracing to find the points inside the polygon so why it will work only
for 2D polygons. The arguments are [x,y,z].
I want to calculate the dose-volume histograms from these meshes.
I will make a new post with a more appropriate subject.
Thanks again
Jothy
On Mon, Jul 25, 2011 at 7:03 AM, Bryn Lloyd <lloyd at itis.ethz.ch> wrote:
> Hi Jothy****
>
> ** **
>
> Since you are using vtkDiscreteMarchingCubes, I assume your mesh is a 3d
> surface mesh.****
>
> vtkPolygon is meant to used for 2D polygons (e.g. a triangle in the
> xy-plane). Unless you project your 3D mesh to a 2d plane, and obtain the
> silhouette, this will not work.****
>
> http://www.vtk.org/doc/nightly/html/classvtkPolyDataSilhouette.html****
>
> ** **
>
> Also, it seems dangerous or even wrong to cast the points and polygons to a
> double pointer like this. First, the points could also be floats. Second, I
> doubt the polys in your mesh can be cast to <double*>.****
>
> ** **
>
> ** **
>
> Instead, you should probably use one of the cell locators, e.g. vtkOBBTree
> or vtkCellLocator to test if your point is inside the mesh in 3D.****
>
> You could have a look at the code in “vtkSelectEnclosedPoints” to see how
> to do this in a robust way. You can even use this filter directly, via the
> function “vtkSelectEnclosedPoints::IsInsideSurface”.****
>
> http://www.vtk.org/doc/nightly/html/classvtkSelectEnclosedPoints.html****
>
> ** **
>
> Cheers****
>
> Bryn****
>
> ** **
>
> ** **
>
> ** **
>
> *From:* vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] *On
> Behalf Of *Jothy
> *Sent:* Friday, July 22, 2011 4:39 PM
> *To:* VTK Mailing List
> *Subject:* [vtkusers] PointInPolygon returns 1 for all points within
> bounds****
>
> ** **
>
> Hi all,
>
> I have a mesh generated from vtkDiscreteMarchingCubes and processed through
> vtkDecimatePro and vtkWindowedSincPolyDataFilter. Now, I want to find the
> points/voxels inside this mesh. I am using vtkPolygon::PointInPolygon. But,
> the result is "1! for the all the points whichever falls with the bounds.
>
> Here is the piece of code that I am using
>
> (smoother is vtkWindowedSincPolyDataFilter)
>
> int npts=smoother->GetOutput()-> GetPoints()->GetNumberOfPoints();// test
> point
> //double n[3]={0.707, 0.707, 0};
> double n[3];
>
> vtkSmartPointer<vtkPolygon> polygon =
> vtkSmartPointer<vtkPolygon>::New();
> *
> polygon->ComputeNormal(mapper->GetInput()->GetPoints()->GetNumberOfPoints(),
>
> static_cast<double*>(mapper->GetInput()->GetPoints()->GetData()->GetVoidPointer(0)),
> n); *
>
> double bds[6];
> smoother->GetOutput()->GetBounds(bds);
> qDebug()<< polygon->PointInPolygon(testIn,npts,*
> static_cast<double*>(mapper->GetInput()->GetPolys()->GetData()->GetVoidPointer(0)
> *),bds,n)<<"Result";
>
> Are these two highlighted lines correct?
>
> Many thanks
>
> Jothy
> ****
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110725/1d4750e9/attachment.htm>
More information about the vtkusers
mailing list