[Insight-users] Primary question: SmartPointer
Yann GAVET
yann.gavet@univ-st-etienne.fr
Wed May 5 13:19:18 EDT 2004
This is a multi-part message in MIME format.
--------------030206080707020809080600
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit
Well, Im no itk expert but I would say that you should write
ImageType::Pointer ClassA::OneFilter()
{
...
}
I think that ImageType::New() is not useful because you allocate a new
image and then you loose the reference.
yann.
Jiang wrote:
> Hi, ITK-users,
>
> I have one question about how to transfer SmartPointer as return value.
>
> The following is my part of code:
>
> typedef
ImageType
>
> void ClassA::func()
>
> {
>
> ImageType::Pointer ResultImage = ImageType::New();
>
> ResultImage=OneFilter();
>
> }
>
> ImageType* ClassA::OneFilter()
>
> {
>
>
.
>
> Some filter process
>
>
.
>
> return filter->GetOutput();
>
> }
>
> The program stops at ResultImage=OneFilter();
>
> I have debugged ClassA::OneFilter, it can work. If I dont use
> ClassA::OneFilter() and ResultImage=OneFilter(),
>
> and put
>
>
.
>
> Some filter process
>
>
.
>
> directly in ClassA::func(), then everything is ok. The
> filter->GetOutput is correct.
>
> I guess the problem is
>
> ImageType::Pointer ResultImage = ImageType::New();
>
> ResultImage= OneFilter();
>
> Is it wrong way to return SmartPoiner from one function to another
> function?
>
> How should I do?
>
> Thanks a lot!
>
> Chunyan Jiang
>
--------------030206080707020809080600
Content-Type: text/x-vcard; charset=utf8;
name="yann.gavet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="yann.gavet.vcf"
begin:vcard
fn:Yann Gavet
n:Gavet;Yann
org;quoted-printable:CHU Saint-Etienne;EA 3063 - Survie et adh=C3=A9rence cellulaire dans les cancers et les gre=
ffes
adr;quoted-printable:;;15 rue A. Par=C3=A9;;;42000;France
email;internet:yann.gavet@univ-st-etienne.fr
title;quoted-printable:Ing=C3=A9nieur Civil des Mines
version:2.1
end:vcard
--------------030206080707020809080600--
More information about the Insight-users
mailing list