[Insight-users] StopOptimization
Luis Ibanez
luis . ibanez at kitware . com
Mon, 25 Aug 2003 18:54:13 -0400
Hi Michael,
The error message that you posted seems to be originated by a
conflict in constness qualifications.
Note that Observers should implement two Execute() methods, one
"const" and another "non-const". The StopOptimization() method is
non-const, so you can only invoke it from the non-const Execute()
method of the Observer.
The other calls are allowed in your const Execute() method, because
they are also const methods. (e.g. GetCurrentPosition() ).
Please try implementing a non-const Execute() method in your
observer and call StopOptimization from there.
Regards,
Luis
----------------------
Michael Kuhn wrote:
> Hi,
>
> When I'm trying to call optimizer->StopOptimization in my observer I get
> the following compiler error:
>
> D:\pack\vtkMy\src\Applications\Mixed\itkUtilities\quaternionObserverMultiResolution.cxx(49)
> : error C2662: 'StopOptimization' : cannot convert 'this' pointer from
> 'const class itk::QuaternionRigidTransformGradientDescentOptimizer' to
> 'class itk::Gra
> dientDescentOptimizer &'
> Conversion loses qualifiers
> C:\programs\vs6p\VC98\INCLUDE\xstring(583) : while compiling
> class-template member function 'void __thiscall
> QuaternionObserverMultiResolution<class itk::RegistrationModule<class
> itk::Image<short,3>,class itk::Image<short,3>,class itk::Image
> <short,3> > >::Execute(const class itk::Object *,const class
> itk::EventObject &)'
> Error executing cl.exe.
>
> In the execute method, I do a dynamic_cast from itk::Object caller to
> itk::QuaternionRigidTransformGradientDescentOptimizer optimizer:
>
> OptimizerPointer optimizer = dynamic_cast<OptimizerPointer>(caller);
>
> OptimizerPointer is defined as follows in the .h file of my observer:
>
> typedef itk::QuaternionRigidTransformGradientDescentOptimizer
> OptimizerType;
> typedef const OptimizerType* OptimizerPointer;
>
>
>
> Other calls to this optimizer (like optimizer->GetCurrentPosition())
> work fine (i.e. the program compiles if I comment the line that
> contains optimizer->StopOptimization() ).
>
> Can anybody tell me, what I'm doing wrong?
>
> Thanks,
>
> Michael
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>