<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-07-03 20:19 GMT+02:00 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Sun, Jul 3, 2016 at 11:59 AM, Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>2016-07-03 19:57 GMT+02:00 Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>If I'm writing my own custom volume reader, and I have the read data in memory (say as a float*). If I know the data is in the right format/layout, can I somehow pass ownership of that data to the output of the algorithm without incurring a copy?<br><br></div><div>I've been looking at some of the simpler readers that come with VTK, but all of them seems to copy the read data to the output (?).<br></div></div></div></blockquote><div><br></div></span><div>Looking at vtkImageData, what I would like (I think) is some way of setting the pointer that is returned by vtkImageData::GetScalarPointer.<br></div></div></div></div></blockquote><div><br></div></span><div>Here is a cut & paste of code from vtkImageImport. Read the the documentation for vtkAbstractArray::SetVoidArray() carefully.</div></div></div></div></blockquote><div><br></div><div>Ah, thanks a lot. I should have found that.<br><br></div><div>Elvis<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div><div> vtkImageData *data = vtkImageData::SafeDownCast(output);</div><div> data->SetExtent(0,0,0,0,0,0);</div><div> data->AllocateScalars(outInfo);</div><div> vtkIdType size = this->NumberOfScalarComponents;</div><div> size *= this->DataExtent[1] - this->DataExtent[0] + 1;</div><div> size *= this->DataExtent[3] - this->DataExtent[2] + 1;</div><div> size *= this->DataExtent[5] - this->DataExtent[4] + 1;</div><div> data->SetExtent(this->DataExtent);</div><div> data->GetPointData()->GetScalars()->SetVoidArray(inputPtr, size, 1);</div><div> data->GetPointData()->GetScalars()->SetName(this->ScalarArrayName);</div></div><div><br></div><div> - David</div></div></div></div>
</blockquote></div><br></div></div>