# AffineGeometryFrame class is removed as part of migration from v4 to v5

**URL:** https://discourse.itk.org/t/affinegeometryframe-class-is-removed-as-part-of-migration-from-v4-to-v5/4433
**Category:** Engineering
**Created:** [September 20, 2021, 11:32am UTC](https://discourse.itk.org/t/affinegeometryframe-class-is-removed-as-part-of-migration-from-v4-to-v5/4433 "2021-09-20T11:32:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mahesh\_Timmanagoudar](https://discourse.itk.org/user_avatar/discourse.itk.org/mahesh_timmanagoudar/32/2170_2.png) [@Mahesh\_Timmanagoudar](https://discourse.itk.org/u/Mahesh_Timmanagoudar)
#### Post date: [September 20, 2021, 11:32am UTC](https://discourse.itk.org/t/affinegeometryframe-class-is-removed-as-part-of-migration-from-v4-to-v5/4433/1 "2021-09-20T11:32:07Z")

</div>

I need that transform on its own. How can i make use of AffineGeometryFrame class functionalities in new ITK version (v5).

I have debugged below things.

```cpp
typedef itk::TubeSpatialObject< Dimension > TubeType;
typename TubeType::Pointer curTube = dynamic_cast<TubeType*>(tubeList->begin()->GetPointer());

```

When we debug the code `curTube->GetIndexToWorldTransform()->TransformPoint` , m\_Matrix is coming as {[1,0,0][0,1,0],[0,0,1]} and m\_Offset=0 , due to this startPoint and a targetPoint are same.

New ITK library AffineGeometryFrame class removed. SetMatrix and SetOffset API’s were removed as part of migration from v4 to v5.20

Code Snippet:

ITK old Code: C:\W\S-dbg\S-bld\ITKv4\Modules\Core\SpatialObjects\include\itkSpatialObject.hxx

```cpp
template< unsigned int TDimension >
void
SpatialObject< TDimension >
::ComputeObjectToWorldTransform()
{
  // The ObjectToParentTransform is the combination of the
  // ObjectToNodeTransform and the NodeToParentNodeTransform
  m_ObjectToParentTransform->SetIdentity();
  m_ObjectToParentTransform->SetCenter(
    m_AffineGeometryFrame->GetObjectToNodeTransform()->GetCenter() );
  m_ObjectToParentTransform->Compose(
    m_AffineGeometryFrame->GetObjectToNodeTransform(), false);
  m_ObjectToParentTransform->Compose(
    static_cast< TreeNodeType * >(
      m_TreeNode.GetPointer() )->GetNodeToParentNodeTransform(), false);

  m_ObjectToWorldTransform->SetCenter(
    m_AffineGeometryFrame->GetObjectToNodeTransform()->GetCenter() );
  m_ObjectToWorldTransform->SetMatrix(
    m_AffineGeometryFrame->GetObjectToNodeTransform()->GetMatrix() );
  m_ObjectToWorldTransform->SetOffset(
    m_AffineGeometryFrame->GetObjectToNodeTransform()->GetOffset() );

  m_IndexToWorldTransform->SetCenter(
    m_AffineGeometryFrame->GetIndexToObjectTransform()->GetCenter() );
  m_IndexToWorldTransform->SetMatrix(
    m_AffineGeometryFrame->GetIndexToObjectTransform()->GetMatrix() );
  m_IndexToWorldTransform->SetOffset(
    m_AffineGeometryFrame->GetIndexToObjectTransform()->GetOffset() );

  static_cast< TreeNodeType * >( m_TreeNode.GetPointer() )
  ->ComputeNodeToWorldTransform();
  m_ObjectToWorldTransform->Compose(
    static_cast< TreeNodeType * >(
      m_TreeNode.GetPointer() )->GetNodeToWorldTransform(), false);

  m_IndexToWorldTransform->Compose(this->GetObjectToWorldTransform(), false);

  // Propagate the changes to the children
  typedef typename TreeNodeType::ChildrenListType TreeChildrenListType;
  TreeChildrenListType *children = m_TreeNode->GetChildren();
  typename TreeChildrenListType::const_iterator it = children->begin();
  typename TreeChildrenListType::const_iterator itEnd = children->end();

  while ( it != itEnd )
    {
    ( *it )->Get()->ComputeObjectToWorldTransform();
    it++;
    }
  // handle internal inverse
  if(!this->GetIndexToWorldTransform()->GetInverse( const_cast< TransformType *>( this->GetInternalInverseTransform() ) ))
    {
    this->m_InternalInverseTransform = ITK_NULLPTR;
    }
  delete children;
}

```

ITK new code: C:\W\S-dbg\S-bld\ITK\Modules\Core\SpatialObjects\include\itkSpatialObject.hxx

```cpp
/** Compute the Global Transform */
template <unsigned int TDimension>
void
SpatialObject<TDimension>::ProtectedComputeObjectToWorldTransform()
{
  m_ObjectToWorldTransform->SetFixedParameters(this->GetObjectToParentTransform()->GetFixedParameters());
  m_ObjectToWorldTransform->SetParameters(this->GetObjectToParentTransform()->GetParameters());

  if (this->HasParent())
  {
    m_ObjectToWorldTransform->Compose(this->GetParent()->GetObjectToWorldTransform(), false);
  }

  if (!m_ObjectToWorldTransform->GetInverse(m_ObjectToWorldTransformInverse))
  {
    itkExceptionMacro(<< "Transform must be invertible.");
  }

  // Propagate the changes to the children
  auto it = m_ChildrenList.begin();
  while (it != m_ChildrenList.end())
  {
    (*it)->Update();
    it++;
  }

  this->Modified();
}

```

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 20, 2021, 1:34pm UTC](https://discourse.itk.org/t/affinegeometryframe-class-is-removed-as-part-of-migration-from-v4-to-v5/4433/2 "2021-09-20T13:34:53Z")

</div>

> [@Mahesh\_Timmanagoudar](#):
>
> I need that transform on its own

Why? What are you trying to accomplish? Did you take a look at the [spatial object refactoring section in the migration guide](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Documentation/ITK5MigrationGuide.md#spatial-objects-refactoring)?

---

<div class="post-metadata">

### Author: ![Mahesh\_Timmanagoudar](https://discourse.itk.org/user_avatar/discourse.itk.org/mahesh_timmanagoudar/32/2170_2.png) [@Mahesh\_Timmanagoudar](https://discourse.itk.org/u/Mahesh_Timmanagoudar)
#### Post date: [September 20, 2021, 3:14pm UTC](https://discourse.itk.org/t/affinegeometryframe-class-is-removed-as-part-of-migration-from-v4-to-v5/4433/3 "2021-09-20T15:14:39Z")

</div>

Because target point is taking same value of start point value for branches.

I am trying to accomplish the below.

• There is a Start Point and a Target(End) Point. The centerline is computed so as to pass through the center of the part from one point to the other.  
• Along with the centerline, the Centerline.tre tube file is also created. This works fine for us.  
• But when it comes to the Branch Vessels, there is a Start Point but there is no Target Point (though optionally there can be additional guide points specified along the center of the vessel). Instead of the Target(End) Point, the Branch Vessel minimal path code use the Centerline.tre tube as a Target(End) that the centerline should intersect. So the centerline is computed and grows towards the part but stops once it intersects the tube. I believe this is how old ITK code was working.  
• Parent transfer(Its in itkSpatialObject.hxx class) works fine with the part. But When same thing is doing with branch vessels. Its generating the target(End) point same as start point. I think Its needs local transfer (which is there in itkAffineGeometryFrame.hxx class).  
• Since itkAffineGeometryFrame.hxx is deprecated in new ITK (v5). Which leads to probelm it seems. So branchcenterline.tre tube file is not generating properly. Please correct me if anything is wrong.

Yes I have gone through the [spatial object refactoring section in the migration guide](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Documentation/ITK5MigrationGuide.md#spatial-objects-refactoring).

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 20, 2021, 3:24pm UTC](https://discourse.itk.org/t/affinegeometryframe-class-is-removed-as-part-of-migration-from-v4-to-v5/4433/4 "2021-09-20T15:24:24Z")

</div>

@Stephen_Aylward do you have some suggestions?
