[Insight-users] Access point list in LineSpatialObject

fjlb at duke.edu fjlb at duke.edu
Wed Feb 6 17:36:42 EST 2008


Hi,

I created a 4D Line Spatial Object and saved it to a file line.meta as suggested
in the guide. I need to load that file using another program and then I need to
access the point list in the file. Loading the file is no problem, accessing
the points in it is. I don't know how to set my file being read to a
LineSpatialObject.
Should I set it as a parent?
Ideally I would like to have my point list available so that I can calculate the
first and second derivatives between the points.
Running the code below gives me zero points for my file which I know has over 90
points when I created it.
Any help is welcome.

Thanks,

Federico


#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif


#include "itkSpatialObjectReader.h"
#include "itkLineSpatialObject.h"
#include "itkLineSpatialObjectPoint.h"


int main( int argc, char *argv[] )
{
	if( argc < 1 )
	{
		std::cerr << "Usage: SpatialObject" << std::endl;
		return EXIT_FAILURE;
	}

	const unsigned int Dimension = 4;

	typedef itk::LineSpatialObject< Dimension >        LineType;
	LineType::Pointer	Line = LineType::New();

	typedef itk::SpatialObjectReader< Dimension > ReaderType;
	ReaderType::Pointer reader = ReaderType::New();

	reader->SetFileName( argv[1] );
	try
	{
		reader->Update();
	}
    catch ( itk::ExceptionObject &err )
	{
		std::cerr << "Exception thrown: " << err << std::endl;
		return EXIT_FAILURE;
	}

	Line->SetParent( reader->GetGroup() );

	LineType::PointListType pointList = Line->GetPoints();
	std::cout << "Number of points representing the line: ";
    std::cout << pointList.size() << std::endl;

  return 0;
}



More information about the Insight-users mailing list