Skip to content
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

Make the index type of VectorContainer itk::SizeValueType by default #4856

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

N-Dekker
Copy link
Contributor

For most use cases, it appears that the index type of itk::VectorContainer should just be itk::SizeValueType (or itk::IdentifierType, but that's just an alias of itk::SizeValueType).

This pull request allows users to write itk::VectorContainer<ElementType> as a shorthand for itk::VectorContainer<itk::SizeValueType, ElementType>.

By default, assume `ElementIdentifier = SizeValueType`, for an
`itk::VectorContainer<ElementType>`.

Conceptually like:

    template <typename TElementIdentifier = SizeValueType, typename TElement>
    class VectorContainer;
The index type (`ElementIdentifier`) of `itk::VectorContainer` is already
`itk::SizeValueType` by default.
The index type (`ElementIdentifier`) of `itk::VectorContainer` is already
`itk::SizeValueType` by default, and `itk::IdentifierType` is just an alias of
`itk::SizeValueType`.
@github-actions github-actions bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module labels Sep 20, 2024
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

Mostly looks good.

itkLegacyMacro(ArrayType GetRadius() const) { return this->GetRadiusInObjectSpace(); }

itkLegacyMacro(void SetRadiiInObjectSpace(ArrayType radii)) { this->SetRadiusInObjectSpace(radii); }
itkLegacyMacro(void SetRadius(double radius))
Copy link
Member

Choose a reason for hiding this comment

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

This set of changes seems unrelated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Honestly I have no idea why clang-format decided to make those unrelated changes 🤷

@@ -96,7 +96,10 @@ class ITK_TEMPLATE_EXPORT MeshSpatialObject : public SpatialObject<TMesh::PointD

#if !defined(ITK_LEGACY_REMOVE)
/** \deprecated Return the type of pixel used */
itkLegacyMacro(const char * GetPixelTypeName()) { return m_PixelType.c_str(); }
itkLegacyMacro(const char * GetPixelTypeName())
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated. Preferably group with the other into a separate commit.

@@ -85,7 +85,10 @@ class ITK_TEMPLATE_EXPORT TubeSpatialObject : public PointBasedSpatialObject<TDi

#if !defined(ITK_LEGACY_REMOVE)
/** Compute the tangents and normals of the centerline of the tube. */
itkLegacyMacro(bool ComputeTangentAndNormals()) { return ComputeTangentsAndNormals(); }
itkLegacyMacro(bool ComputeTangentAndNormals())
Copy link
Member

Choose a reason for hiding this comment

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

Another unrelated change.

Comment on lines -47 to +54
template <typename TElementIdentifier, typename TElement>
template <typename T1, typename T2 = void>
class ITK_TEMPLATE_EXPORT VectorContainer
: public Object
, private std::vector<TElement>
, private std::vector<std::conditional_t<std::is_void_v<T2>, T1, T2>>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this "trick" does not work as smoothly as I was hoping for.... The compiler still considers VectorContainer<ElementType> and VectorContainer<SizeValueType, ElementType> to be different types. Which disallows interchanging one with the other. (For example, assigning a pointer to another.) Not really convenient 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:IO Issues affecting the IO module area:Registration Issues affecting the Registration module type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants