[prev in list] [next in list] [prev in thread] [next in thread]
List: vtkusers
Subject: Re: [vtkusers] FindClosestPointWithinRadius issue in vtkKdTree
From: xabi riobe <xabivtk () gmail ! com>
Date: 2010-03-31 7:33:56
Message-ID: u2kb38cd42e1003310033s5048c308s7ddc6fb2a1cc2a15 () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Thank you Andy to take a look at this.
Which class did you modify? is it normal that I see no change yet in
http://public.kitware.com/cgi-bin/viewcvs.cgi/Filtering/ ?
2010/3/29 Andy Bauer <andy.bauer@kitware.com>
> Thanks for the bug report. I just fixed it and it should go into the new
> vtk release.
>
> Andy
>
>
>>
>> Message: 1
>> Date: Thu, 25 Mar 2010 14:44:44 +0100
>> From: xabi riobe <xabivtk@gmail.com>
>> Subject: [vtkusers] FindClosestPointWithinRadius issue in vtkKdTree
>> To: vtkusers@vtk.org
>> Message-ID:
>> <b38cd42e1003250644x1a70b70bm65234f02d22ef219@mail.gmail.com>
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> Hi,
>>
>> I was trying to use vtkKdTreePointLocator to find closest points but from
>> the results i obtain i'm wondering wheather there is an issue with the
>> method FindClosestPointWithinRadius, because sometimes it returns some
>> points with a distance bigger than the radius.
>>
>> This method calls vtkKdTree::FindClosestPointWithinRadius which calls
>> vtkKdTree::FindClosestPointInSphere, but here the point returned can be
>> out
>> of the sphere.
>> I think there must be an additional test in one of these two methods to
>> compare the distance and the given radius.
>>
>> here is a program test, with a comparison with vtkPointLocator that works
>> well.
>>
>> PS: i also want to bring back this problem:
>>
>> http://old.nabble.com/vtkCellLocator-precision-issue-td27453637.html#a27453637
>> which can maybe solve this one
>>
>> http://old.nabble.com/vtkCell::IntersectWithLine-issues-td18225442.html#a18234362
>>
>>
>> #include <vtk/vtkActor.h>
>> #include <vtk/vtkCleanPolyData.h>
>> #include <vtk/vtkCubeSource.h>
>> #include <vtk/vtkPolyData.h>
>> #include <vtk/vtkPolyDataMapper.h>
>> #include <vtk/vtkProperty.h>
>> #include <vtk/vtkRenderer.h>
>> #include <vtk/vtkRenderWindow.h>
>> #include <vtk/vtkRenderWindowInteractor.h>
>> #include <vtk/vtkSmartPointer.h>
>>
>> #define MY_SP(class, variable)\
>> vtkSmartPointer<class> variable = vtkSmartPointer<class>::New();
>>
>> const double cst_dRadius = 1.2;
>>
>> #include <vtk/vtkKdTreePointLocator.h>
>> #include <vtk/vtkPointLocator.h>
>>
>> bool ComputePointDistances(vtkKdTreePointLocator *locator, vtkPolyData
>> *in)
>> {
>> int num = in->GetNumberOfPoints();
>> cout << "number of input points : " << num << endl;
>> vtkPoints *pPoints = in->GetPoints();
>> double pt[3];
>> int cpt = 0;
>> double dDist2 = 0;
>>
>> int bad = 0;
>> int id = -1;
>> for(int i=0; i<num; ++i)
>> {
>> pPoints->GetPoint(i, pt);
>> id = locator->FindClosestPointWithinRadius(cst_dRadius, pt, dDist2);
>> if(-1 != id)
>> {
>> if(sqrt(dDist2) > cst_dRadius)
>> ++bad;
>> ++cpt;
>> }
>> }
>> cout << "should not be tested : " << bad << endl;
>> cout << "number of distances computed : " << cpt << endl;
>>
>> return true;
>> }
>> bool ComputePointDistances(vtkPointLocator *locator, vtkPolyData *in)
>> {
>> int num = in->GetNumberOfPoints();
>> cout << "number of input points : " << num << endl;
>> vtkPoints *pPoints = in->GetPoints();
>> double pt[3];
>> int cpt = 0;
>> double dDist2 = 0;
>>
>> int bad = 0;
>> int id = -1;
>> for(int i=0; i<num; ++i)
>> {
>> pPoints->GetPoint(i, pt);
>> id = locator->FindClosestPointWithinRadius(cst_dRadius, pt, dDist2);
>> if(-1 != id)
>> {
>> if(sqrt(dDist2) > cst_dRadius)
>> ++bad;
>> ++cpt;
>> }
>> }
>> cout << "should not be tested : " << bad << endl;
>> cout << "number of distances computed : " << cpt << endl;
>>
>> return true;
>> }
>>
>> int main(int argc, char* argv[])
>> {
>> /////////////////////////////////////////////////////////
>> MY_SP(vtkRenderer, ren1);
>> ren1->SetBackground(0.2, 0.2, 0.2);
>> MY_SP(vtkRenderWindow, renWin);
>> renWin->SetSize( 512, 512 );
>> renWin->AddRenderer(ren1);
>> MY_SP(vtkRenderWindowInteractor, iren);
>> iren->SetRenderWindow(renWin);
>>
>> /////////////////////////////////////////////////////////
>> MY_SP(vtkCubeSource, src);
>> src->SetBounds(-1,1,-1,1,-1,1);
>> src->Update();
>>
>> MY_SP(vtkCleanPolyData, clean);
>> clean->SetInputConnection(src->GetOutputPort());
>> clean->Update();
>> vtkPolyData *cube = clean->GetOutput();
>>
>> MY_SP(vtkPolyDataMapper, Map);
>> Map->SetInput(cube);
>>
>> MY_SP(vtkActor, act);
>> act->SetMapper(Map);
>> act->GetProperty()->SetInterpolationToFlat();
>> act->GetProperty()->SetColor(1.0, 0.0, 0.0);
>>
>> ren1->AddActor(act);
>>
>>
>> MY_SP(vtkCubeSource, src2);
>> src2->SetBounds(0,2,0,2,0,2);
>> src2->Update();
>>
>> MY_SP(vtkCleanPolyData, clean2);
>> clean2->SetInputConnection(src2->GetOutputPort());
>> clean2->Update();
>> vtkPolyData *cube2 = clean2->GetOutput();
>>
>> MY_SP(vtkPolyDataMapper, Map2);
>> Map2->SetInput(cube2);
>>
>> MY_SP(vtkActor, act2);
>> act2->SetMapper(Map2);
>> act2->GetProperty()->SetInterpolationToFlat();
>> act2->GetProperty()->SetColor(0.0, 1.0, 0.0);
>>
>> ren1->AddActor(act2);
>>
>> /////////////////////////////////////////////////////////
>> MY_SP(vtkPointLocator, locator);
>> locator->SetTolerance(0.0);
>> locator->SetDataSet(cube2);
>> locator->BuildLocator();
>>
>> ComputePointDistances(locator, cube);
>>
>> MY_SP(vtkKdTreePointLocator, locator2);
>> locator2->SetTolerance(0.0);
>> locator2->SetDataSet(cube2);
>> locator2->BuildLocator();
>>
>> ComputePointDistances(locator2, cube);
>>
>> /////////////////////////////////////////////////////////
>> ren1->ResetCamera();
>> renWin->Render();
>> iren->Start();
>>
>> /////////////////////////////////////////////////////////
>> return 0;
>> }
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>> http://www.vtk.org/pipermail/vtkusers/attachments/20100325/597ae2ae/attachment-0001.htm
>> >
>>
>>
>
[Attachment #5 (text/html)]
Thank you Andy to take a look at this.<br>Which class did you modify? is it normal \
that I see no change yet in <a \
href="http://public.kitware.com/cgi-bin/viewcvs.cgi/Filtering/">http://public.kitware.com/cgi-bin/viewcvs.cgi/Filtering/</a> \
?<br> <br><div class="gmail_quote">2010/3/29 Andy Bauer <span dir="ltr"><<a \
href="mailto:andy.bauer@kitware.com">andy.bauer@kitware.com</a>></span><br><blockquote \
class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, \
204, 204); padding-left: 1ex;"> <div class="gmail_quote"><div>Thanks for the bug \
report. I just fixed it and it should go into the new vtk release.<br><br>Andy<br> \
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Message: 1<br>
Date: Thu, 25 Mar 2010 14:44:44 +0100<br>
From: xabi riobe <<a href="mailto:xabivtk@gmail.com" \
target="_blank">xabivtk@gmail.com</a>><br>
Subject: [vtkusers] FindClosestPointWithinRadius issue in vtkKdTree<br>
To: <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>
Message-ID:<br>
<<a href="mailto:b38cd42e1003250644x1a70b70bm65234f02d22ef219@mail.gmail.com" \
target="_blank">b38cd42e1003250644x1a70b70bm65234f02d22ef219@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi,<br>
<br>
I was trying to use vtkKdTreePointLocator to find closest points but from<br>
the results i obtain i'm wondering wheather there is an issue with the<br>
method FindClosestPointWithinRadius, because sometimes it returns some<br>
points with a distance bigger than the radius.<br>
<br>
This method calls vtkKdTree::FindClosestPointWithinRadius which calls<br>
vtkKdTree::FindClosestPointInSphere, but here the point returned can be out<br>
of the sphere.<br>
I think there must be an additional test in one of these two methods to<br>
compare the distance and the given radius.<br>
<br>
here is a program test, with a comparison with vtkPointLocator that works<br>
well.<br>
<br>
PS: i also want to bring back this problem:<br>
<a href="http://old.nabble.com/vtkCellLocator-precision-issue-td27453637.html#a27453637" \
target="_blank">http://old.nabble.com/vtkCellLocator-precision-issue-td27453637.html#a27453637</a><br>
which can maybe solve this one<br>
<a href="http://old.nabble.com/vtkCell::IntersectWithLine-issues-td18225442.html#a18234362" \
target="_blank">http://old.nabble.com/vtkCell::IntersectWithLine-issues-td18225442.html#a18234362</a><br>
<br>
<br>
#include <vtk/vtkActor.h><br>
#include <vtk/vtkCleanPolyData.h><br>
#include <vtk/vtkCubeSource.h><br>
#include <vtk/vtkPolyData.h><br>
#include <vtk/vtkPolyDataMapper.h><br>
#include <vtk/vtkProperty.h><br>
#include <vtk/vtkRenderer.h><br>
#include <vtk/vtkRenderWindow.h><br>
#include <vtk/vtkRenderWindowInteractor.h><br>
#include <vtk/vtkSmartPointer.h><br>
<br>
#define MY_SP(class, variable)\<br>
vtkSmartPointer<class> variable = vtkSmartPointer<class>::New();<br>
<br>
const double cst_dRadius = 1.2;<br>
<br>
#include <vtk/vtkKdTreePointLocator.h><br>
#include <vtk/vtkPointLocator.h><br>
<br>
bool ComputePointDistances(vtkKdTreePointLocator *locator, vtkPolyData *in)<br>
{<br>
int num = in->GetNumberOfPoints();<br>
cout << "number of input points : " << num << \
endl;<br> vtkPoints *pPoints = in->GetPoints();<br>
double pt[3];<br>
int cpt = 0;<br>
double dDist2 = 0;<br>
<br>
int bad = 0;<br>
int id = -1;<br>
for(int i=0; i<num; ++i)<br>
{<br>
pPoints->GetPoint(i, pt);<br>
id = locator->FindClosestPointWithinRadius(cst_dRadius, pt, dDist2);<br>
if(-1 != id)<br>
{<br>
if(sqrt(dDist2) > cst_dRadius)<br>
++bad;<br>
++cpt;<br>
}<br>
}<br>
cout << "should not be tested : " << bad << endl;<br>
cout << "number of distances computed : " << cpt << \
endl;<br> <br>
return true;<br>
}<br>
bool ComputePointDistances(vtkPointLocator *locator, vtkPolyData *in)<br>
{<br>
int num = in->GetNumberOfPoints();<br>
cout << "number of input points : " << num << \
endl;<br> vtkPoints *pPoints = in->GetPoints();<br>
double pt[3];<br>
int cpt = 0;<br>
double dDist2 = 0;<br>
<br>
int bad = 0;<br>
int id = -1;<br>
for(int i=0; i<num; ++i)<br>
{<br>
pPoints->GetPoint(i, pt);<br>
id = locator->FindClosestPointWithinRadius(cst_dRadius, pt, dDist2);<br>
if(-1 != id)<br>
{<br>
if(sqrt(dDist2) > cst_dRadius)<br>
++bad;<br>
++cpt;<br>
}<br>
}<br>
cout << "should not be tested : " << bad << endl;<br>
cout << "number of distances computed : " << cpt << \
endl;<br> <br>
return true;<br>
}<br>
<br>
int main(int argc, char* argv[])<br>
{<br>
/////////////////////////////////////////////////////////<br>
MY_SP(vtkRenderer, ren1);<br>
ren1->SetBackground(0.2, 0.2, 0.2);<br>
MY_SP(vtkRenderWindow, renWin);<br>
renWin->SetSize( 512, 512 );<br>
renWin->AddRenderer(ren1);<br>
MY_SP(vtkRenderWindowInteractor, iren);<br>
iren->SetRenderWindow(renWin);<br>
<br>
/////////////////////////////////////////////////////////<br>
MY_SP(vtkCubeSource, src);<br>
src->SetBounds(-1,1,-1,1,-1,1);<br>
src->Update();<br>
<br>
MY_SP(vtkCleanPolyData, clean);<br>
clean->SetInputConnection(src->GetOutputPort());<br>
clean->Update();<br>
vtkPolyData *cube = clean->GetOutput();<br>
<br>
MY_SP(vtkPolyDataMapper, Map);<br>
Map->SetInput(cube);<br>
<br>
MY_SP(vtkActor, act);<br>
act->SetMapper(Map);<br>
act->GetProperty()->SetInterpolationToFlat();<br>
act->GetProperty()->SetColor(1.0, 0.0, 0.0);<br>
<br>
ren1->AddActor(act);<br>
<br>
<br>
MY_SP(vtkCubeSource, src2);<br>
src2->SetBounds(0,2,0,2,0,2);<br>
src2->Update();<br>
<br>
MY_SP(vtkCleanPolyData, clean2);<br>
clean2->SetInputConnection(src2->GetOutputPort());<br>
clean2->Update();<br>
vtkPolyData *cube2 = clean2->GetOutput();<br>
<br>
MY_SP(vtkPolyDataMapper, Map2);<br>
Map2->SetInput(cube2);<br>
<br>
MY_SP(vtkActor, act2);<br>
act2->SetMapper(Map2);<br>
act2->GetProperty()->SetInterpolationToFlat();<br>
act2->GetProperty()->SetColor(0.0, 1.0, 0.0);<br>
<br>
ren1->AddActor(act2);<br>
<br>
/////////////////////////////////////////////////////////<br>
MY_SP(vtkPointLocator, locator);<br>
locator->SetTolerance(0.0);<br>
locator->SetDataSet(cube2);<br>
locator->BuildLocator();<br>
<br>
ComputePointDistances(locator, cube);<br>
<br>
MY_SP(vtkKdTreePointLocator, locator2);<br>
locator2->SetTolerance(0.0);<br>
locator2->SetDataSet(cube2);<br>
locator2->BuildLocator();<br>
<br>
ComputePointDistances(locator2, cube);<br>
<br>
/////////////////////////////////////////////////////////<br>
ren1->ResetCamera();<br>
renWin->Render();<br>
iren->Start();<br>
<br>
/////////////////////////////////////////////////////////<br>
return 0;<br>
}<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://www.vtk.org/pipermail/vtkusers/attachments/20100325/597ae2ae/attachment-0001.htm" \
target="_blank">http://www.vtk.org/pipermail/vtkusers/attachments/20100325/597ae2ae/attachment-0001.htm</a>><br>
<br>
</blockquote></div><br>
</blockquote></div><br>
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic