[vtkusers] show celldata on vtkImagePlaneWidget

Putte, T.B. (Tom) van der tom.vanderputte at tno.nl
Thu Jun 9 09:02:18 EDT 2011


Dean,

It works great, and I found that this way it is also possible to use the implicitplanewidget data on 3D image (vti file) CELL data, instead of structuredGrid, without having to interpolate scalar cell data to points.

However, when I go back to my original problem with this solution, namely to use an imagePlaneWidget, I get the error: 

"Attempt to connect input port index 0 for an algorithm with 0 input ports."

This is what I have:
//*******************************************

vtkXMLImageDataReader reader = vtkXMLImageDataReader.New();
reader.SetFileName(fileName);
reader.SetCellArrayStatus("CellData_GEOTOP", 1); //TURN ON CELL SCALARS
reader.SetPointArrayStatus("Scalars_", 0); //TURN OF POINT SCALARS
reader.Update();

vtkImagePlaneWidget iPlaneWidget = new vtkImagePlaneWidget();
iPlaneWidget.SetResliceInterpolateToNearestNeighbour();
iPlaneWidget.TextureInterpolateOff();
iPlaneWidget.SetInput(reader.GetOutput());            
iPlaneWidget.SetSliceIndex(0);
iPlaneWidget.SetPicker(picker);
iPlaneWidget.UserControlledLookupTableOn();
iPlaneWidget.SetLookupTable(lut);

// Then Dean's suggestions:

iPlaneWidget.GetPolyDataAlgorithm().SetInput(reader.GetOutput()); <--- ERROR
iPlaneWidgetX.SetInteractor(interActor);
iPlaneWidgetX.On();
                ren1.GetActors().GetLastActor().GetMapper().SetUseLookupTableScalarRange(1);                ren1.GetActors().GetLastActor().GetMapper().SetScalarModeToUseCellData();                ren1.GetActors().GetLastActor().GetMapper().SetColorModeToMapScalars();                ren1.GetActors().GetLastActor().GetMapper().InterpolateScalarsBeforeMappingOff();                ren1.GetActors().GetLastActor().GetMapper().SetLookupTable(lut2);
vtkPolyDataMapper mapper3 = vtkPolyDataMapper.New();
mapper3.SetInputConnection(iPlaneWidgetX.GetPolyDataAlgorithm().GetOutputPort());

mapper3.SetUseLookupTableScalarRange(1);
mapper3.SetScalarModeToUseCellData();
mapper3.SetColorModeToMapScalars();
mapper3.InterpolateScalarsBeforeMappingOff();
mapper3.SetLookupTable(lut);

vtkActor actor3 = new vtkActor();
actor3.SetMapper(mapper3);
ren1.AddActor(actor3);

//*******************************************

The line:
iPlaneWidget.GetPolyDataAlgorithm().SetInput(reader.GetOutput());
throws the error. Is this something to be expected?

Tom

________________________________________
Van: Dean Inglis [dean.inglis at camris.ca]
Verzonden: vrijdag 27 mei 2011 21:42
Aan: Putte, T.B. (Tom) van der; vtkusers at vtk.org
Onderwerp: Re: [vtkusers] show celldata on vtkImagePlaneWidget

Tom,

try the attached tcl script.  You may have to turn off drawing
the implicit widget's plane and replace it with your own actor.

Dean

----- Original Message -----
From: "Putte, T.B. (Tom) van der" <tom.vanderputte at tno.nl>
To: "Dean Inglis" <dean.inglis at camris.ca>; <vtkusers at vtk.org>
Sent: Friday, May 27, 2011 11:27 AM
Subject: RE: [vtkusers] show celldata on vtkImagePlaneWidget


Hi Dean,

The LUT is defined like this:

vtkLookupTable lut = new vtkLookupTable();
lut.SetTableRange(0, 7);
lut.SetNumberOfTableValues(8);
lut.Build();

