[Insight-developers] filter->GetOutput() should be 'const'

Luis Ibanez luis . ibanez at kitware . com
Mon, 14 Jul 2003 11:01:10 -0400


We recently have a user doing the following:

    reader->Update();
    reader->GetOutput()->SetScaling( scaling );
    filter->SetInput( reader->GetOutput() );


The SetScaling() shouldn't be used in this
circumstances since it is interfering with
the pipeline.

---

This error could have been prevented if we
were using cons-correctness in the GetOutput()
method of ITK filters, as we are doing already
for SetInput().

The const-ness only need to be removed at
the level of the pipeline (as it is the case
for SetInput()).  In all other cases, users
shouldn't be allowed to change the content of
an image that is being produces as the output
of a filter.


I suggest we fix this before the release 1.4.


The GetOutput() method should have signature:


   const OutputImageType * GetOutput() const


This could be done after we freeze the code...


   Luis