[Insight-users] Re: Stopping registration using metric value
Luis Ibanez
luis.ibanez at kitware.com
Thu, 22 Jan 2004 12:26:14 -0500
Hi Radhika,
"Knowing constancy is Insight
Not knowing constancy leads to disaster"
Tao Te Ching,XVI, Lao Tsu
----
ITK considers a double role for the Observers.
Those who quietly "observe" another ITK object
without disturbing it, and those more "interven-
tionalist" observers who take the liberty of
changing the state of the object they observe.
For this reason you will find that the Observer
interface of the itk::Command class has two different
Execute() methods. One with const interface and other
with non-const interface.
A) Non-Const (Quantum-mechanics observers):
void Execute(Object *caller, const EventObject & event );
B) Const (Newtonian observers):
void Execute(const Object *caller, const EventObject & event );
When you plan to alter the state of the object that
you are observing, you should implement this action
in the Execute() method with non-const interface.
The compiler errors that you are getting are the result
of putting your code in the "const" Execute method and
still attempt to call non-const methods of the optimizer.
Please put your code in the non-const method.
Regards,
Luis
--------------------------------
Radhika Sivaramakrishna wrote:
> Hi Luis,
>
> As you had indicated in a previous post, I tried to include a statement
> like below in the Evaluate function of my
>
> command observer.
>
>
>
> if (optimizer->GetValue() < 30)
>
> optimizer->StopOptimization();
>
>
>
>
>
> However, I got the error below.
>
>
>
>
>
> Building object file Registration3D.o...
>
> /export/jfs/rsivaram/Registration/Registration3D.cxx: In member function
>
> `virtual void CommandIterationUpdate::Execute(const itk::Object*, const
>
> itk::EventObject&)':
>
> /export/jfs/rsivaram/Registration/Registration3D.cxx:57: passing `const
>
> itk::VersorRigid3DTransformOptimizer' as `this' argument of `void
>
> itk::RegularStepGradientDescentBaseOptimizer::StopOptimization()'
> discards
>
> qualifiers
>
> make[1]: *** [Registration3D.o] Error 1
>
>
>
>
>
> Is this just a casting problem, or something else?
>
>
>
>
>
> Thanks
>
> Radhika
>
>
>
> -----------------------------------------------------
>
> Confidentiality Notice.
>
> This email message is for the sole use of the intended recipient(s) and
> may contain confidential and privileged information. Any unauthorized
> review, use, disclosure or distribution is prohibited. If you are not
> the intended recipient, please contact the sender by reply email and
> destroy all copies of the original message. If you are the intended
> recipient, please be advised that the content of this message is subject
> to access, review and disclosure by the sender's Email System Administrator.
>