[vtkusers] 3d SphereSource Picking and Get the Point ID
Giuseppe Marco Randazzo
gmrandazzo at gmail.com
Fri Jan 25 11:18:25 EST 2013
ok... solved....
according to the equation in R3 the surface of a sphere with center
"(x0,y0,z0)" and radius "r" is represented by a set of points "(x,y,z)"
such that:
(x-x0)^2 + (y-y0)^2 + (z-z0)^2 = r^2
So from the example
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/PointPicker
you can get the coordinate of the point x,y,z that is part of the sphere
and by appying this formula with the origin of points that are stored in
your vtkPoint you can get the origini sphere ID.
Here an example of code...
double a = square(points->GetPoint(i)[0] - style->getPicked()[0]) +
square(p.points()->GetPoint(i)[1] - style->getPicked()[1]) +
square(p.points()->GetPoint(i)[2] - style->getPicked()[2]);
double rsquared = square(sphereSource->GetRadius());
if a ~= rsquared then
ORIGIN ID GOT!!!!!
Thanks.
Marco
On 01/25/2013 04:40 PM, Giuseppe Marco Randazzo wrote:
> Hello,
>
> I need to get the point id by picking a multiple spehere source 3D plot..
>
>
> For example i've 400 vtkPoints rendered by the Glyph3D with
> SphereSource....
>
> so:
>
>
> polydata->SetPoints(vtkpoints)
>
> sphereSource->SetRadius(radiusssss);
> glyph3D()->SetSourceConnection(sphereSource->GetOutputPort());
> glyph3D()->SetInput(polydata);
> glyph3D()->Update();
>
> So also i got from the wiki these examples:
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/PointPicker
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/WorldPointPicker
>
> that get me the poin coordinate... but in the world picker is specified:
>
> "This example demonstrates how to get the position of the point in 3D
> that is exactly behind the mouse click. This point is not likely a
> point that exists in the data set - i.e. it can be a point on the
> interior of a cell. "
>
> So my question is how can i get the point in the data set that was
> picked?
>
> Also i seen this example:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MoveAVertex
>
> and tried to use PointPicker->GetPointId()
>
> But i do not get the point id that correspond to the id in the
> vtkpoint table.... i get the point id that is one of the selected
> spheresource.
>
> How is possible so get the real point id?
>
> Thanks.
>
> Marco
More information about the vtkusers
mailing list