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.
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
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
/** 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();
}