Skip to content

STYLE: Change vector to point when possible#841

Merged
SimonRit merged 2 commits intoRTKConsortium:mainfrom
axel-grc:PointType
Apr 28, 2026
Merged

STYLE: Change vector to point when possible#841
SimonRit merged 2 commits intoRTKConsortium:mainfrom
axel-grc:PointType

Conversation

@axel-grc
Copy link
Copy Markdown
Collaborator

@axel-grc axel-grc commented Oct 28, 2025

Close #820

Copy link
Copy Markdown
Collaborator

@SimonRit SimonRit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add a note to the transition page

Corner2[2] = this->GetInput(0)->GetOrigin()[2] +
this->GetInput(0)->GetLargestPossibleRegion().GetSize()[2] * this->GetInput(0)->GetSpacing()[2];
itk::Point<double, 3> Corner1, Corner2;
Corner1 = itk::MakePoint(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not seem necessary?

@SimonRit SimonRit requested a review from acoussat November 7, 2025 08:52
@SimonRit
Copy link
Copy Markdown
Collaborator

SimonRit commented Nov 7, 2025

@acoussat Can you please check that this does not break your wrapping of ConvexShape?

@acoussat
Copy link
Copy Markdown
Collaborator

According to the CI, test/rtkOutputArgumentWrapping.py::test_IsIntersectedByRay succeeds so it seems that the wrapping still works. Should I do more extensive testing, or is it enough?

@SimonRit
Copy link
Copy Markdown
Collaborator

I guess not, thanks!

@axel-grc
Copy link
Copy Markdown
Collaborator Author

We should document the change of API in migration guide.

@axel-grc axel-grc force-pushed the PointType branch 2 times, most recently from ca3c6df to 498fc59 Compare December 18, 2025 15:21
{
typename InputRegionIterator::PointType pixelPosition = itIn->GetPixelPosition();
typename InputRegionIterator::PointType dirVox = -itIn->GetSourceToPixel();
stepMM.Fill(0.);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to fix the failing test that occurred because of pixelPosition that was corrected to stepMM line 422

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change and the one line 422 should be in a separate PR. pixelPosition is used 4 times line 422, why is that? Initializing stepMM to 0 does not seem to be the correct solution to me.

@axel-grc axel-grc force-pushed the PointType branch 2 times, most recently from 7300a03 to bdd5a48 Compare December 19, 2025 13:15
@SimonRit SimonRit added this to the RTK 3.0 milestone Jan 7, 2026
@axel-grc axel-grc requested a review from SimonRit April 23, 2026 07:24
Copy link
Copy Markdown
Collaborator

@SimonRit SimonRit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Minor suggestions except the stepMM change which shouldn't be in this PR IMO.

Comment thread test/rtkquadrictest.cxx Outdated
cylinder->SetJ(-1.);
rtk::QuadricShape::ScalarType infDist, supDist;
auto rayOrigin = itk::MakeVector(52.43581919641932, -0.5, 998.6243011589495);
rtk::QuadricShape::ScalarType nearDist, farDist;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These names should not change, most likely an erroneous rebase on main.

Comment thread test/rtkadmmtotalvariationtest.cxx Outdated

rei = REIType::New();
REIType::VectorType semiprincipalaxis, center;
REIType::VectorType semiprincipalaxis;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two can now be initialized with MakePoint and MakeVector instead of Fill

Comment thread src/rtkForbildPhantomFileReader.cxx Outdated
}
q->Rotate(rot);
q->Translate(m_Center + rot * spatialOffset);
VectorType translation = m_Center.GetVectorFromOrigin() + rot * spatialOffset.GetVectorFromOrigin();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to change the type of spatialOffset to Vector here? Then I think you can remove the two .GetVectorFromOrigin().

Comment thread src/rtkBoxShape.cxx Outdated
m_BoxMin -= img->GetDirection() * img->GetSpacing() * 0.5;

// BoxShape corner 2
VectorType max;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really an extra variable here?

Comment thread documentation/docs/rtk_3_migration_guide.md
{
typename InputRegionIterator::PointType pixelPosition = itIn->GetPixelPosition();
typename InputRegionIterator::PointType dirVox = -itIn->GetSourceToPixel();
stepMM.Fill(0.);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change and the one line 422 should be in a separate PR. pixelPosition is used 4 times line 422, why is that? Initializing stepMM to 0 does not seem to be the correct solution to me.

// orthogonal to the plane defined by the detector source direction
// and the secon detector vector
PointType v;
VectorType v;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use MakeVector here?

Comment thread include/rtkIterativeFDKConeBeamReconstructionFilter.hxx
Comment thread src/rtkForbildPhantomFileReader.cxx Outdated
}
auto q = QuadricShape::New();
q->SetEllipsoid(VectorType(0.), axes);
q->SetEllipsoid(itk::MakePoint(0., 0., 0.), axes);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does {} work here? If yes, apply to all 0 init please.

@SimonRit
Copy link
Copy Markdown
Collaborator

Interestingly, I found a commit from 15 years ago going in the other direction. I still think it's better to stick to ITK's semantic and I believe itk::Point has been improved since.

Replace variables that were declared then initialized with .Fill(0) by using uniform initialization ({}) where safe.
@SimonRit SimonRit merged commit 6f374fd into RTKConsortium:main Apr 28, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PointType in ConvexShape should not be a Vector but a Point

3 participants