[Insight-users] Smart pointer to filter output
Luis Ibanez
luis.ibanez at kitware.com
Wed Nov 25 19:25:22 EST 2009
Hi Gerald,
You shouldn't remove the constness of the image pointer.
Images are own by the filter that produce them.
You should not change the content of an image that is
the output of a filter. Therefore you should receive such
images into Const Smart Pointers, such as:
ImageType::ConstSmartPointer p = filter->GetOutput();
Regards,
Luis
---------------------------------
On Mon, Nov 23, 2009 at 3:22 AM, Lodron, Gerald
<Gerald.Lodron at joanneum.at> wrote:
> It does not compile! Now I found a way but it does not look very nice:
>
> void setSourceImage(vtkImageData* image) {
> m_TargetConnector= SourceConnectorType::New();
> m_TargetConnector->SetInput(image);
> //m_TargetImage= m_TargetConnector->GetOutput(); //does not work
> m_TargetImage = const_cast<TargetImageType*>(m_TargetConnector->GetOutput());
> }
>
> I don't need tue update image yet, i am only building the connection pipeline. Any other suggestions?
>
> Best regards
>
>
>
> Hi Gerald,
>
> by "doesn't work", what do you mean ?
>
> 1) It does not compile ?
> 2) It compiles but seg. faults at run time ?
> 3) It throws an exception at run time ?
> 4) It returns a null pointer at run time ?
>
>
> The design of your method is strange.
>
>
> You probably should have done:
>
> m_TargetConnector= SourceConnectorType::New();
>
> inside the constructor of your class,
>
> and the setSourceImage() should only
> have the lines:
>
>> void setSourceImage(vtkImageData* image) {
>> m_TargetConnector->SetInput(image);
>> }
>
>
> Why is that there is no call to the Update() method ?
>
> You don't seem to have a line like:
>
> m_TargetConnector->Update();
>
>
> Please let us know,
>
>
> Thanks
>
>
> Luis
>
>
>
> -----------------------------------------------------------------------------------
> On Tue, Nov 17, 2009 at 10:26 AM, Lodron, Gerald <Gerald.Lodron at joanneum.at> wrote:
>> Hello
>>
>> How can I make a smart pointer to my filter output, here my code:
>>
>> Class parameters (TargetImageType is a template parameter):
>>
>> typedef typename itk::VTKImageToImageFilter<TargetImageType>
>> TargetConnectorType;
>>
>> typename TargetImageType::Pointer m_TargetImage; typename
>> TargetConnectorType::Pointer m_TargetConnector;
>>
>> Function:
>>
>> void setSourceImage(vtkImageData* image) {
>> m_TargetConnector= SourceConnectorType::New();
>> m_TargetConnector->SetInput(image);
>> m_TargetImage= m_TargetConnector->GetOutput(); //does not work
>> }
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
More information about the Insight-users
mailing list