[vtkusers] Data cannot transfer between different dll when link VTK in static mode

kenichiro yoshimi rccm.kyoshimi at gmail.com
Sat Jul 21 10:39:14 EDT 2018


Hello Yirui,

I think the problem is caused by the missing information relating to
the pipeline and hence WHOLE_EXTENT. Therefore in Function2WriteImage
function, you need to explicitly create vtkTrivialProducer to pass the
WHOLE_EXTENT to the writer below.

void Function2WriteImage(vtkSmartPointer<vtkImageData> data)
{
  int ext[6];
  data->GetExtent(ext);
  vtkSmartPointer<vtkTrivialProducer> producer =
    vtkSmartPointer<vtkTrivialProducer>::New();
  producer->SetOutput(data);
  producer->SetWholeExtent(ext);

  std::cout << "Write image using function2.dll" << std::endl;
  vtkSmartPointer<vtkMetaImageWriter> writer =
    vtkSmartPointer<vtkMetaImageWriter>::New();
  writer->SetFileName("./function2_write_image.mha");
  writer->SetInputConnection(producer->GetOutputPort());
  try {
    writer->Write();
  }
  catch (...)
  {
    std::cout << "function 2 write image error." << std::endl;
    return;
  }
}

Regards
2018年7月21日(土) 17:16 yirui1210 <523480317 at qq.com>:
>
> Hello,
>
> I build VTK 8.0 in static mode in Windows 10, VS2015, and I write a simple demo which has two dll modules. The data is transferred as following:
> (1) read data in module 1 and save it, this is no problem.
> (2) transfer the data in module 1 to module 2.
> (3) write the data in module 2, but there is error, the saved data is empty.
> I have traced the code in VTK roughly, the image extent is [0, -1, 0, -1, 0, -1], but I can retrieve the pixel, the pixel value can be get correctly. The demo code I used is attached in this email, any help or tips will be appreciated, thank you!
>
> Regards,
> Yirui
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers


More information about the vtkusers mailing list