seedNumber should range in value from 0 to GetNumberOfSeeds()-1 -- the reason you are getting the error is that you are using GetNumberOfSeeds() as the value...<br><br><br>HTH,<br>David<br><br><br><div class="gmail_quote">
On Tue, Jun 24, 2008 at 11:02 PM, Ken Urish <<a href="mailto:ken.urish@gmail.com">ken.urish@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Ive been struggling with vtkSeedWidget and I would apprecaite if<br>
anyone can point me in the right direction. Any example code on how to<br>
get seed position off 2d image would be just as good.<br>
<br>
I can easily place seeds on a 2d image using vtkSeedWidget. I am<br>
having difficulty getting their location. I setup a callback that<br>
monitors mouse position and pointPlaceEvents. It correctly tells me<br>
how many seeds I have.<br>
I am trying to then have it give me the seed location by calling:<br>
this->SeedRepresentation->GetSeedDisplayPosition (seedNumber, point);<br>
<br>
I get the error message: vtkSeedRepresentation (029B6D28): Trying to<br>
access non-existent handle. I am stuck. I put the call back below for<br>
any help.<br>
<br>
Thanks<br>
--Ken--<br>
<br>
<br>
<br>
// This callback is responsible for setting the seed label.<br>
class vtkSeedCallback : public vtkCommand<br>
{<br>
public:<br>
static vtkSeedCallback *New()<br>
{ return new vtkSeedCallback; }<br>
virtual void Execute(vtkObject*, unsigned long eid, void*)<br>
{<br>
if ( eid == vtkCommand::CursorChangedEvent )<br>
cout << "cursor changed\n";<br>
else<br>
{<br>
int seedNumber;<br>
double point[3];<br>
double ptMapped[3];<br>
<br>
cout << "point placed\n";<br>
cout << "Total number of seeds: "<br>
<< this->SeedRepresentation->GetNumberOfSeeds () << "\n";<br>
seedNumber = this->SeedRepresentation->GetNumberOfSeeds ();<br>
this->SeedRepresentation->GetSeedDisplayPosition<br>
(seedNumber, point);<br>
}<br>
<br>
}<br>
vtkSeedCallback() : SeedRepresentation(0) {}<br>
vtkSeedRepresentation *SeedRepresentation;<br>
};<br>
<br>
<br>
<br>
//Below is the setup in main program for the callback<br>
<br>
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
iren->SetRenderWindow(renWin);<br>
renWin->Render();<br>
<br>
// Say hello to my big widget<br>
// Create the widget and its representation<br>
vtkPointHandleRepresentation2D *handle =<br>
vtkPointHandleRepresentation2D::New();<br>
handle->GetProperty()->SetColor(1,0,0);<br>
vtkSeedRepresentation *rep = vtkSeedRepresentation::New();<br>
rep->SetHandleRepresentation(handle);<br>
<br>
vtkSeedWidget *widget = vtkSeedWidget::New();<br>
widget->SetInteractor(iren);<br>
widget->SetRepresentation(rep);<br>
<br>
vtkSeedCallback *mcbk = vtkSeedCallback::New();<br>
mcbk->SeedRepresentation = rep;<br>
widget->AddObserver(vtkCommand::PlacePointEvent,mcbk);<br>
widget->AddObserver(vtkCommand::CursorChangedEvent,mcbk);<br>
<br>
// render the image<br>
iren->Initialize();<br>
renWin->Render();<br>
widget->On();<br>
iren->Start();<br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br>