[vtkusers] ContourWidget continuously problem
Dora Szasz
dora.szasz at yahoo.com
Fri Aug 31 08:25:25 EDT 2012
Hello all,
I think ContourWidget doesn't like me at all.
Now I am trying to put a default circle as contour widget over a DICOM Image and it doesn't appear.
Do you have any idea?
Thanks,
Dora
Here is the code:
#include "vtkImageViewer2.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkContourWidget.h"
#include "vtkContourLineInterpolator.h"
#include "vtkOrientedGlyphContourRepresentation.h"
#include "vtkDICOMImageReader.h"
#include "vtkProperty.h"
#include "vtkPolyData.h"
#include "vtkSmartPointer.h"
#include "vtkMath.h"
#include "vtkCellArray.h"
int main()
{
//Setting up Viewer
vtkImageViewer2* viewer = vtkImageViewer2::New();
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
viewer->SetupInteractor(iren);
//Load DICOM Image into Viewer
vtkDICOMImageReader* reader = vtkDICOMImageReader::New();
reader->SetDirectoryName("F:/Neurostar/Imaging Data/MRSet");
reader->Update();
viewer->SetInput(reader->GetOutput());
viewer->SetSlice(40);
//Draw the Circle
vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
vtkIdType* lineIndices = new vtkIdType[21];
for (int i = 0; i< 20; i++)
{
const double angle = 2.0*vtkMath::Pi()*i/20.0;
points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle),0.1*sin(angle), 0.0 );
lineIndices[i] = static_cast<vtkIdType>(i);
}
lineIndices[20] = 0;
lines->InsertNextCell(21,lineIndices);
delete [] lineIndices;
pd->SetPoints(points);
pd->SetLines(lines);
//Setting up Contour Widget
vtkContourWidget* widget = vtkContourWidget::New();
vtkOrientedGlyphContourRepresentation* rep = vtkOrientedGlyphContourRepresentation::New();
rep->GetLinesProperty()->SetColor(1, 0, 0);
widget->SetRepresentation(rep);
widget->SetCurrentRenderer(viewer->GetRenderer());
widget->SetInteractor(iren);
widget->On();
widget->SetEnabled(true);
widget->ProcessEventsOn();
//Start Interaction
widget->Initialize(pd);
widget->Render();
//viewer->Render();
iren->Initialize();
iren->Start();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120831/d061a461/attachment.htm>
More information about the vtkusers
mailing list