From a69e6ea48cb632685a57e8f008e16cbb5fc80870 Mon Sep 17 00:00:00 2001 From: Andras Lasso Date: Wed, 13 Nov 2024 23:43:29 -0500 Subject: [PATCH] STYLE: Fix build warnings on linux Fixed build warnings reported by this github action: https://github.com/Slicer/Slicer/actions/runs/11829892124/job/32962501349 --- Libs/MRML/Core/vtkImageMathematicsAddon.cxx | 25 +++++++++-------- Libs/MRML/Core/vtkImplicitInvertableBoolean.h | 1 + Libs/MRML/Core/vtkMRMLClipNode.cxx | 4 +-- Libs/MRML/Core/vtkMRMLNode.cxx | 4 +-- Libs/MRML/Core/vtkMRMLTextStorageNode.cxx | 2 +- ...MRMLLinearTransformsDisplayableManager.cxx | 28 +++++++++++-------- .../qSlicerTransformsModuleWidget.cxx | 1 - .../Transforms/qSlicerTransformsReader.cxx | 1 - 8 files changed, 37 insertions(+), 29 deletions(-) diff --git a/Libs/MRML/Core/vtkImageMathematicsAddon.cxx b/Libs/MRML/Core/vtkImageMathematicsAddon.cxx index a3ecaebd9c4..06f5cef6b9b 100644 --- a/Libs/MRML/Core/vtkImageMathematicsAddon.cxx +++ b/Libs/MRML/Core/vtkImageMathematicsAddon.cxx @@ -152,8 +152,7 @@ void vtkImageMathematicsAddonExecute2(vtkImageMathematicsAddon* self, vtkImageDa unsigned long count = 0; unsigned long target; int op = self->GetOperation(); - int divideByZeroToC = self->GetDivideByZeroToC(); - double constantc = self->GetConstantC(); + double normalizeScalarRange[2] = { 0.0, 1.0 }; self->GetRange(normalizeScalarRange); double normalizeMagnitude = normalizeScalarRange[1] - normalizeScalarRange[0]; @@ -170,6 +169,18 @@ void vtkImageMathematicsAddonExecute2(vtkImageMathematicsAddon* self, vtkImageDa inData->GetContinuousIncrements(outExt, inIncX, inIncY, inIncZ); outData->GetContinuousIncrements(outExt, outIncX, outIncY, outIncZ); + if (op != VTK_MULTIPLYBYSCALEDRANGE) + { + vtkErrorWithObjectMacro(self, << "Execute: Unknown operation: " << op); + return; + } + + if (normalizeMagnitude == 0.0) + { + vtkErrorWithObjectMacro(self, << "Execute: normalizeScalarRange width is zero"); + return; + } + // Loop through output pixels for (idxZ = 0; idxZ <= maxZ; idxZ++) { @@ -185,15 +196,7 @@ void vtkImageMathematicsAddonExecute2(vtkImageMathematicsAddon* self, vtkImageDa } for (idxR = 0; idxR < rowLength; idxR++) { - // Pixel operation - switch (op) - { - case VTK_MULTIPLYBYSCALEDRANGE: - *outPtr = *inPtr * static_cast((*outPtr - normalizeScalarRange[0]) / normalizeMagnitude); - break; - default: - break; - } + *outPtr = *inPtr * static_cast((*outPtr - normalizeScalarRange[0]) / normalizeMagnitude); outPtr++; inPtr++; } diff --git a/Libs/MRML/Core/vtkImplicitInvertableBoolean.h b/Libs/MRML/Core/vtkImplicitInvertableBoolean.h index 218adb934ca..f7ef3b8f8fe 100644 --- a/Libs/MRML/Core/vtkImplicitInvertableBoolean.h +++ b/Libs/MRML/Core/vtkImplicitInvertableBoolean.h @@ -50,6 +50,7 @@ class VTK_MRML_EXPORT vtkImplicitInvertableBoolean : public vtkImplicitBoolean /** * Evaluate boolean combinations of implicit function using current operator. */ + using vtkImplicitBoolean::EvaluateFunction; double EvaluateFunction(double x[3]) override; //@} diff --git a/Libs/MRML/Core/vtkMRMLClipNode.cxx b/Libs/MRML/Core/vtkMRMLClipNode.cxx index be8452c9484..47120fdfbaa 100644 --- a/Libs/MRML/Core/vtkMRMLClipNode.cxx +++ b/Libs/MRML/Core/vtkMRMLClipNode.cxx @@ -556,7 +556,7 @@ int vtkMRMLClipNode::GetClippingNodeState(const char* nodeID) int vtkMRMLClipNode::GetNthClippingNodeState(int n) { NodeReferenceListType references = this->NodeReferences[ClippingNodeReferenceRole]; - if (references.size() <= n) + if (references.size() <= static_cast(n)) { return ClipOff; } @@ -596,7 +596,7 @@ void vtkMRMLClipNode::SetClippingNodeState(const char* nodeID, int state) void vtkMRMLClipNode::SetNthClippingNodeState(int n, int state) { NodeReferenceListType references = this->NodeReferences[ClippingNodeReferenceRole]; - if (references.size() <= n) + if (references.size() <= static_cast(n)) { return; } diff --git a/Libs/MRML/Core/vtkMRMLNode.cxx b/Libs/MRML/Core/vtkMRMLNode.cxx index 1314a441da5..8c2f00c01c5 100644 --- a/Libs/MRML/Core/vtkMRMLNode.cxx +++ b/Libs/MRML/Core/vtkMRMLNode.cxx @@ -2068,7 +2068,7 @@ bool vtkMRMLNode::vtkMRMLNodeReference::SetProperty(const std::string& key, cons bool modified = false; if (propertiesIt != this->Properties.end()) { - if (propertiesIt->second != value); + if (propertiesIt->second != value) { modified = true; propertiesIt->second = value; @@ -2160,7 +2160,7 @@ void vtkMRMLNode::SetNthNodeReferenceProperty(const std::string& referenceRole, } NodeReferenceListType& references = this->NodeReferences[std::string(referenceRole)]; - if (n < 0 || n >= references.size()) + if (n < 0 || static_cast(n) >= references.size()) { return; } diff --git a/Libs/MRML/Core/vtkMRMLTextStorageNode.cxx b/Libs/MRML/Core/vtkMRMLTextStorageNode.cxx index 2e30dd5c13f..43bb2981644 100644 --- a/Libs/MRML/Core/vtkMRMLTextStorageNode.cxx +++ b/Libs/MRML/Core/vtkMRMLTextStorageNode.cxx @@ -242,7 +242,7 @@ const char* vtkMRMLTextStorageNode::GetDefaultWriteFileExtension() vtkStringArray* fileTypes = this->GetSupportedWriteFileTypes(); if (fileTypes && fileTypes->GetNumberOfValues() > 0) { - std::string fileExtension = vtkDataFileFormatHelper::GetFileExtensionFromFormatString(fileTypes->GetValue(0)); + std::string fileExtension = vtkDataFileFormatHelper::GetFileExtensionFromFormatString(fileTypes->GetValue(0).c_str()); if (!fileExtension.empty()) { // Remove leading "." diff --git a/Modules/Loadable/Transforms/MRMLDM/vtkMRMLLinearTransformsDisplayableManager.cxx b/Modules/Loadable/Transforms/MRMLDM/vtkMRMLLinearTransformsDisplayableManager.cxx index e17394a7a58..0a4e2e5c339 100644 --- a/Modules/Loadable/Transforms/MRMLDM/vtkMRMLLinearTransformsDisplayableManager.cxx +++ b/Modules/Loadable/Transforms/MRMLDM/vtkMRMLLinearTransformsDisplayableManager.cxx @@ -275,16 +275,19 @@ void vtkMRMLLinearTransformsDisplayableManager::OnMRMLSceneNodeAdded(vtkMRMLNode return; } - vtkMRMLTransformNode* transformNode = nullptr; - vtkMRMLTransformDisplayNode* displayNode = nullptr; - if (transformNode = vtkMRMLTransformNode::SafeDownCast(node)) + vtkMRMLTransformNode* transformNode = vtkMRMLTransformNode::SafeDownCast(node); + if (transformNode) { this->Internal->AddObservations(transformNode); + return; } - else if (displayNode = vtkMRMLTransformDisplayNode::SafeDownCast(node)) + + vtkMRMLTransformDisplayNode* displayNode = vtkMRMLTransformDisplayNode::SafeDownCast(node); + if (displayNode) { this->Internal->UpdatePipelineFromDisplayNode(vtkMRMLTransformDisplayNode::SafeDownCast(node)); this->RequestRender(); + return; } } @@ -298,19 +301,22 @@ void vtkMRMLLinearTransformsDisplayableManager::OnMRMLSceneNodeRemoved(vtkMRMLNo return; } - vtkMRMLTransformNode* transformNode = nullptr; - vtkMRMLTransformDisplayNode* displayNode = nullptr; - bool modified = false; - if (transformNode = vtkMRMLTransformNode::SafeDownCast(node)) + + vtkMRMLTransformNode* transformNode = vtkMRMLTransformNode::SafeDownCast(node); + if (transformNode) { this->Internal->RemoveObservations(transformNode); modified = true; } - else if (displayNode = vtkMRMLTransformDisplayNode::SafeDownCast(node)) + else { - this->Internal->UpdatePipelineFromDisplayNode(displayNode); - modified = true; + vtkMRMLTransformDisplayNode* displayNode = vtkMRMLTransformDisplayNode::SafeDownCast(node); + if (displayNode) + { + this->Internal->UpdatePipelineFromDisplayNode(displayNode); + modified = true; + } } if (modified) diff --git a/Modules/Loadable/Transforms/qSlicerTransformsModuleWidget.cxx b/Modules/Loadable/Transforms/qSlicerTransformsModuleWidget.cxx index 32ce241134b..f626c4f9ce4 100644 --- a/Modules/Loadable/Transforms/qSlicerTransformsModuleWidget.cxx +++ b/Modules/Loadable/Transforms/qSlicerTransformsModuleWidget.cxx @@ -417,7 +417,6 @@ void qSlicerTransformsModuleWidget::updateCenterOfTransformationWidgets() { vtkNew transform; d->MRMLTransformNode->GetTransformToWorld(transform); - double coordinates_World[3] = { 0.0, 0.0, 0.0 }; transform->TransformPoint(centerOfTransformation, centerOfTransformation); } diff --git a/Modules/Loadable/Transforms/qSlicerTransformsReader.cxx b/Modules/Loadable/Transforms/qSlicerTransformsReader.cxx index 077c238044d..e6792d7b8b6 100644 --- a/Modules/Loadable/Transforms/qSlicerTransformsReader.cxx +++ b/Modules/Loadable/Transforms/qSlicerTransformsReader.cxx @@ -130,7 +130,6 @@ double qSlicerTransformsReader::canLoadFileConfidence(const QString& fileName)co using ImageIOType = itk::NiftiImageIO; ImageIOType::Pointer niftiIO = ImageIOType::New(); niftiIO->SetFileName(fileName.toStdString()); - bool readSuccessful = false; try { niftiIO->ReadImageInformation();