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 &lt;<a href="mailto:ken.urish@gmail.com">ken.urish@gmail.com</a>&gt; 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-&gt;SeedRepresentation-&gt;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>
 &nbsp;static vtkSeedCallback *New()<br>
 &nbsp; &nbsp;{ return new vtkSeedCallback; }<br>
 &nbsp;virtual void Execute(vtkObject*, unsigned long eid, void*)<br>
 &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp;if ( eid == vtkCommand::CursorChangedEvent )<br>
 &nbsp; &nbsp; &nbsp; &nbsp;cout &lt;&lt; &quot;cursor changed\n&quot;;<br>
 &nbsp; &nbsp; &nbsp;else<br>
 &nbsp; &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int seedNumber;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;double point[3];<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;double ptMapped[3];<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;cout &lt;&lt; &quot;point placed\n&quot;;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cout &lt;&lt; &quot;Total number of seeds: &quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt; this-&gt;SeedRepresentation-&gt;GetNumberOfSeeds () &lt;&lt; &quot;\n&quot;;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;seedNumber = this-&gt;SeedRepresentation-&gt;GetNumberOfSeeds ();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&gt;SeedRepresentation-&gt;GetSeedDisplayPosition<br>
(seedNumber, point);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp;}<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkSeedCallback() : SeedRepresentation(0) {}<br>
 &nbsp; &nbsp; &nbsp; &nbsp;vtkSeedRepresentation *SeedRepresentation;<br>
};<br>
<br>
<br>
<br>
//Below is the setup in main program for the callback<br>
<br>
 &nbsp;vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
 &nbsp;iren-&gt;SetRenderWindow(renWin);<br>
 &nbsp;renWin-&gt;Render();<br>
<br>
 &nbsp;// Say hello to my big widget<br>
 &nbsp;// Create the widget and its representation<br>
 &nbsp;vtkPointHandleRepresentation2D *handle =<br>
vtkPointHandleRepresentation2D::New();<br>
 &nbsp;handle-&gt;GetProperty()-&gt;SetColor(1,0,0);<br>
 &nbsp;vtkSeedRepresentation *rep = vtkSeedRepresentation::New();<br>
 &nbsp;rep-&gt;SetHandleRepresentation(handle);<br>
<br>
 &nbsp;vtkSeedWidget *widget = vtkSeedWidget::New();<br>
 &nbsp;widget-&gt;SetInteractor(iren);<br>
 &nbsp;widget-&gt;SetRepresentation(rep);<br>
<br>
 &nbsp;vtkSeedCallback *mcbk = vtkSeedCallback::New();<br>
 &nbsp;mcbk-&gt;SeedRepresentation = rep;<br>
 &nbsp;widget-&gt;AddObserver(vtkCommand::PlacePointEvent,mcbk);<br>
 &nbsp;widget-&gt;AddObserver(vtkCommand::CursorChangedEvent,mcbk);<br>
<br>
 &nbsp;// render the image<br>
 &nbsp;iren-&gt;Initialize();<br>
 &nbsp;renWin-&gt;Render();<br>
 &nbsp;widget-&gt;On();<br>
 &nbsp;iren-&gt;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>