[vtkusers] Programmatically adding and removing seeds from vtkSeedWidget

Mauro Maiorca mauromaiorca at gmail.com
Tue Feb 8 10:32:28 EST 2011


Hi Jeroen,

Sorry for the (quite) late reply, you might have already figured out
the solution by now. I'm replying just in case somebody else needs
this (I've got the same problem 3 hours and 3 coffees ago :D ), here
the solution:

     m_seedWidget->CompleteInteraction();

     // Remove current seeds:
     int numSeeds = m_seedRep->GetNumberOfSeeds ();
     for ( int i = 0; i < numSeeds; ++i )
     {
         m_seedRep->RemoveLastHandle();
         m_seedWidget->DeleteSeed (m_seedRep->GetNumberOfSeeds ());
// <---- NOTE!
     }


apparently DeleteSeed doesn't affect GetNumberOfSeeds, and
RemoveLastHandle doesn't affect vtkSeedList *Seeds; in
vtkSeedWidget.h!
By combining RemoveLastHandle and DeleteSeed it works perfectly!!
I hope this will reduce the daily caffeine intake in some other random
VTK users wondering in the list archive :-)

cheers,
Mauro


On Wed, Apr 29, 2009 at 5:21 PM,  <J.S.Wijnhout at lumc.nl> wrote:
> Hi all,
>
> This sounds like a dumb question, but I can't seem to figure it out myself.
> I'm using vtkSeedWidget to allow the user to set an arbitrary number of
> seeds. However I want to be able to, programmatically, delete all the seeds.
> Also, I need to programmatically add seeds to the vtkSeedWidget (for
> example, seeds read from a file). Can this be done using vtkSeedWidget? I
> have played with vtkSeedRepresentation, which has methods to remove and add
> handles. However the following approach leaves with an inconsistent state
> (It is a bit hard to describe, but seeds and handles to not seem to be
> synchronised well. New seeds often end up in the origin of my image.):
>
>     m_seedWidget->CompleteInteraction();
>
>     // Remove current seeds:
>     int numSeeds = m_seedRep->GetNumberOfSeeds ();
>     for ( int i = 0; i < numSeeds; ++i )
>     {
>         m_seedRep->RemoveLastHandle();
>     }
>
>     m_seedRep->BuildRepresentation();
>
>     // Add seeds from polydata:
>     vtkPolyData *seedPd = m_activeSlice->GetSeedPolyData(m_activeContour);
>     vtkPoints *seeds = seedPd->GetPoints();
>
>     if ( 0 != seeds )
>     {
>         numSeeds = seeds->GetNumberOfPoints();
>         for ( int i = 0; i < numSeeds; ++i )
>         {
>             double p[3];
>             seeds->GetPoint(i,p);
>             int s = m_seedRep->CreateHandle(p);
>             m_seedRep->SetSeedDisplayPosition(s,p);
>         }
>     }
>
>     m_seedRep->BuildRepresentation();
>     m_seedWidget->RestartInteraction();
>     m_seedWidget->Render();
>
> best,
> Jeroen
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list