[Insight-users] pointset data deleted on update

flavio flaviosime at yahoo.it
Thu Sep 11 16:06:01 EDT 2008


hello
I'm trying to build a PointSetToImageRegistrationMethod using a
SpatialObjectToPointSetFilter to create the pointset and then setting
points_data manually.
My registration don't work and I see that before StartRegistration()
pointset data are correct but after was reset to zero.
I wrote this code to debug my application:

    // SO to PointSet ------

typedef itk::PointSet<float, 3 >PointSetType;

itk::SpatialObjectToPointSetFilter<GroupType,PointSetType>
SOPointSetFilterType;
SOPointSetFilterType::Pointer SOPointSetFilter = 		  		
SOPointSetFilterType::New();
    SOPointSetFilter->SetInput( MySpatialObject);
    SOPointSetFilter->Update();

   // PointSet
    typedef itk::PointSet<float, 3 >     PointSetType;
    PointSetType::Pointer      fixedPointSet =PointSetType::New();
    fixedPointSet = SOPointSetFilter->GetOutput();

   // set PointData
    typedef PointSetType::PointDataContainer   PointDataContainer;
    PointDataContainer::Pointer    pointData =
			fixedPointSet->GetPointData();

   // iterator
    typedef PointDataContainer::Iterator       PointDataIterator;
    PointDataIterator  PDIterator = pointData->Begin();
    PointDataIterator  end        = pointData->End();

// a point
    typedef PointSetType::PointType PointType;
    PointType pp;

// id point
    PointSetType::PointIdentifier id = 0;
    PointSetType::PixelType value;

  // add elements to pointdata vector
    while( PDIterator != end )
    {
      pointData->InsertElement( id , 4000);
      id++;
      ++PDIterator;
    }

   // set pointdata
    fixedPointSet->SetPointData( pointData );

    //print
    fixedPointSet->GetPointData(5, & value);// get value five
    fixedPointSet->GetPoint(5, & pp );      // get point five
    cout<<"POINTSET data before update : "<<pp<< " "<<value<<std::endl;

     fixedPointSet->Update();

    fixedPointSet->GetPointData(5, & value);
    fixedPointSet->GetPoint(5, & pp );
    cout<<"POINTSET data after update : "<<pp<< " "<<value<<std::endl;

This code return :
POINTSET data before update : [ 5 , 40 , 155]  4000
POINTSET data after update :    [ 5 , 40 , 155]  0

Why after invoke Update() my point data is deleted ? How can I solve
this problem?

thanks
Flavio

P.S: I use itk 3.6










More information about the Insight-users mailing list