[Insight-developers] InPlaceImageFilter::CanRunInPlace not virtual + Potential misunderstanding with InPlaceImageFilter::GetInplace

Karthik Krishnan karthik.krishnan at kitware.com
Wed Apr 29 09:24:58 EDT 2009


Tom:

- GetInPlace() / SetInPlace() is an opportunity for the user to state if
he'd like the filter should run in place.

- CanRunInPlace() is an opportunity for the filter to state if it is capable
of running in place.

So one should check both...

if {user wants to run filter in place} & {filter is capable of running in
place)
  {
   // ...
  }


I wouldn't add a third option, it'd make things more confusing.

No reason why CanRunInPlace is not virtual, although you seem to have a case
in point to change it motivated by compatibility rather than design.

Thanks
--
karthik

On Wed, Apr 29, 2009 at 7:52 AM, Tom Vercauteren <tom.vercauteren at m4x.org>wrote:

> Hi all,
>
> I wrote a subclass of InPlaceImageFilter. Because of  the following
> (now fixed) bug, http://www.itk.org/Bug/view.php?id=8672, my filter
> can only run in place for ITK version strictly greater than 3.12. I
> thus need a backward compatibility scheme.
>
> My first try, was to override InPlaceImageFilter::CanRunInPlace to
> return false if the ITK version is below 3.13. However I realized that
> InPlaceImageFilter::CanRunInPlace is not virtual which means I'd
> rather stay off overriding it... Is there a reason why
> InPlaceImageFilter::CanRunInPlace is not virtual?
>
> Also, I initially thought that, if InPlaceImageFilter::CanRunInPlace
> returned false, then InPlaceImageFilter::GetInplace would also return
> false. This is however not the case. It seems that I need to both
> check for CanRunInPlace and GetInplace to know whether a filter will
> actually run in place.
>
> This design seems a bit odd to me. Wouldn't it be better if
> InPlaceImageFilter::GetInplace would return whether a filter will
> actually run in place? Or maybe we can add a new virtual function to
> do that, e.g. InPlaceImageFilter::WillRunInPlace.
>
> Currently, it seems that such a function would only be used in three
> itk classes ( PasteImageFilter, CastImageFilter and
> DenseFiniteDifferenceImageFilter) but I think it would be worth having
> it.
>
> Thoughts?
>
> Regards,
> Tom Vercauteren
> _______________________________________________
> 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 ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090429/e78069eb/attachment.htm>


More information about the Insight-developers mailing list