lut.SetTableValue(0, 0, 0, 0.498039, 0.75);
lut.SetTableValue(1, 0.458824, 0.227451, 0, 0.75);
lut.SetTableValue(2, 0.772549, 0.384314, 0, 0.75);
lut.SetTableValue(3, 0.666667, 0.666667, 0, 0.75);
lut.SetTableValue(4, 0, 0.666667, 0, 0.75);
lut.SetTableValue(5, 0.333333, 1, 0, 0.75);
lut.SetTableValue(6, 1, 0.666667, 0, 0.75);
lut.SetTableValue(7, 1, 1, 0, 0.75);

However, not defining a lut has the same effect with respect to the
implicitPlaneWidget, the only thing that changes is the color of the
wireframe.

The results in ParaView I get simply through the GUI, not by typing in any
code. I sit possible to get a view of the code behind the pipeline that I
put together through the GUI?

Cheers, Tom


-----Original Message-----
From: Dean Inglis [mailto:dean.inglis at camris.ca]
Sent: vrijdag 27 mei 2011 16:29
To: Putte, T.B. (Tom) van der; vtkusers at vtk.org
Subject: Re: [vtkusers] show celldata on vtkImagePlaneWidget

Tom,

can you send the code that defines the lut?  Id like to
try running this as a tcl script. Also, do you get the results
you want using Paraview?  If so, then it should be doable
in your standalone code.

Dean

----- Original Message -----
Sent: Friday, May 27, 2011 6:47 AM
Subject: RE: [vtkusers] show celldata on vtkImagePlaneWidget


Hi All,

I was trying to implement Deans suggestion to show celldata (not point data)
by using a StructuredGrid, and then an implictPlaneWidget, however I can't
get it to work; what I currently do is this:

(see attachment for vts, it's a file with 27 points with extent (0,0,0) -
(2,2,2) and 8 cells, with only cell data defined)

-----------------------------
//Read vts file
vtkStructuredGridReader reader2 = new vtkStructuredGridReader();
reader2.SetFileName(fileName);
reader2.Update();

//create wireframe mapper

vtkDataSetMapper mapper = new vtkDataSetMapper();
mapper.SetUseLookupTableScalarRange(1);
mapper.SetInput(reader2.GetOutput());
mapper.SetScalarModeToUseCellData();
mapper.SetColorModeToMapScalars();
mapper.InterpolateScalarsBeforeMappingOff();
mapper.SetLookupTable(lut);

vtkActor actor = new vtkActor();
actor.SetMapper(mapper);
actor.GetProperty().SetRepresentationToWireframe();

// Create implicitPlaneWidget
vtkImplicitPlaneWidget implPlaneWidget = new vtkImplicitPlaneWidget();
implPlaneWidget.SetInput(reader2.GetOutput());
implPlaneWidget.SetNormalToZAxis(1);
   implPlaneWidget.PlaceWidget(bounds[0],bounds[1],bounds[2],bounds[3],bounds[4],bounds[5]);
implPlaneWidget.SetOrigin(1, 1, 1);
implPlaneWidget.SetInteractor(interActor);
implPlaneWidget.On();
-----------------------------

The output is in the attached images (struc_grid_vtk_wrong1&2). I put in the
wireframe to check everything. Now there are 2 problems:

1) The wireframe extent is larger than the implicitPlaneWidget extent
2) The implicitPlaneWidget shows only a white plane, but no cell data. What
am I missing here? I also tried the implicitPlaneWidget2, but I can't seem
to get that to work at all.

Any clues on these issues, perhaps anybody has an example of the
implicitPlane in combination with a structured grid? What I'm looking for is
shown in the image from paraview (based on the same vts-file)

Cheers,
Tom


-----Original Message-----
From: Dean Inglis [mailto:dean.inglis at camris.ca]
Sent: woensdag 11 mei 2011 16:09
To: Putte, T.B. (Tom) van der; vtkusers at vtk.org
Subject: Re: [vtkusers] show celldata on vtkImagePlaneWidget

Hi Tom,

this is fundamentally how VTK handles image data: data values are associated
with point locations with pixel corners defined by points, and is different
than, for example, how ITK handles image data (see ITK users guide page 40,
chapter 4: Data Representation) wherein point locations are the pixel
centers.
You can view your data discretely with my suggestion below and if the origin
of
your data needs to be shifted by half spacing you could use
vtkImageChangeInformation.
Alternatey, maybe you could try creating a vtkStructuredGrid and then do

