<html>
<body>
Hi Ashley,<br><br>
I'm copying this back to the vtkusers list so other people can help too
in solving this problem.<br><br>
- Amy<br><br>
At 09:35 PM 4/26/2006, you wrote:<br>
<blockquote type=cite class=cite cite=""><font size=2>Hi Amy,<br>
</font> <br>
<font size=2>m_Points are the coordinates of the created points.<br>
I'm trying to get the coordinates of the point id 1. <br>
I've tried using id 0, but it doesn't seems to work too. <br>
</font> <br>
<font size=2>Here's my code again.<br>
</font> <br>
<font size=2>//Usual render stuffs<br>
//Create Points <br>
vtkPoints *pts = vtkPoints::New();<br>
pts->InsertPoint (0, 0, 3, 0);<br>
pts->InsertPoint (1, 1, 2, 0);<br>
pts->InsertPoint (2, 0, 2, 1);<br>
pts->InsertPoint (3, -1, 2, 0);<br>
pts->InsertPoint (4, 0, 2, -1);<br>
</font> <br>
<font size=2>//Create Lines to link points<br>
vtkCellArray *lines = vtkCellArray::New();<br>
lines->InsertNextCell (3); <br>
lines->InsertCellPoint (1); <br>
lines->InsertCellPoint (0);<br>
lines->InsertCellPoint (2);<br>
</font> <br>
<font size=2> lines->InsertNextCell (3); <br>
lines->InsertCellPoint (3);<br>
lines->InsertCellPoint (0); <br>
lines->InsertCellPoint (4);<br>
</font> <br>
<font size=2>vtkPolyData *pd = vtkPolyData::New();<br>
pd->SetPoints(pts);<br>
pd->SetLines(lines);<br>
<br>
//Create tubes around the lines<br>
//Create Sphere<br>
vtkSphereSource *sphere = vtkSphereSource::New();<br>
<br>
//Map sphere to every input points<br>
vtkGlyph3D *spheres = vtkGlyph3D::New();<br>
spheres->SetInput(pd);<br>
spheres->SetSource(sphere->GetOutput());<br><br>
vtkPolyDataMapper *sphereMapper= vtkPolyDataMapper::New();<br>
sphereMapper->SetInputConnection(spheres->GetOutputPort());<br><br>
vtkActor *sphereActor = vtkActor::New();<br>
sphereActor->SetMapper(sphereMapper);<br>
<br>
//Create text as marker when pick<br>
//Create camera<br>
//Add spheresActors, edgeActors (the tubes) and textActors (text
markers)<br>
<br>
//Create callback command<br>
PropCaller *caller = PropCaller::New();<br>
caller->SetRenderer (ren);<br>
caller->SetSelectionActor (textActor[0]); //set it to the first text
only<br>
caller->SetPoints (pts); //passing in the pointer pts so that i can
get the coordinates in my subclass PropCaller for comparison<br><br>
renWin->Render();<br>
iren->AddObserver (vtkCommand::CharEvent, caller);<br>
iren->Start();<br>
<br>
///// In my PropCaller class //////<br>
class PropCaller : public vtkCommand {<br>
public:<br>
static PropCaller *New() {return new
PropCaller;}<br>
void SetSelectionActor(vtkActor*
marker){m_Marker = marker;}<br>
void SetRenderer (vtkRenderer
*myRenderer);<br>
virtual vtkRenderer
*MakeRenderer();<br>
vtkRenderer *GetRenderer ();<br>
void SetPoint(vtkPoints* pts) {<br>
m_Points = pts;<br>
}<br>
virtual void Execute (vtkObject
*caller, unsigned long, void*) {<br>
int x,y;<br>
vtkRenderWindowInteractor *iren =
reinterpret_cast<vtkRenderWindowInteractor*>(caller);<br>
iren->GetEventPosition(x, y);<br>
vtkPropPicker *picker = vtkPropPicker::New();<br>
picker->Pick(x,y,0,this->renderer);<br>
vtkActor *pickedActor = picker->GetActor();<br>
if (picker->GetPickPosition() == m_Points->GetPoint(1)) {<br>
if (m_Marker) {<br>
m_Mark->VisibilityOn();<br>
m_Mark->SetPosition(picker->GetPickPosition());<br>
iren->Render();<br>
}<br>
}<br>
}<br>
protected:<br>
PropCaller();<br>
~PropCaller();<br>
vtkRenderer *renderer;<br>
vtkActor *m_Marker;<br>
vtkActor *m_Actor;<br>
vtkPoints *m_Points;<br>
};<br><br>
<hr>
</font><font face="Tahoma" size=2><b>From:</b> Amy Squillacote<br>
<b>Sent:</b> Wed 26-Apr-06 8:16 PM<br>
<b>To:</b> Ashley Sher; vtkusers@vtk.org<br>
<b>Subject:</b> Re: [vtkusers] Problem with vtkPoint::GetPoint(vtk
IdType)<br>
</font><br><br>
<pre>Hi Ashley,
What is m_Points supposed to contain? You didn't include the code
showing where the values in this instance of vtkPoints comes
from. Also, what are you getting back from your call to
GetPoint? I
see that you're calling GetPoint(1); remember that VTK numbers from
0, so if you're trying to compare against the first point in
m_Points, you should call GetPoint(0).
- Amy
At 05:46 AM 4/26/2006, Ashley Sher wrote:
>Hi all,
>
>I tried to use GetPoint to retreive the coordinates of defined
point,
>however, it's not working. It is not returning the actual point
coordinate.
>
>Anyone met with this problem before?
>
>vtkPoints *pts = vtkPoints::New();
>pts->InsertPoint (0, 0, 3, 0);
>pts->InsertPoint (1, 1, 2, 0);
>pts->InsertPoint (2, 0, 2, 1);
>pts->InsertPoint (3, -1, 2, 0);
>pts->InsertPoint (4, 0, 2, -1);
>
>vtkPolyData *pd = vtkPolyData::New();
>pd->SetPoints(pts);
>
>vtkSphereSource *sphere = vtkSphereSource::New();
>vtkGlyph3D *spheres = vtkGlyph3D::New();
>spheres->SetInput(pd);
>spheres->SetSource(sphere->GetOutput());
>vtkPolyDataMapper *sphereMapper= vtkPolyDataMapper::New();
>sphereMapper->SetInputConnection(spheres->GetOutputPort());
>vtkActor *sphereActor = vtkActor::New();
>sphereActor->SetMapper(sphereMapper);
>
>iren->GetEventPosition(x, y);
>vtkPropPicker *picker = vtkPropPicker::New();
>picker->Pick(x,y,0,this->renderer);
>vtkActor *pickedActor = picker->GetActor();
>
>if (picker->GetPickPosition() == m_Points->GetPoint(1)) {
>
:
>
:
>}
>--
>View this message in context:
><a href="http://www.nabble.com/Problem-with-vtkPoint::GetPoint(vtk-IdType)-t1510830.html#a4098328" eudora="autourl">
http://www.nabble.com/Problem-with-vtkPoint%3A%3AGetPoint%28vtk-IdType%29-t1510830.html#a4098328</a>
>Sent from the VTK - Users forum at Nabble.com.
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at:
><a href="http://www.vtk.org/Wiki/VTK_FAQ" eudora="autourl">
http://www.vtk.org/Wiki/VTK_FAQ</a>
>Follow this link to subscribe/unsubscribe:
><a href="http://www.vtk.org/mailman/listinfo/vtkusers" eudora="autourl">
http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre><font face="Courier New, Courier"></font></blockquote></body>
</html>