<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi all,<br>
<br>
I would like to be able to change between multiresolution and direct
registration methods on run-time.<br>
<br>
Up to now, I've been using a template class to make all constructors of
needed classes public (and using the raw C++ pointers) to have the
ability of casting classes, but I think that it is not the right
solution.<br>
<br>
The question is, how should I do to create an object of a type and then
cast it to its superclass? e.g.:<br>
<br>
<blockquote>
<pre>itk::ImageRegistrationMethod<ImageType, ImageType>::Pointer r = itk::ImageRegistrationMethod<ImageType, ImageType>::New();</pre>
<pre>// do some particular itk::ImageRegistrationMethod stuff
...</pre>
<pre>itk::ProcessObject::Pointer registration = dynamic_cast<itk::ProcessObject::Pointer>(r);
// do some common stuff of itk::ProcessObject children
</pre>
</blockquote>
I think that another way to resolve my problem should be act as
itk::Common is used on the examples code:<br>
<blockquote type="cite">
<pre>void Execute ( const itk::Object * object, const itk::EventObject & event ) {</pre>
<pre> OptimizerPointer optimizer =</pre>
<pre> dynamic_cast< OptimizerPointer > ( object );</pre>
<pre> if ( ! itk::IterationEvent().CheckEvent ( &event ) )</pre>
<pre> {</pre>
<pre> return;</pre>
<pre> }</pre>
<pre> std::cout << optimizer->GetCurrentIteration() << " ";</pre>
<pre> std::cout << optimizer->GetValue() << " ";</pre>
<pre> std::cout << optimizer->GetCurrentPosition() << std::endl;</pre>
<pre> }</pre>
</blockquote>
But, how should I get the itk::Object* from the
itk::ImageRegistrationMethod<..>::Pointer ?<br>
<br>
Thanks in advance,<br>
Oscar Esteban<br>
</body>
</html>