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

Prefer cxx modern names directly #4703

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/itk_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ mv
myhistogram
myreferenceimage
mx
natively
nbOfDirections
nbOfPixels
ncodewords
Expand Down
3 changes: 0 additions & 3 deletions CMake/ITKConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ set(ITK_VERSION_MAJOR "@ITK_VERSION_MAJOR@")
set(ITK_VERSION_MINOR "@ITK_VERSION_MINOR@")
set(ITK_VERSION_PATCH "@ITK_VERSION_PATCH@")

# If ITK was built with version 4 compatibility features.
set(ITKV4_COMPATIBILITY "@ITKV4_COMPATIBILITY@")

# Remove all legacy code completely.
set(ITK_LEGACY_REMOVE "@ITK_LEGACY_REMOVE@")

Expand Down
16 changes: 6 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,16 @@ cmake_dependent_option(
OFF
"NOT ITK_LEGACY_REMOVE"
OFF)
# The disabling of legacy code, and the ITKv4 compatibility option can not both be
# requested. If removal of legacy code is requested, then ITKV4_COMPATIBILITY must
# be off.
cmake_dependent_option(
ITKV4_COMPATIBILITY
"Enable LEGACY compatibility with ITK4.x when possible."
OFF
"NOT ITK_LEGACY_REMOVE"
OFF)

mark_as_advanced(
ITK_LEGACY_SILENT
ITK_LEGACY_REMOVE
ITK_FUTURE_LEGACY_REMOVE
ITKV4_COMPATIBILITY)
)

if(ITKV4_COMPATIBILITY)
message(FATAL_ERROR "ITKV4_COMPATIBILITY is removed starting in ITK version 4.0, this option is no longer valid.")
endif()

if(ITKV3_COMPATIBILITY)
message(FATAL_ERROR "ITKV3_COMPATIBILITY is removed starting in ITK version 5.0, this option is no longer valid.")
Expand Down
16 changes: 16 additions & 0 deletions Documentation/docs/migration_guides/itk_6_migration_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,19 @@ re-flagged as `ITK_LEGACY_REMOVE`. There have been some other
deprecations and API changes. The new behavior is activated by setting
`ITK_LEGACY_REMOVE` to `ON`. By default, compatibility with v5 is retained
(`ITK_LEGACY_REMOVE=OFF`).

Remove support for ITKv4 interfaces
-----------------------------------

ITKV4_COMPATIBILITY is no longer a supported option.

Require modern C++ language feature use
---------------------------------------

Many backward compatible/ forward enabling compiler features are now required to be used.

