[vtkusers] vtkMarchingSquares to vtkContourWidget
Nicolas Rannou
nicolas_rannou at hms.harvard.edu
Wed May 5 18:26:24 EDT 2010
Hello,
I'm trying to extract contours using marching squares then to use this
contour to initialize a vtkContourWidget.
But I couldn't get good results yet.
What I do:
/***************************************************************************/
vtkMarchingSquares* contours = vtkMarchingSquares::New();
contours->SetInput( image );
contours->GenerateValues ( 1, 0, 0 );
vtkStripper * stripper = vtkStripper::New();
stripper->SetInput( contours->GetOutput() );
stripper->Update();
vtkPolyData* testPolyD = vtkPolyData::New();
testPolyD->SetPoints( stripper->GetOutput()->GetPoints() );
vtkTransform *t = vtkTransform::New();
t->Translate( seed_pos[0], seed_pos[1], seed_pos[2] );
vtkTransformPolyDataFilter *tf = vtkTransformPolyDataFilter::New();
tf->SetTransform( t );
tf->SetInput( testPolyD );
tf->Update();
vtkOrientedGlyphContourRepresentation* contourRep =
vtkOrientedGlyphContourRepresentation::New();
vtkContourWidget* contourWidget = vtkContourWidget::New();
contourWidget->SetInteractor(this->m_ImageView->GetImageViewer(0)->GetInteractor());
contourWidget->SetRepresentation(contourRep);
contourWidget->On();
contourWidget->Initialize(iView);
vtkPolyData* contour = contourRep->GetContourRepresentationAsPolyData();
/***************************************************************************/
then, if I plot this polydata, I get something like in the enclosed png
in blue.
I roughly added in green the nodes I get while using the vtkContourWidget.
The nodes are in the good position but the data hasn't the good "shape".
I also roughly draw in red the polydata I would like to have in my
vtkContourWidget.
The expected shape would be the same as the one I get just after
applying the marching squares but I can't use directly the output of the
marching square filter since it contains no point and no usable line.
I must be missing something but what...
Thanks,
Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MSquares_CWidget.png
Type: image/png
Size: 114017 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100505/adb2775e/attachment.png>
More information about the vtkusers
mailing list