-
Notifications
You must be signed in to change notification settings - Fork 145
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
COMP: fix incorrect casts from scalar or vector to points #479
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,8 +82,7 @@ main(int argc, char * argv[]) | |
spacing[1] = 2.; | ||
spacing[2] = 1.; | ||
reader->SetSpacing(spacing); | ||
ReaderType::OutputImagePointType origin(0.); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SimonRit This particular line of code still compiles with Of course, if the line of code isn't useful anymore, it's fine to me to have it removed anyway. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, line below was failing but not this one. |
||
reader->SetOrigin(0.); | ||
reader->SetOrigin(itk::MakePoint(0., 0., 0.)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the record, the following should also work fine, assuming the right
The coordinates of a point are properly zero-initialized by the expression But of course, |
||
ReaderType::OutputImageDirectionType direction; | ||
direction.SetIdentity(); | ||
reader->SetDirection(direction); | ||
|
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.
Thank you @SimonRit I hope you agree that InsightSoftwareConsortium/ITK#3237, declaring those
Point(v)
constructorsexplicit
does really help to make ITK user code better. 😃 In this particular case, callingitk::MakePoint
certainly looks more appropriate than callingitk::MakeVector
👍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.
Honestly, it's not obvious to me why an
itk::Point
is not anitk::Vector
. I have often fought against itk when using vectors, matrices and points and I'm pretty sure that there are many more places where RTK code could be improved... As far as I know, this is not well documented, but I might have missed a good explanation.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.
@SimonRit Well, I guess that itk::Point and itk::Vector are just like in https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/geometry/points-vectors-and-normals (but then in an N-dimensional space):
Right?
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.
Yes but from the same source
Three-dimensional points and vectors are of course similar in that they are both represented by the aforementioned tuple notation.
Which is why I would not have used two different types.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.
Points and vectors are similar, but they are not the same. At least, I find it helpful to distinguish between them, by using different types for them. Even though I did not invent
itk::Point
anditk::Vector
myself 😃