<div dir="ltr"><div><div>Hi Brad, thank you very much, it works!<br><br></div>I had reimplemented the MakeOutput method in my filter but with a sligthly different signature, and it called twice the .GetPointer() method on the output, so I changed it and it seams to solve the problem. <br>
<br></div><div>// class template stuff...<br></div>void <br><div><pre style="margin:0px;text-indent:0px"><span style="color:rgb(56,118,29)"><span style="background-color:rgb(255,255,255)">//</span></span><span style="color:rgb(192,192,192)"><span style="color:rgb(56,118,29)"><span style="background-color:rgb(255,255,255)"><span style="font-style:italic">MakeOutput</span>( unsigned int idx )  </span> </span> </span><span style="color:rgb(0,128,0)"></span></pre>
<span style="color:rgb(0,0,0)">::</span><span style="font-style:italic;color:rgb(0,0,0)">MakeOutput</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">DataObjectPointerArraySizeType</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">idx</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">)</span>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">{</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">DataObject</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">Pointer</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">output</span><span style="color:rgb(0,0,0)">;</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">switch</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">idx</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">)</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">case</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">:</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(0,0,0)">output</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(192,192,192)"> </span>TVectorField<span style="color:rgb(0,0,0)">::</span>New<span style="color:rgb(0,0,0)">()</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">).</span>GetPointer<span style="color:rgb(0,0,0)">();</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">break</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">case</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">:</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(0,0,0)">output</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span>TImage<span style="color:rgb(0,0,0)">::</span>New<span style="color:rgb(0,0,0)">()</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">).</span>GetPointer<span style="color:rgb(0,0,0)">();</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">break</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">default</span><span style="color:rgb(0,0,0)">:</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,128)">std</span><span style="color:rgb(0,0,0)">::</span>cerr<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><<</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"No</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">output</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">"</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><<</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">idx</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><<</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">std</span><span style="color:rgb(0,0,0)">::</span>endl<span style="color:rgb(0,0,0)">;</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(0,0,0)">output</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span>NULL<span style="color:rgb(0,0,0)">;</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">break</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">}</span></pre>
<pre style="margin:0px;text-indent:0px"><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,128,0)">return</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">output.GetPointer();</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">return</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">output</span><span style="color:rgb(0,0,0)">;</span></pre>

<pre style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0)">}</span></pre><br></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">Nicolás Gallego-Ortiz<br>Université catholique de Louvain, Belgium<br>
</div></div>
<br><br><div class="gmail_quote">2014-07-14 15:22 GMT+02:00 Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
Did you overload the MakeOutput method for your filter?<br>
<br>
This method is used to create new outputs, like when you disconnect the output. If you want to understand how this is done look here at the DataObject::DisconnectPipeline method[1], which calls ProcessObject::SetOutput(NULL)[2], and then your overridden ProcessObject::MakeOutput such as here [3].<br>

<br>
Brad<br>
<br>
[1] <a href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/src/itkDataObject.cxx#L202-L223" target="_blank">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/src/itkDataObject.cxx#L202-L223</a><br>

[2] <a href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/src/itkProcessObject.cxx#L482-L484" target="_blank">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/src/itkProcessObject.cxx#L482-L484</a><br>

[3] <a href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx#L52-L70" target="_blank">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx#L52-L70</a><br>

<div><div class="h5"><br>
On Jul 14, 2014, at 9:09 AM, Nicolas Gallego <<a href="mailto:nicgallego@gmail.com">nicgallego@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> I have implemented a filter with two outputs of different type inspired by the example []. This filter is used inside a loop, so I learned from an earlier post in this list that I should call the method DisconnectPileline() on the image pointers I use hold the intermediate results before using them as inputs of my pipeline on the next iteration. Something like this<br>

><br>
> .....<br>
> TImage1::Pointer im1;<br>
> TImage2::Pointer im2;<br>
><br>
> ... initialization code...<br>
> filter->SetInput1( im1 );<br>
> filter->SetInput2( im2 );<br>
><br>
> for( int i = 0; i < nIter; i++) {<br>
>     filter->Update();<br>
>     TImage1::Pointer tmp1 = filter->GetOutput1();<br>
>     TImage2::Pointer tmp2 = filter->GetOutput2();<br>
><br>
><br>
><br>
><br>
> The problem is that it only works on the principal output, when I call the method on the second output, I get the following execution error,<br>
><br>
> ---------------------------------------------------------------------------------------------------------------------------<br>
> itk::ExceptionObject (0000000000ACF300)<br>
> Location: "unknown"<br>
> File: d:\itk4.5\insighttoolkit-4.5.0\modules\core\common\include\itkImage.hxx<br>
> Line: 138<br>
> Description: itk::ERROR: Image(0000000002FDBDF0): itk::Image::Graft() cannot cast class itk::DataObject const * __ptr64 to class itk::Image<class itk::Vector<fl<br>
> oat,3>,3> const * __ptr64<br>
> ---------------------------------------------------------------------------------------------------------------------------<br>
><br>
> and when I use PipelineDisconnect() only on the principal output, my pipeline is Updated twice as it is still connected, and the program does not crash but the results are numerically incorrect. Any ideas to solve this issue? I know I should submit an example code that reproduces the error, I will try to extract it and post it later, but for the moment I would be happy to get some ideas about how to debug this issu.<br>

><br>
> Thank you very much,<br>
><br>
> Nicolás Gallego-Ortiz<br>
> Université catholique de Louvain, Belgium<br>
</div></div>> _______________________________________________<br>
> Community mailing list<br>
> <a href="mailto:Community@itk.org">Community@itk.org</a><br>
> <a href="http://public.kitware.com/mailman/listinfo/community" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
<br>
</blockquote></div><br></div>