* `ITKv5_CONST` must be replaced with `const`
* `ITK_ITERATOR_VIRTUAL` must be replaced with `virtual`
* `ITK_ITERATOR_OVERRIDE` must be replaced with `override`
* `ITK_ITERATOR_FINAL` must be replaced with `final`
* `ITK_DELETE_FUNCTION` must be replaced with `delete`
14 changes: 0 additions & 14 deletions Modules/Compatibility/Deprecated/include/itkImageTransformer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,6 @@ ImageTransformer<TInputImage>::ThreaderCallback(void * arg)
if (threadId < total)
{
str->Filter->ThreadedGenerateData(splitRegion, threadId);
#if defined(ITKV4_COMPATIBILITY)
if (str->Filter->GetAbortGenerateData())
{
std::string msg;
ProcessAborted e(__FILE__, __LINE__);
msg += "Object " + std::string(str->Filter->GetNameOfClass()) + ": AbortGenerateData was set!";
e.SetDescription(msg);
throw e;
}
else if (str->Filter->GetProgress() == 0.0f) // progress was not set after at least the first chunk finished
{
str->Filter->UpdateProgress(static_cast<float>(threadId + 1) / total); // this will be the only progress update
}
#endif
}
// else
// {
Expand Down
3 changes: 0 additions & 3 deletions Modules/Compatibility/Deprecated/itk-module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ set(DOCUMENTATION "This is a collection of classes that are intended to be
removed from the toolkit.")

set(ITKDeprecatedOnByDefault EXCLUDE_FROM_DEFAULT)
if(ITKV4_COMPATIBILITY)
set(ITKDeprecatedOnByDefault "")
endif()

itk_module(
ITKDeprecated
Expand Down
17 changes: 0 additions & 17 deletions Modules/Core/Common/include/itkArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,12 @@ class ITK_TEMPLATE_EXPORT Array : public vnl_vector<TValue>
* memory when this object is destroyed. */
Array(ValueType * datain, SizeValueType sz, bool LetArrayManageMemory = false);

#if defined(ITK_LEGACY_REMOVE)
/** Constructor that initializes array with contents from a user supplied
* const buffer. The pointer to the buffer and the length is specified. By default,
* the array does a deep copy of the const pointer data, so the array class also
* manages memory. */
Array(const ValueType * datain, SizeValueType sz);

#else // defined ( ITK_LEGACY_REMOVE )
/** Constructor that initializes array with contents from a user supplied
* buffer. The pointer to the buffer and the length is specified. The array
* does a deep copy of the const pointer data, so the array class also
* manages memory. The 3rd argument is only for backward compatibility. */
Array(const ValueType * datain, SizeValueType sz, bool LetArrayManageMemory = false);
#endif

/** Constructor to initialize an array from another of any data type */
template <typename TArrayValue>
Array(const Array<TArrayValue> & r)
Expand Down Expand Up @@ -187,14 +178,6 @@ class ITK_TEMPLATE_EXPORT Array : public vnl_vector<TValue>
* means that subclasses cannot allocate memory. */
~Array() override;

#if !defined(ITK_LEGACY_REMOVE)
void
swap(Array & other)
{
this->Swap(other);
}
#endif

void
Swap(Array & other)
{
Expand Down
12 changes: 0 additions & 12 deletions Modules/Core/Common/include/itkArray.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,13 @@ Array<TValue>::Array(ValueType * datain, SizeValueType sz, bool LetArrayManageMe
vnl_vector<TValue>::num_elmts = sz;
}

#if defined(ITK_LEGACY_REMOVE)
template <typename TValue>
Array<TValue>::Array(const ValueType * datain, SizeValueType sz)
: vnl_vector<TValue>(datain, sz)
// The vnl vector copy constructor creates new memory
// no matter the setting of let array manage memory of rhs
{}

#else // defined ( ITK_LEGACY_REMOVE )
template <typename TValue>
Array<TValue>::Array(const ValueType * datain, SizeValueType sz, bool /* LetArrayManageMemory */)
: /* NOTE: The 3rd argument "LetArrayManageMemory, was never valid to use, but is
* preserved to maintain backwards compatibility*/
vnl_vector<TValue>(datain, sz)
// The vnl vector copy constructor creates new memory
// no matter the setting of let array manage memory of rhs
{}
#endif

template <typename TValue>
Array<TValue>::~Array()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction
virtual void
Evaluate(const ContinuousIndexType & index, WeightsType & weights, IndexType & startIndex) const;

#if !defined(ITK_LEGACY_REMOVE)
/** Get support region size. */
itkLegacyMacro(SizeType GetSupportSize() const) { return Self::SupportSize; };

/** Get number of weights. */
itkLegacyMacro(unsigned int GetNumberOfWeights() const) { return Self::NumberOfWeights; }
#endif

protected:
BSplineInterpolationWeightFunction() = default;
~BSplineInterpolationWeightFunction() override = default;
Expand Down
9 changes: 3 additions & 6 deletions Modules/Core/Common/include/itkBoundingBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,9 @@ class ITK_TEMPLATE_EXPORT BoundingBox : public Object

private:
PointsContainerConstPointer m_PointsContainer{};
#if !defined(ITK_LEGACY_REMOVE)
PointsContainerPointer m_CornersContainer{ PointsContainer::New() };
#endif
mutable BoundsArrayType m_Bounds{};
mutable TimeStamp m_BoundsMTime{}; // The last time the bounds
// were computed.
mutable BoundsArrayType m_Bounds{};
mutable TimeStamp m_BoundsMTime{}; // The last time the bounds
// were computed.
};
} // end namespace itk

Expand Down
37 changes: 0 additions & 37 deletions Modules/Core/Common/include/itkBoundingBox.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,6 @@ BoundingBox<TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer>::Com
return result;
}

#if !defined(ITK_LEGACY_REMOVE)
/** Compute and get the corners of the bounding box */
template <typename TPointIdentifier, unsigned int VPointDimension, typename TCoordRep, typename TPointsContainer>
auto
BoundingBox<TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer>::GetCorners() -> const PointsContainer *
{
m_CornersContainer->clear();
m_CornersContainer->Reserve(NumberOfCorners);

SizeValueType index = 0;
for (const PointType & pnt : this->ComputeCorners())
{
m_CornersContainer->SetElement(index++, pnt);
}

return m_CornersContainer.GetPointer();
}
#endif


