Skip to content

Avoid memcpy when possible #37

@finetjul

Description

@finetjul

vtkIGTLToMRMLImage.cxx:326 (vtkIGTLToMRMLImage::IGTLToMRML), there is a coslty memcpy.

Instead, the pointer on the array could be passed to the vtkImageData array. For example (I did not try, but something like that could work):

switch(imageData->GetDataType())
   {
   vtkTemplateMacro(static_cast<vtkDataArrayTemplate<VTK_TT>* >(imageData->GetPointData()->GetScalars())->SetVoidArray(imgMsg->GetScalarPointer(), imgMsg->GetSubVolumeImageSize(), /*save*/1);
  }

Of course, the array memory should stay valid for as long as the imagedata is around.

See:
http://www.vtk.org/doc/nightly/html/classvtkDataArrayTemplate.html#a5d4281c3356c18a276ae7a8db8ca0c87
https://github.com/Slicer/Slicer/blob/master/Libs/vtkITK/vtkITKArchetypeImageSeriesScalarReader.cxx#L130-L132

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions