[vtkusers] vtkContourWidget question

Karthik Krishnan karthik.krishnan at kitware.com
Mon Oct 26 13:04:30 EDT 2009


Please post a minimal compiling example demonstrating issue (1). The
following code minimal example should demonstrate a contour widget
used in conjunction with an IMageActorPointPlacer and does not exhibit
the issues you've described.

The line interpolators etc should be invoked only when you interact
with the contour widget, and this will happen only when your mouse
cursor is in the vicinity of the contour widget. Are you saying that
they are invoked even when you don't interact with the widget.

You may choose to explicitly disable event processing to fix (2) by calling

  contourWidget->ProcessEventsOff();

The interpolators should definitely not be invoked in this case.

#include "vtkPNGReader.h"
#include "vtkImageActor.h"
#include "vtkImageData.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkContourWidget.h"
#include "vtkOrientedGlyphContourRepresentation.h"
#include "vtkImageActorPointPlacer.h"

int main(int argc, char*argv[])
{
  // Create the RenderWindow, Renderer and both Actors
  //
  vtkRenderer *ren1 = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->AddRenderer(ren1);

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

  // Read two images of different modalities. T1 MRI and PD MRI.
  vtkPNGReader *t1MRIReader = vtkPNGReader::New();
  t1MRIReader->SetFileName("BrainProtonDensitySlice.png");
  t1MRIReader->Update();

  vtkImageActor *actor = vtkImageActor::New();
  actor->SetInput(t1MRIReader->GetOutput());
  actor->SetDisplayExtent( 0, 180, 0, 216, 0, 0 );

  // Add the actors to the renderer
  ren1->AddActor(actor);

  // Here comes the image actor constrained handle widget stuff.....

  vtkContourWidget *widget = vtkContourWidget::New();
  widget->SetInteractor(iren);
  vtkOrientedGlyphContourRepresentation *rep =
      vtkOrientedGlyphContourRepresentation::SafeDownCast(
                        widget->GetRepresentation());
  rep->GetLinesProperty()->SetColor(1, 0.2, 0);
  rep->GetLinesProperty()->SetLineWidth(3.0);

  //    Define the PointPlacer as the one that converts 2D display positions to
  //    to those that lie on the image
  vtkImageActorPointPlacer * pointPlacer = vtkImageActorPointPlacer::New();
  pointPlacer->SetImageActor( actor );
  rep->SetPointPlacer(pointPlacer);

  renWin->Render();
  iren->Initialize();
  widget->EnabledOn();

  iren->Start();

  // Cleanups
  widget->Delete();
  t1MRIReader->Delete();
  actor->Delete();
  iren->Delete();
  renWin->Delete();
  ren1->Delete();
  pointPlacer->Delete();

  return 0;
}

On Mon, Oct 26, 2009 at 12:34 PM,  <itkvtk123 at gmx.net> wrote:
> Hey
>
> I have two questions concerning the vtkContourWidget.
>
> 1.
> While drawing the points, how do I make the contour to stick onto the image?
> I'm using ImageActorPointPlacer already, but the Nodes seem to be drawn at display coordinates and not at world coordinates.
> (When zooming out, the image gets smaller, but the contour stays at the same size)
>
> 2.
> Once my contour is drawn and I change the intensity window of vtkImageViewer2, all line interpolators of the vtkContourWidget are called.
> Since my interpolation requires a lot of CPU power, I don't want this behaviour. Once the contour is drawn, it should stay as it is, i.e. any interaction with the render window should not alter the contour shape once the contour is completed (closed loop).
>
> Thank you for your answers
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> 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
>



-- 
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: 518 881 4919
Fax: 518 371 4573



More information about the vtkusers mailing list