[vtkusers] vtkSeedWidget GetSeedDisplayPosition Question

David Cole david.cole at kitware.com
Wed Jun 25 06:48:36 EDT 2008


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...


HTH,
David


On Tue, Jun 24, 2008 at 11:02 PM, Ken Urish <ken.urish at gmail.com> wrote:

> Ive been struggling with vtkSeedWidget and I would apprecaite if
> anyone can point me in the right direction. Any example code on how to
> get seed position off 2d image would be just as good.
>
> I can easily place seeds on a 2d image using vtkSeedWidget. I am
> having difficulty getting their location. I setup a callback that
> monitors mouse position and pointPlaceEvents. It correctly tells me
> how many seeds I have.
> I am trying to then have it give me the seed location by calling:
> this->SeedRepresentation->GetSeedDisplayPosition (seedNumber, point);
>
> I get the error message: vtkSeedRepresentation (029B6D28): Trying to
> access non-existent handle. I am stuck. I put the call back below for
> any help.
>
> Thanks
> --Ken--
>
>
>
> // This callback is responsible for setting the seed label.
> class vtkSeedCallback : public vtkCommand
> {
> public:
>  static vtkSeedCallback *New()
>    { return new vtkSeedCallback; }
>  virtual void Execute(vtkObject*, unsigned long eid, void*)
>    {
>      if ( eid == vtkCommand::CursorChangedEvent )
>        cout << "cursor changed\n";
>      else
>        {
>                int seedNumber;
>                  double point[3];
>                  double ptMapped[3];
>
>        cout << "point placed\n";
>                cout << "Total number of seeds: "
>                         << this->SeedRepresentation->GetNumberOfSeeds () <<
> "\n";
>                seedNumber = this->SeedRepresentation->GetNumberOfSeeds ();
>                this->SeedRepresentation->GetSeedDisplayPosition
> (seedNumber, point);
>                }
>
>    }
>        vtkSeedCallback() : SeedRepresentation(0) {}
>        vtkSeedRepresentation *SeedRepresentation;
> };
>
>
>
> //Below is the setup in main program for the callback
>
>  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>  iren->SetRenderWindow(renWin);
>  renWin->Render();
>
>  // Say hello to my big widget
>  // Create the widget and its representation
>  vtkPointHandleRepresentation2D *handle =
> vtkPointHandleRepresentation2D::New();
>  handle->GetProperty()->SetColor(1,0,0);
>  vtkSeedRepresentation *rep = vtkSeedRepresentation::New();
>  rep->SetHandleRepresentation(handle);
>
>  vtkSeedWidget *widget = vtkSeedWidget::New();
>  widget->SetInteractor(iren);
>  widget->SetRepresentation(rep);
>
>  vtkSeedCallback *mcbk = vtkSeedCallback::New();
>  mcbk->SeedRepresentation = rep;
>  widget->AddObserver(vtkCommand::PlacePointEvent,mcbk);
>  widget->AddObserver(vtkCommand::CursorChangedEvent,mcbk);
>
>  // render the image
>  iren->Initialize();
>  renWin->Render();
>  widget->On();
>  iren->Start();
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080625/4a180ed8/attachment.htm>


More information about the vtkusers mailing list