[vtkusers] 回复: Data cannot transfer between different dll when linkVTK in static mode
yirui1210
523480317 at qq.com
Sun Jul 22 09:15:56 EDT 2018
Hello Yoshimi,
Thank you so much, it works!
Regards,
Yirui
------------------ 原始邮件 ------------------
发件人: "kenichiro yoshimi"<rccm.kyoshimi at gmail.com>;
发送时间: 2018年7月21日(星期六) 晚上10:39
收件人: "yirui1210"<523480317 at qq.com>;
抄送: "vtkusers"<vtkusers at public.kitware.com>;
主题: Re: [vtkusers] Data cannot transfer between different dll when linkVTK in static mode
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180722/f749cd8f/attachment.html>
More information about the vtkusers
mailing list