[vtkusers] Programmatically adding and removing seeds from vtkSeedWidget
J.S.Wijnhout at lumc.nl
J.S.Wijnhout at lumc.nl
Wed Apr 29 03:21:23 EDT 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090429/a81997bc/attachment.htm>
More information about the vtkusers
mailing list