<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Thanks David,</div><div class=""><br class=""></div><div class="">So yes, I got there this way: </div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> reslice-></span><span style="font-variant-ligatures: no-common-ligatures" class="">GetOutput</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()-></span><span style="font-variant-ligatures: no-common-ligatures" class="">GetPointData</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()-></span><span style="font-variant-ligatures: no-common-ligatures" class="">SetScalars</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">vtkSmartPointer</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">vtkFloatArray</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">>::</span><span style="font-variant-ligatures: no-common-ligatures" class="">New</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">());</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> reslice-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">GetOutput</span><span style="font-variant-ligatures: no-common-ligatures" class="">()-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">GetPointData</span><span style="font-variant-ligatures: no-common-ligatures" class="">()-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">GetScalars</span><span style="font-variant-ligatures: no-common-ligatures" class="">()-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">SetVoidArray</span><span style="font-variant-ligatures: no-common-ligatures" class="">(myBufferPtr</span><span style="font-variant-ligatures: no-common-ligatures" class="">, myBufferBytesLen</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures" class="">);</span></div></div><div class=""><br class=""></div><div class="">It works fine, but could you explain why in <span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">vtkImageData</span><span style="font-family: Menlo; font-size: 11px; font-variant-ligatures: no-common-ligatures;" class="">::AllocateScalars</span> we have:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (scalars && scalars-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">GetDataType</span><span style="font-variant-ligatures: no-common-ligatures" class="">() == dataType</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> && scalars-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">GetReferenceCount</span><span style="font-variant-ligatures: no-common-ligatures" class="">() == </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">Why does it matter, the ReferenceCount be equal to 1 ?</div><div class=""><br class=""></div><div class="">Alessandro</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 21, 2017, at 2:56 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" class="">david.gobbi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Sat, Jan 21, 2017 at 4:34 AM, Alessandro Volz <span dir="ltr" class=""><<a href="mailto:alessandro.volz@gmail.com" target="_blank" class="">alessandro.volz@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm using vtkImageReslice to obtain a vtkImageData object that I read the output scalars from. All works fine.<br class="">
I'm now in a situation where it would make sense that I preallocate thee output buffer for the reslice to write into.<br class="">
Is there a way to do this?<br class="">
I thought I'd create a vtkImageData and SetScalarPointer on it, then SetOutput on the reslice. But I haven't been able to.<br class="">
Is there a way I could do this? Maybe I should create a vtkImageData subclass?</blockquote><div class=""><br class=""></div><div class="">Instead of subclassing vtkImageData, it might be better to subclass vtkImageReslice and override the AllocateOutputData() methods. See the current implementation of AllocateOutputData() here:</div><div class=""><a href="https://gitlab.kitware.com/vtk/vtk/blob/master/Common/ExecutionModel/vtkImageAlgorithm.cxx#L198" target="_blank" class="">https://gitlab.kitware.com/<wbr class="">vtk/vtk/blob/master/Common/<wbr class="">ExecutionModel/<wbr class="">vtkImageAlgorithm.cxx#L198</a><br class=""></div><div class=""><br class=""></div><div class="">But your idea of calling SetOutput() should work as long as you provide a large enough output buffer of the correct data type.</div><div class=""><br class=""></div><div class=""> - David</div><div class=""><br class=""></div></div></div></div>
</div></blockquote></div><br class=""></body></html>