template <typename TPointIdentifier, unsigned int VPointDimension, typename TCoordRep, typename TPointsContainer>
bool
BoundingBox<TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer>::ComputeBoundingBox() const
Expand Down Expand Up @@ -344,23 +324,6 @@ BoundingBox<TPointIdentifier, VPointDimension, TCoordRep, TPointsContainer>::Dee
// Connect the same points container into the clone
clone->SetPoints(this->m_PointsContainer);

#if !defined(ITK_LEGACY_REMOVE)
// Copy the corners into the clone.
clone->m_CornersContainer->clear();

PointsContainerConstIterator itr = this->m_CornersContainer->Begin();
PointsContainerConstIterator end = this->m_CornersContainer->End();

clone->m_CornersContainer->Reserve(this->m_CornersContainer->Size());
PointsContainerIterator dest = clone->m_CornersContainer->Begin();

while (itr != end)
{
dest.Value() = itr.Value();
++itr;
}
#endif

// Copy the bounds into the clone
for (unsigned int i = 0; i < 2 * PointDimension; ++i)
{
Expand Down
16 changes: 0 additions & 16 deletions Modules/Core/Common/include/itkCellInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,22 +472,6 @@ class ITK_TEMPLATE_EXPORT CellInterface
/** Get the geometric position of a point. */
// bool GetPointPosition(PointsContainer*, int localId, Point*)=0;

#if !defined(ITK_LEGACY_REMOVE)
/** Expose old names for backwards compatibility*/
static constexpr CommonEnums::CellGeometry VERTEX_CELL = CommonEnums::CellGeometry::VERTEX_CELL;
static constexpr CommonEnums::CellGeometry LINE_CELL = CommonEnums::CellGeometry::LINE_CELL;
static constexpr CommonEnums::CellGeometry TRIANGLE_CELL = CommonEnums::CellGeometry::TRIANGLE_CELL;
static constexpr CommonEnums::CellGeometry QUADRILATERAL_CELL = CommonEnums::CellGeometry::QUADRILATERAL_CELL;
static constexpr CommonEnums::CellGeometry POLYGON_CELL = CommonEnums::CellGeometry::POLYGON_CELL;
static constexpr CommonEnums::CellGeometry TETRAHEDRON_CELL = CommonEnums::CellGeometry::TETRAHEDRON_CELL;
static constexpr CommonEnums::CellGeometry HEXAHEDRON_CELL = CommonEnums::CellGeometry::HEXAHEDRON_CELL;
static constexpr CommonEnums::CellGeometry QUADRATIC_EDGE_CELL = CommonEnums::CellGeometry::QUADRATIC_EDGE_CELL;
static constexpr CommonEnums::CellGeometry QUADRATIC_TRIANGLE_CELL =
CommonEnums::CellGeometry::QUADRATIC_TRIANGLE_CELL;
static constexpr CommonEnums::CellGeometry LAST_ITK_CELL = CommonEnums::CellGeometry::LAST_ITK_CELL;
static constexpr CommonEnums::CellGeometry MAX_ITK_CELLS = CommonEnums::CellGeometry::MAX_ITK_CELLS;
#endif

protected:
/** Store the set of cells using this boundary. */
UsingCellsContainer m_UsingCells{};
Expand Down
9 changes: 0 additions & 9 deletions Modules/Core/Common/include/itkCommonEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,6 @@ using IOFileModeEnum = CommonEnums::IOFileMode;
using IOByteOrderEnum = CommonEnums::IOByteOrder;
using CellGeometryEnum = CommonEnums::CellGeometry;

#if !defined(ITK_LEGACY_REMOVE)
/** Expose old names for backwards compatibility*/
using IOPixelType = CommonEnums::IOPixel;
using IOComponentType = CommonEnums::IOComponent;
using IOFileType = CommonEnums::IOFile;
using IOFileModeType = CommonEnums::IOFileMode;
using IOByteOrderType = CommonEnums::IOByteOrder;
using CellGeometryType = CommonEnums::CellGeometry;
#endif
// Define how to print enumeration
extern ITKCommon_EXPORT std::ostream &
operator<<(std::ostream & out, IOPixelEnum value);
Expand Down
Loading
Loading