grid->GetCellData()->SetScalars( my_scalar_value_array );

and use vtkImplicitPlaneWidget to interact with and visualize the data.

Dean

----- Original Message -----
From: "Putte, T.B. (Tom) van der" <tom.vanderputte at tno.nl>
To: <vtkusers at vtk.org>
Cc: "Dean Inglis" <dean.inglis at camris.ca>
Sent: Wednesday, May 11, 2011 9:05 AM
Subject: RE: [vtkusers] show celldata on vtkImagePlaneWidget


Hi Dean,

Thanks, I tried this, but the problem is that I'm trying to display discrete
scalar data. So converting cell data to points will actually change values
(throught the vtkCellDataToPointData interpolation), as well as shift the
image 0.5 x spacing distance in all directions.

Suppose I would really want to display the celldata as accurately as
possible on an intersection plane (perhaps even with the (intersection of
the) mesh displayed to make the boundaries between cells more clear), is it
even possible to use the ImagePlaneWidget? Or should I use the implicit
plane widget? Or make something entirely from scratch?

Thanks again,
Tom


-----Original Message-----
From: Dean Inglis [mailto:dean.inglis at camris.ca]
Sent: woensdag 11 mei 2011 14:37
To: vtkusers at vtk.org
Cc: Putte, T.B. (Tom) van der
Subject: Re: [vtkusers] show celldata on vtkImagePlaneWidget

Hi Tom,

you are doing the right thing by converting cell data to point data in this
case.  You could try
setting the interpolation to nearest neighbor and turning interpolation off:

iPlaneWidgetX.SetResliceInterpolateToNearestNeighbour();
iPlaneWidgetX.TextureInterpolateOff();

Dean

Hi,

Using Activiz, I'm trying to display imagedata (CELLDATA, not pointdata) on
a vtkImagePlaneWidget, just as simple gridcells like this:
(https://picasaweb.google.com/lh/photo/SYdgbXrXm-4SRfVHCufBLfK3gj7O8KOK36SDLJLIWK8?feat=directlink)
but it doesn't show anything. What I try is this:

  vtkXMLImageDataReader reader = vtkXMLImageDataReader.New();
  reader.SetFileName(imgFileNameTotal);
  reader.SetCellArrayStatus("CellData", 1); //only celldata
  reader.SetPointArrayStatus("Scalars_", 0); //no pointdata
  reader.Update();

  //Create ImagePlaneWidget
  vtkImagePlaneWidget iPlaneWidgetX = new vtkImagePlaneWidget();
  iPlaneWidgetX.SetInput(reader.GetOutput());
  iPlaneWidgetX.SetPlaneOrientationToXAxes();
  iPlaneWidgetX.SetSliceIndex(10);

  //Rendering, Camera & interactors
  vtkRenderer ren1 =
renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
  vtkRenderWindow renWin = renderWindowControl1.RenderWindow;
  vtkRenderWindowInteractor interActor = renWin.GetInteractor();

  vtkInteractorStyleTrackballCamera style = new
  vtkInteractorStyleTrackballCamera();

  interActor.SetInteractorStyle(style);
  iPlaneWidgetX.SetInteractor(interActor);
  iPlaneWidgetX.On();

  renWin.SetSize(500, 500);
  renWin.Render();

However, when I add this

  vtkCellDataToPointData pointData = new vtkCellDataToPointData();
  pointData.SetInput( reader.GetOutput());

and change the iPlaneWidget's input:
  iPlaneWidgetX.SetInput(pointData.GetOutput());

It does show the data, but as interpolated pointdata, which is not what I
want.

Is the imagePlaneWidget unable to display celldata, and should I tackle this
a different way?

Cheers,
Tom
This e-mail and its contents are subject to the DISCLAIMER at
http://www.tno.nl/emaildisclaimer


This e-mail and its contents are subject to the DISCLAIMER at
http://www.tno.nl/emaildisclaimer




More information about the vtkusers mailing list