[Insight-users] how to pass a mesh out of a funcion?

#ZHAO ZHEEN# kurtzhao at pmail.ntu.edu.sg
Fri, 9 Jan 2004 16:25:28 +0800


Hi, there,

I created a mesh in a function, then pass the pointer out. When I was =
using the pointer outside of the function, it had been destroyed.=20
How can I use the mesh at the outside of the function?
Here is the code:

bool SegToMash(const char * SegImgFileName, float OrganValue, MeshType * =
mesh)
{
	typedef unsigned short SegPixelType;
	typedef itk::Image< SegPixelType, Dimension >   SegType;
	typedef itk::BinaryMask3DMeshSource< MeshType >  MeshSourceType;
	typedef itk::ImageFileReader< SegType >  SegReaderType;
=09
	SegReaderType::Pointer    SegReader     =3D  SegReaderType::New();
	SegReader->SetFileName(  SegImgFileName );
	 SegReader->Update();
  =20
MeshSourceType::Pointer meshSource =3D MeshSourceType::New();
=20
  meshSource->SetBinaryImage( SegReader->GetOutput() );
  meshSource->SetObjectValue( (SegPixelType)OrganValue );
  meshSource->Update();
		=20

  mesh=3DmeshSource->GetOutput();
=09
	return false;
}

Best Regards
Kurt