[vtkusers] Find point by coordiante
Boehm, Lukas
Lukas.Boehm at cellent.de
Tue Aug 21 12:07:53 EDT 2012
Thank you very much! This example solved my problem :-)
My vtkImageData is only for 2D and z-value for spacing was set to 0. I set it to 1 and now it works.
Good bye,
Lukas
From: Gonzalo Amadio [mailto:gonzaloamadio at gmail.com]
Sent: Dienstag, 21. August 2012 17:48
To: Boehm, Lukas
Cc: Kevin H. Hobbs; vtkusers at vtk.org
Subject: Re: [vtkusers] Find point by coordiante
Here do you have an example. Where findPoint is used either in an image and in a polydata.
#include <vtkVersion.h>
#include <vtkSmartPointer.h>
#include <vtkPolyData.h>
#include <vtkTriangleFilter.h>
#include <vtkIdTypeArray.h>
#include <vtkImageDataGeometryFilter.h>
#include <vtkImageData.h>
int main(int, char *[])
{
//Create an image data
vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New();
imageData->SetDimensions(5,5,1);
imageData->SetSpacing(1.0, 1.0, 1.0);
imageData->SetOrigin(0.0, 0.0, 0.0);
//Convert the image to a polydata
vtkSmartPointer<vtkImageDataGeometryFilter> imageDataGeometryFilter = vtkSmartPointer<vtkImageDataGeometryFilter>::New();
imageDataGeometryFilter->SetInputConnection(imageData->GetProducerPort());
imageDataGeometryFilter->Update();
vtkSmartPointer<vtkTriangleFilter> triangleFilter = vtkSmartPointer<vtkTriangleFilter>::New();
triangleFilter->SetInputConnection(imageDataGeometryFilter->GetOutputPort());
triangleFilter->Update();
vtkSmartPointer<vtkPolyData> triang = triangleFilter->GetOutput();//polydata normal, cells
triang->BuildLinks();
triang->BuildCells();
vtkIdType id = triang->FindPoint(0,0,0);
std::cout << id << std::endl;
vtkIdType id2 = imageData->FindPoint(0,0,0);
std::cout << id2 << std::endl;
return EXIT_SUCCESS;
}
2012/8/21 Boehm, Lukas <Lukas.Boehm at cellent.de>
Thank you both for your answers!
FindPoint works perfect with vtkPolyData, but now I think I can't use vtkPolyData. Instead I probably have to use vtkImageData.
My VTK pipeline looks like this:
1.) Create vtkImageData with all points
2.) Use vtkMarchingSquares filter to get vtkPolyData representing some iso lines
3.) Some unimportant clipping stuff...
If I use the vtkPolyData object from vtkMarchingSquares I get values which make sense. But it seems like marching squares removes all points where no iso lines are drawn. I only find ids of points which are on the iso lines.
So my idea was to use vtkImageData. But not even the simpliest example works with vtkImageData and FindPoint:
double[] pos = imageData.GetPoint(200);
// pos contains 18.0, -29.0, 0.0 which seems to be correct
int id = imageData.FindPoint(pos[0], pos[1], pos[2]);
I would expect 'id' to have the value 200. But it always has the value -1. The documentation says that a return value < 0 means that the point can't be found (maybe it's outside of the vtkImageData object). Could somebody please tell me why FindPoint always returns -1?
Thank you,
Lukas
From: Gonzalo Amadio [mailto:gonzaloamadio at gmail.com]
Sent: Dienstag, 21. August 2012 15:48
To: Kevin H. Hobbs
Cc: Boehm, Lukas; vtkusers at vtk.org
Subject: Re: [vtkusers] Find point by coordiante
I think this will work!..
http://www.vtk.org/doc/release/5.6/html/a00430.html#fb20db494bf2e8c0aff4ff2fcf7d6a22
The doc says "find the closes point to the coordinates provided as arguiment"
2012/8/21 Kevin H. Hobbs <hobbsk at ohio.edu>
On 08/21/2012 09:18 AM, Boehm, Lukas wrote:
> Hello,
>
>
>
> I've got a short question. I have a vtkPoints object and a coordinate
> (x,y,z). Is there a way to get the id of the closest point to this
> coordinate? I didn't find anything.
>
You need a point locator.
http://www.vtk.org/doc/nightly/html/classvtkPointLocator.html
_______________________________________________
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
--
--------
Gonzalo Amadio
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cellent Aktiengesellschaft
Vorsitzender des Aufsichtsrates: Dr. Martin Setzer
Vertretungsberechtigter Vorstand: Andreas Schwegler
Gerichtsstand: Amtsgericht Stuttgart, HRB 22791
Umsatzsteuer-ID: DE 226611517
Firmensitz: Stuttgart
Diese EMail sowie etwaige Anlagen sind ausschliesslich fuer den Adressaten bestimmt und koennen vertrauliche oder gesetzlich
geschuetzte Informationen enthalten. Wenn Sie nicht der bestimmungsgemaesse Empfaenger sind, unterrichten Sie bitte den Absender
und vernichten Sie diese Mail. Anderen als dem bestimmungsgemaessen Adressaten ist es untersagt, diese EMail zu speichern,
weiterzuleiten oder ihren Inhalt, auf welche Weise auch immer, zu verwenden. Wir verwenden aktuelle Virenschutzprogramme.
Fuer Schäden, die dem Empfaenger gleichwohl durch von uns zugesandte, mit Viren befallene EMails entstehen, schliessen wir jede Haftung aus.
The information contained in this e-mail or attachments is intended only for its addressee and may contain confidential and/or
privileged information. If you have received this e-mail in error, please notify the sender and delete the e-mail. If you are not the
intended recipient, you are hereby notified, that saving, distribution or use of the content of this e-mail in any way is prohibited.
We use updated virus protection software. We do not accept any responsibility for damages caused anyhow by viruses transmitted via e-mail.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
--
--------
Gonzalo Amadio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120821/d134bcf5/attachment.htm>
More information about the vtkusers
mailing list