Skip to content

Commit

Permalink
STYLE: Remove initial << insertion from itkWarningMacro(<< " calls
Browse files Browse the repository at this point in the history
Follow-up to pull request #4057
commit 89beb04
"STYLE: Remove initial `<<` insertion from `itkExceptionMacro(<< "` calls"

Aims to shorten the code a little bit, and improve consistency. The code base
already had more than 80 `itkWarningMacro` calls that passed a literal string as
first argument directly, without having `<<` at its left side.
  • Loading branch information
N-Dekker authored and dzenanz committed Jun 2, 2023
1 parent b52f423 commit c6fedbd
Show file tree
Hide file tree
Showing 60 changed files with 129 additions and 129 deletions.
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkImageSink.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ImageSink<TInputImage>::GetInput(unsigned int idx) const -> const InputImageType

if (in == nullptr && this->ProcessObject::GetInput(idx) != nullptr)
{
itkWarningMacro(<< "Unable to convert input number " << idx << " to type " << typeid(InputImageType).name());
itkWarningMacro("Unable to convert input number " << idx << " to type " << typeid(InputImageType).name());
}
return in;
}
Expand All @@ -75,7 +75,7 @@ ImageSink<TInputImage>::GetInput(const DataObjectIdentifierType & key) const ->

if (in == nullptr && this->ProcessObject::GetInput(key) != nullptr)
{
itkWarningMacro(<< "Unable to convert input \"" << key << "\" to type " << typeid(InputImageType).name());
itkWarningMacro("Unable to convert input \"" << key << "\" to type " << typeid(InputImageType).name());
}
return in;
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageSource.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ImageSource<TOutputImage>::GetOutput(unsigned int idx) -> OutputImageType *

if (out == nullptr && this->ProcessObject::GetOutput(idx) != nullptr)
{
itkWarningMacro(<< "Unable to convert output number " << idx << " to type " << typeid(OutputImageType).name());
itkWarningMacro("Unable to convert output number " << idx << " to type " << typeid(OutputImageType).name());
}
return out;
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkImageToImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ImageToImageFilter<TInputImage, TOutputImage>::GetInput(unsigned int idx) const

if (in == nullptr && this->ProcessObject::GetInput(idx) != nullptr)
{
itkWarningMacro(<< "Unable to convert input number " << idx << " to type " << typeid(InputImageType).name());
itkWarningMacro("Unable to convert input number " << idx << " to type " << typeid(InputImageType).name());
}
return in;
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkLineConstIterator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ LineConstIterator<TImage>::operator++()
// The new index is outside the acceptable region. We can iterate no
// farther, call this the end. NOTE THAT INPUT IS STILL INCREMENTED.
m_IsAtEnd = true;
itkWarningMacro(<< "Line left region; unable to finish tracing it");
itkWarningMacro("Line left region; unable to finish tracing it");
}
}
} // end namespace itk
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ OutputWindowDisplayDebugText(const char *);

/** This macro is used to print warning information (i.e., unusual circumstance
* but not necessarily fatal.) Example usage looks like:
* itkWarningMacro(<< "this is warning info" << this->SomeVariable); */
* itkWarningMacro("this is warning info" << this->SomeVariable); */
#define itkWarningMacro(x) \
do \
{ \
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkProcessObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ ProcessObject::AddRequiredInputName(const DataObjectIdentifierType & name, DataO

if (!m_RequiredInputNames.insert(name).second)
{
itkWarningMacro(<< "Input already \"" << name << "\" already required!");
itkWarningMacro("Input already \"" << name << "\" already required!");
// Input already required, but it is not added as indexed input?
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Mesh/include/itkMeshSource.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ template <typename TOutputMesh>
void
MeshSource<TOutputMesh>::SetOutput(OutputMeshType * output)
{
itkWarningMacro(<< "SetOutput(): This method is slated to be removed from ITK. Please use GraftOutput() in possible "
"combination with DisconnectPipeline() instead.");
itkWarningMacro("SetOutput(): This method is slated to be removed from ITK. Please use GraftOutput() in possible "
"combination with DisconnectPipeline() instead.");
this->ProcessObject::SetNthOutput(0, output);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ SimplexMeshVolumeCalculator<TInputMesh>::CalculateTriangleVolume(InputPointType
}
else
{
itkWarningMacro(<< "Unpredicted situation...!"
itkWarningMacro("Unpredicted situation...!"
<< "absu: " << absu[0] << ", " << absu[1] << ", " << absu[2]);
return;
}
Expand Down
27 changes: 14 additions & 13 deletions Modules/Core/TestKernel/include/itkPipelineMonitorImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PipelineMonitorImageFilter<TImageType>::VerifyDownStreamFilterExecutedPropagatio
if (m_OutputRequestedRegions.size() != this->GetNumberOfUpdates() ||
m_InputRequestedRegions.size() != this->GetNumberOfUpdates())
{
itkWarningMacro(<< "Down stream filter didn't execute PropagateRequestedRegion well");
itkWarningMacro("Down stream filter didn't execute PropagateRequestedRegion well");
ret = false;
}
return ret;
Expand All @@ -64,8 +64,9 @@ PipelineMonitorImageFilter<TImageType>::VerifyInputFilterExecutedStreaming(int e
{
return true;
}
itkWarningMacro(<< "Streamed pipeline was executed " << this->GetNumberOfUpdates()
<< " times which was not the expected number " << expectedNumber << " of times.");
itkWarningMacro("Streamed pipeline was executed " << this->GetNumberOfUpdates()
<< " times which was not the expected number " << expectedNumber
<< " of times.");
return false;
}

Expand All @@ -77,30 +78,30 @@ PipelineMonitorImageFilter<TImageType>::VerifyInputFilterMatchedUpdateOutputInfo
InputImageConstPointer input = this->GetInput();
if (input->GetSpacing() != m_UpdatedOutputSpacing)
{
itkWarningMacro(<< "The input filter's Spacing does not match UpdateOutputInformation");
itkWarningMacro("The input filter's Spacing does not match UpdateOutputInformation");
return false;
}
if (input->GetOrigin() != m_UpdatedOutputOrigin)
{
itkWarningMacro(<< "The input filter's Origin does not match UpdateOutputInformation");
itkWarningMacro("The input filter's Origin does not match UpdateOutputInformation");
return false;
}
if (input->GetDirection() != m_UpdatedOutputDirection)
{
itkWarningMacro(<< "The input filter's Direction does not match UpdateOutputInformation");
itkWarningMacro("The input filter's Direction does not match UpdateOutputInformation");
return false;
}
if (input->GetLargestPossibleRegion() != m_UpdatedOutputLargestPossibleRegion)
{
itkWarningMacro(<< "The input filter's LargestPossibleRegion does not match UpdateOutputInformation");
itkWarningMacro(<< "input: " << input->GetLargestPossibleRegion()
<< "updated: " << m_UpdatedOutputLargestPossibleRegion);
itkWarningMacro("The input filter's LargestPossibleRegion does not match UpdateOutputInformation");
itkWarningMacro("input: " << input->GetLargestPossibleRegion()
<< "updated: " << m_UpdatedOutputLargestPossibleRegion);
return false;
}
if (!m_UpdatedBufferedRegions.empty() &&
!m_UpdatedOutputLargestPossibleRegion.IsInside(m_UpdatedBufferedRegions.back()))
{
itkWarningMacro(<< "The input filter's BufferedRegion is not contained by LargestPossibleRegion");
itkWarningMacro("The input filter's BufferedRegion is not contained by LargestPossibleRegion");
return false;
}
return true;
Expand All @@ -119,7 +120,7 @@ PipelineMonitorImageFilter<TImageType>::VerifyInputFilterBufferedRequestedRegion
{
if (m_UpdatedBufferedRegions[i] != m_UpdatedRequestedRegions[i])
{
itkWarningMacro(<< "The input filter's updated buffered region was not the requested region");
itkWarningMacro("The input filter's updated buffered region was not the requested region");
ret = false;
}
}
Expand All @@ -143,7 +144,7 @@ PipelineMonitorImageFilter<TImageType>::VerifyInputFilterMatchedRequestedRegions
{
if (m_UpdatedBufferedRegions[--i] != m_InputRequestedRegions[--j])
{
itkWarningMacro(<< "The input filter's updated buffer region was not the region we requested");
itkWarningMacro("The input filter's updated buffer region was not the region we requested");
ret = false;
}
}
Expand All @@ -158,7 +159,7 @@ PipelineMonitorImageFilter<TImageType>::VerifyInputFilterRequestedLargestRegion(
{
if (m_InputRequestedRegions.back() != m_UpdatedOutputLargestPossibleRegion)
{
itkWarningMacro(<< "The input filter didn't set its output request to the largest region");
itkWarningMacro("The input filter didn't set its output request to the largest region");
return false;
}
return true;
Expand Down
16 changes: 8 additions & 8 deletions Modules/Core/Transform/include/itkRigid2DTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ template <typename TParametersValueType>
inline auto
Rigid2DTransform<TParametersValueType>::BackTransform(const OutputPointType & point) const -> InputPointType
{
itkWarningMacro(<< "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
return this->GetInverseMatrix() * (point - this->GetOffset());
}

Expand All @@ -309,8 +309,8 @@ template <typename TParametersValueType>
inline auto
Rigid2DTransform<TParametersValueType>::BackTransform(const OutputVectorType & vect) const -> InputVectorType
{
itkWarningMacro(<< "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
return this->GetInverseMatrix() * vect;
}

Expand All @@ -319,8 +319,8 @@ template <typename TParametersValueType>
inline auto
Rigid2DTransform<TParametersValueType>::BackTransform(const OutputVnlVectorType & vect) const -> InputVnlVectorType
{
itkWarningMacro(<< "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
return this->GetInverseMatrix() * vect;
}

Expand All @@ -330,8 +330,8 @@ inline auto
Rigid2DTransform<TParametersValueType>::BackTransform(const OutputCovariantVectorType & vect) const
-> InputCovariantVectorType
{
itkWarningMacro(<< "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
itkWarningMacro("BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() "
"to generate an inverse transform and then perform the transform using that inverted transform.");
return this->GetMatrix() * vect;
}

Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Transform/include/itkTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ Transform<TParametersValueType, VInputDimension, VOutputDimension>::ApplyToImage

if (!this->IsLinear())
{
itkWarningMacro(<< "ApplyToImageMetadata was invoked with non-linear transform of type: " << this->GetNameOfClass()
<< ". This might produce unexpected results.");
itkWarningMacro("ApplyToImageMetadata was invoked with non-linear transform of type: "
<< this->GetNameOfClass() << ". This might produce unexpected results.");
}

typename Self::Pointer inverse = this->GetInverseTransform();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ AnisotropicDiffusionImageFilter<TInputImage, TOutputImage>::InitializeIteration(
{
// f->SetTimeStep(1.0 / std::pow(2.0,
// static_cast<double>(ImageDimension)));
itkWarningMacro(<< "Anisotropic diffusion unstable time step: " << m_TimeStep << std::endl
itkWarningMacro("Anisotropic diffusion unstable time step: "
<< m_TimeStep << std::endl
<< "Stable time step for this image must be smaller than "
<< minSpacing / std::pow(2.0, static_cast<double>(ImageDimension + 1)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::EnforceConstraints()
{
if (this->GetNoiseModelFidelityWeight() > 0)
{
itkWarningMacro(<< "Noise model is undefined for RIEMANNIAN case, "
itkWarningMacro("Noise model is undefined for RIEMANNIAN case, "
<< "disabling noise model by setting fidelity weight "
<< "to zero.");
this->SetNoiseModelFidelityWeight(0.0);
Expand Down Expand Up @@ -689,7 +689,7 @@ typename PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::ThreadDataSt

if (m_NumIndependentComponents != 1)
{
itkWarningMacro(<< "ThreadedRiemannianMinMax calculation assumes that "
itkWarningMacro("ThreadedRiemannianMinMax calculation assumes that "
<< "there is exactly 1 independent component, but "
<< "num independent components = " << m_NumIndependentComponents << " instead.\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ DiffusionTensor3DReconstructionImageFilter<TReferenceImagePixelType,
// they don't.
if (refOrigin != maskOrigin)
{
itkWarningMacro(<< "Mask origin doesn't match Reference origin "
itkWarningMacro("Mask origin doesn't match Reference origin "
<< "Mask Origin " << maskOrigin << " Ref Origin " << refOrigin);
}
if (refSpacing != maskSpacing)
{
itkWarningMacro(<< "Mask spacing doesn't match Reference spacing "
itkWarningMacro("Mask spacing doesn't match Reference spacing "
<< "Mask Spacing " << maskSpacing << " Ref Spacing " << refSpacing);
}
if (refDirection != maskDirection)
{
itkWarningMacro(<< "Mask direction doesn't match Reference direction "
itkWarningMacro("Mask direction doesn't match Reference direction "
<< "Mask Direction " << maskDirection << " Ref Direction " << refDirection);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ FastChamferDistanceImageFilter<TInputImage, TOutputImage>::FastChamferDistanceIm
m_Weights[--dim] = 0.92644;
break;
default:
itkWarningMacro(<< "Dimension " << ImageDimension << " with Default weights ");
itkWarningMacro("Dimension " << ImageDimension << " with Default weights ");
for (unsigned int i = 1; i <= ImageDimension; ++i)
{
m_Weights[i - 1] = std::sqrt(static_cast<float>(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ IsoContourDistanceImageFilter<TInputImage, TOutputImage>::EnlargeOutputRequested
else
{
// pointer could not be cast to TLevelSet *
itkWarningMacro(<< "itk::IsoContourDistanceImageFilter"
itkWarningMacro("itk::IsoContourDistanceImageFilter"
<< "::EnlargeOutputRequestedRegion cannot cast " << typeid(output).name() << " to "
<< typeid(TOutputImage *).name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ FastMarchingImageFilter<TLevelSet, TSpeedImage>::EnlargeOutputRequestedRegion(Da
else
{
// Pointer could not be cast to TLevelSet *
itkWarningMacro(<< "itk::FastMarchingImageFilter"
itkWarningMacro("itk::FastMarchingImageFilter"
<< "::EnlargeOutputRequestedRegion cannot cast " << typeid(output).name() << " to "
<< typeid(TLevelSet *).name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ FastMarchingImageFilterBase<TInput, TOutput>::EnlargeOutputRequestedRegion(DataO
else
{
// Pointer could not be cast to TLevelSet *
itkWarningMacro(<< "itk::FastMarchingImageFilter"
itkWarningMacro("itk::FastMarchingImageFilter"
<< "::EnlargeOutputRequestedRegion cannot cast " << typeid(output).name() << " to "
<< typeid(OutputImageType *).name());
}
Expand Down Expand Up @@ -416,7 +416,7 @@ FastMarchingImageFilterBase<TInput, TOutput>::CheckTopology(OutputImageType * oI
}
else
{
itkWarningMacro(<< "CheckTopology has not be implemented for Dimension != 2 and != 3."
itkWarningMacro("CheckTopology has not be implemented for Dimension != 2 and != 3."
<< "m_TopologyCheck should be set to Nothing.");
}
}
Expand Down Expand Up @@ -585,7 +585,7 @@ FastMarchingImageFilterBase<TInput, TOutput>::InitializeOutput(OutputImageType *
}
else
{
itkWarningMacro(<< "Topology checking is only valid for level set dimensions of 2 and 3");
itkWarningMacro("Topology checking is only valid for level set dimensions of 2 and 3");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ FastMarchingImageToNodePairContainerAdaptor<TInput, TOutput, TImage>::GenerateDa

if (!is_ok)
{
itkWarningMacro(<< "no input image provided");
itkWarningMacro("no input image provided");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ GPUAnisotropicDiffusionImageFilter<TInputImage, TOutputImage, TParentImageFilter
{
// f->SetTimeStep(1.0 / std::pow(2.0,
// static_cast<double>(ImageDimension)));
itkWarningMacro(<< "Anisotropic diffusion unstable time step: " << this->GetTimeStep() << std::endl
itkWarningMacro("Anisotropic diffusion unstable time step: "
<< this->GetTimeStep() << std::endl
<< "Stable time step for this image must be smaller than "
<< minSpacing / std::pow(2.0, static_cast<double>(ImageDimension + 1)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ BSplineDownsampleImageFilter<TInputImage, TOutputImage, ResamplerType>::EnlargeO
else
{
// pointer could not be cast to TLevelSet *
itkWarningMacro(<< "itk::BSplineDownsampleImageFilter"
itkWarningMacro("itk::BSplineDownsampleImageFilter"
<< "::EnlargeOutputRequestedRegion cannot cast " << typeid(output).name() << " to "
<< typeid(TOutputImage *).name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ BSplineUpsampleImageFilter<TInputImage, TOutputImage, ResamplerType>::EnlargeOut
else
{
// pointer could not be cast to TLevelSet *
itkWarningMacro(<< "itk::BSplineUpsampleImageFilter"
itkWarningMacro("itk::BSplineUpsampleImageFilter"
<< "::EnlargeOutputRequestedRegion cannot cast " << typeid(output).name() << " to "
<< typeid(TOutputImage *).name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ GrayscaleConnectedClosingImageFilter<TInputImage, TOutputImage>::GenerateData()

if (maxValue == seedValue)
{
itkWarningMacro(<< "GrayscaleConnectedClosingImageFilter: pixel value at seed point matches maximum value in "
"image. Resulting image will have a constant value.");
itkWarningMacro("GrayscaleConnectedClosingImageFilter: pixel value at seed point matches maximum value in "
"image. Resulting image will have a constant value.");
outputImage->FillBuffer(maxValue);
this->UpdateProgress(1.0);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ GrayscaleConnectedOpeningImageFilter<TInputImage, TOutputImage>::GenerateData()

if (minValue == seedValue)
{
itkWarningMacro(<< "GrayscaleConnectedClosingImageFilter: pixel value at seed point matches minimum value in "
"image. Resulting image will have a constant value.");
itkWarningMacro("GrayscaleConnectedClosingImageFilter: pixel value at seed point matches minimum value in "
"image. Resulting image will have a constant value.");
outputImage->FillBuffer(minValue);
return;
}
Expand Down

0 comments on commit c6fedbd

Please sign in to comment.