[vtkusers] show celldata on vtkImagePlaneWidget

Putte, T.B. (Tom) van der tom.vanderputte at tno.nl
Fri May 27 06:47:28 EDT 2011


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: strucGrid_Cellonly.vts
Type: application/octet-stream
Size: 385 bytes
Desc: strucGrid_Cellonly.vts
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110527/a82c434c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: strucGrid_paraview.png
Type: image/png
Size: 10302 bytes
Desc: strucGrid_paraview.png
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110527/a82c434c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: struc_grid_vtk_wrong2.png
Type: image/png
Size: 15646 bytes
Desc: struc_grid_vtk_wrong2.png
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110527/a82c434c/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: struc_grid_vtk_wrong.png
Type: image/png
Size: 25349 bytes
Desc: struc_grid_vtk_wrong.png
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110527/a82c434c/attachment-0002.png>


More information about the vtkusers mailing list