-
-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Provide GetSpacing/GetOrigin calls that wrap for python #4775
ENH: Provide GetSpacing/GetOrigin calls that wrap for python #4775
Conversation
{ | ||
for (unsigned int i = 0; i < OutputImageDimension; ++i) | ||
{ | ||
m_SpacingVector[i] = m_Spacing[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this assignment is done in the getter, what is the point of also having it as an ivar? This could be a local variable in the getter instead. Same remark for the other one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to avoid returning a reference to a local var and to make the minimal changes to the code to preserve backward compatibility. What do you recommend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, so we can't return spacing by value? If so, this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - this is still using a very old (the original) ITK API where spacing was double * - which doesn't wrap for python, hence this PR. For ITK v6.0, I'd like to do a major update to SpatialObjects to follow ITK's current API, but it will break backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add an extra ivar, we might want to print it in PrintSelf
method.
Great point - will amend this commit! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
👍 for making breaking changes to improve the API with ITK 6
itk::SpatialObjectToImageFilter provided GetSpacing() and GetOrigin() calls that returned double * objects. That return type is not well supported by SWIG for python wrapping. Herein we provide GetSpacingVector() and GetOriginPoint() functions that return VectorType and PointType objects from the itk::Image class definition which are nicely wrapped by SWIG for python.
66fb443
to
b39f3f0
Compare
itk::SpatialObjectToImageFilter provided GetSpacing() and GetOrigin() calls that returned double * objects. That return type is not well supported by SWIG for python wrapping.
Herein we provide GetSpacingVector() and GetOriginPoint() functions that return VectorType and PointType objects from the itk::Image class definition which are nicely wrapped by SWIG for python.
See: https://discourse.itk.org/t/image-spacing-value-interactions-in-itk-python-wrapping/6707