[vtkusers] vtk Filter's new/delete
chensiqi
pidanchen at hotmail.com
Tue Dec 23 00:35:11 EST 2008
Hi, vtkers.
I have a question regarding pointer new and delete. Here is the code
main(){
....
vtkPoints *LSPoints = vtkPoints::New(); fun ( LSV, &LSPoints );
std::cout<< LSPoints->GetNumberOfPoints()<<std::endl;.......................................(1)
....
LSPoints->Delete();
}
fun( vtkImage LSV, vtkPoints **pLSPoints )
{
vtkContourFilter *LSFilter = vtkContourFilter::New(); LSFilter->SetInput( vtkLSV ); LSFilter->SetValue( 0, 0 ); LSFilter->Update();
*pLSPoints = LSFilter->GetOutput()->GetPoints();
std::cout<< (*pLSPoints)->GetNumberOfPoints()<<std::endl;.................................(2) LSFilter->Delete();
}
The output at position 2 is correct where as the output at position 1 is destroyed.
If I comment "LSfilter->Delete()", then the output at both locations are correct. But I think I need to release the memory of LSFilter here.
pls point out where I am wrong.
Thanks for any input.
Siqi
_________________________________________________________________
超炫人气榜给您所有偶像的最新资讯和排名,快来支持自己的偶像!
http://cnweb.search.live.com/xrank/results.aspx?q=%e5%91%a8%e6%9d%b0%e4%bc%a6&FORM=MSNH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081223/ba765200/attachment.htm>
More information about the vtkusers
mailing list