[vtkusers] Extent / Pipeline Problem with vtk 6.1

Berk Geveci berk.geveci at kitware.com
Thu Jul 3 13:10:46 EDT 2014


Hi Daniel,

I am happy to report that this is not a bug in VTK. It is a bug in the
example instead. I am happy because I don't have to fix a bug in my code :-)

Take a look at this document:
http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput

It explains that SetInputData() does not set a pipeline connection. When
you use it, you need to make sure that the pipeline that produce the data
is manually updated. So adding a
color->Update();
before rendering happens will fix the issue.

If your intention is to setup a pipeline connection such that any change in
filter parameters are automatically reflected in the viewer, use this
instead:
imageViewer->SetInputConnection(color->GetOutputPort());

Best,
-berk


On Thu, Jul 3, 2014 at 3:57 AM, Frese Daniel Dr. <frese at heidenhain.de>
wrote:

> I rechecked the behavior with a more recent git snapshot as of yesterday;
> the behavior remains the same. So I filed a bug report with ID 0014838
> <http://vtk.org/Bug/view.php?id=14838>.
>
>
>
> Daniel
>
>
>
>
>
> *Von:* Goodwin Lawlor [mailto:goodwin.lawlor.lists at gmail.com]
> *Gesendet:* Mittwoch, 2. Juli 2014 12:39
> *An:* Frese Daniel Dr.
> *Cc:* vtkusers at vtk.org
> *Betreff:* Re: [vtkusers] Extent / Pipeline Problem with vtk 6.1
>
>
>
> Hi Daniel,
>
>
>
> On quick inspection this looks like a bug in vtkImageMapToColors not
> handling the output info. You could file a bug here: http://vtk.org/Bug
>
>
>
> hth
>
>
>
> Goodwin
>
>
>
> On Mon, Jun 30, 2014 at 2:23 PM, Frese Daniel Dr. <frese at heidenhain.de>
> wrote:
>
> Hi everybody,
>
>
>
> After porting a working application from vtk 5.x to vtk 6.1, I ran into
> some problems that I can’t solve by myself. Based on the error messages, I
> think though, it originates in the modified pipeline behavior of vtk 6.1
> (admittedly I use an already aged snapshot from November 2013).
>
>
>
> I tried to assemble a more or less minimal example to illustrate the
> problem. Basically I use the pipeline
>
> vtkImageCanvasSource2D -> vtkImageMapToColors -> vtkImageViewer2.
>
> If I visualize the canvas, without passing through the vtkImageMapToColors
> filter, everything works fine. If I pass through the vtkImageMapToColors
> filter, I get a blank render window and the error message :
>
> “vtkTrivialProducer (00F15A08) : This data object does not contain the
> requested extent.”
>
>
>
> I printed out the vtkInformation objects of the canvas’ output port and
> the the vtkImageMapToColors’ input port, and both outputs showed the
> correct extents for WHOLE_EXTENT and UPDATE_EXTENT, but wrong values for
> COMBINED_UPDATE_EXTENT. Moreover, canvas->GetOutput()->Print() gives also
> the right extents, whereas the output of the the vtkImageMapToColors shows
> that basically no meta information has been transmitted.
>
>
>
> The complete code is below. Does anybody have a clue, what I am missing
> here ?
>
>
>
> Thank you,
>
> Daniel
>
>
>
>
>
> #include <vtkAutoInit.h>
>
> VTK_MODULE_INIT(vtkInteractionStyle);
>
> VTK_MODULE_INIT(vtkRenderingOpenGL);
>
>
>
> #include <vtkSmartPointer.h>
>
> #include <vtkLookupTable.h>
>
> #include <vtkImageCanvasSource2D.h>
>
> #include <vtkImageMapToColors.h>
>
> #include <vtkRenderWindowInteractor.h>
>
> #include <vtkImageViewer2.h>
>
> #include <vtkRenderer.h>
>
> #include <vtkInformation.h>
>
> #include <vtkImageData.h>
>
>
>
> void main() {
>
>       // Creation of canvas drawing
>
>       vtkSmartPointer<vtkImageCanvasSource2D> canvas =
> vtkSmartPointer<vtkImageCanvasSource2D>::New();
>
>       canvas->SetScalarTypeToUnsignedChar();
>
>       canvas->SetExtent(0, 99, 0, 99, 0, 0);
>
>       canvas->SetDrawColor(255);
>
>       canvas->DrawSegment(10, 10, 90, 90);
>
>       canvas->Update();
>
>       // canvas->GetOutputInformation(0)->Print(cout); // debug output
> shows : correct WHOLE_EXTENT / UPDATE_EXTENT
>
>
>
>       // Map colors
>
>       vtkSmartPointer<vtkLookupTable> lut =
> vtkSmartPointer<vtkLookupTable>::New();
>
>       lut->SetNumberOfColors(256);
>
>       lut->SetTableRange(0, 255);
>
>       lut->SetValueRange(0, 255);
>
>       lut->Build();
>
>       for (int i=0; i<256; i++) lut->SetTableValue(i, i/255.0, 0, 0, 1);
>
>
>
>       vtkSmartPointer<vtkImageMapToColors> color =
> vtkSmartPointer<vtkImageMapToColors>::New();
>
>       color->SetLookupTable(lut);
>
>       color->SetInputConnection(canvas->GetOutputPort());
>
>       // color->GetInputInformation()->Print(cout); // debug output shows
> : correct WHOLE_EXTENT / UPDATE_EXTENT
>
>       // color->GetOutput()->Print(cout); // debug output shows : Extent
> wrong !
>
>
>
>       // Display the result
>
>       vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>
>       vtkSmartPointer<vtkImageViewer2> imageViewer =
> vtkSmartPointer<vtkImageViewer2>::New();
>
>
>
>       imageViewer->SetInputData(canvas->GetOutput());  // using this
> line, I get sensible output
>
>       //imageViewer->SetInputData(color->GetOutput());  // using this
> line, I get an empty viewer and an error message
>
>
>
>       imageViewer->SetupInteractor(renderWindowInteractor);
>
>       imageViewer->GetRenderer()->ResetCamera();
>
>
>
>       renderWindowInteractor->Initialize();
>
>       renderWindowInteractor->Start();
>
> }
>
>
>
>
>
> ------------------------------------------------------------------------------------------------------
>
> Registergericht: Traunstein / Registry Court: HRB 275 - Sitz / Head
> Office: Traunreut
> Aufsichtsratsvorsitzender / Chairman of Supervisory Board: Rainer Burkhard
> Geschäftsführung / Management Board: Thomas Sesselmann (Vorsitzender /
> Chairman),
> Michael Grimm, Matthias Fauser, Sebastian Tondorf
>
> E-Mail Haftungsausschluss / E-Mail Disclaimer:
> http://www.heidenhain.de/disclaimer
>
>
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140703/612120cd/attachment.html>


More information about the vtkusers mailing list