From 00e3964a940fa7a3cbd6f6353df845f83416bd93 Mon Sep 17 00:00:00 2001 From: Lee Newberg Date: Fri, 20 Dec 2024 15:49:58 -0500 Subject: [PATCH] ENH: WIP: Issue #7179 Curved Planar Reformation Call vtkAddonMathUtilities::FitPlaneToPoints directly instead of via vtkSlicerMarkupsLogic::GetBestFitPlane, which is unavailable from vtkMRMLSliceLogic. --- Libs/MRML/Logic/vtkMRMLSliceLogic.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Libs/MRML/Logic/vtkMRMLSliceLogic.cxx b/Libs/MRML/Logic/vtkMRMLSliceLogic.cxx index b4999e33be5..81c60c98901 100644 --- a/Libs/MRML/Logic/vtkMRMLSliceLogic.cxx +++ b/Libs/MRML/Logic/vtkMRMLSliceLogic.cxx @@ -12,11 +12,6 @@ =========================================================================auto=*/ -#if 0 -// Includes that are not available -#include -#endif - // MRMLLogic includes #include #include @@ -1111,8 +1106,15 @@ vtkMRMLSliceLogic::CurvedPlanarReformationComputeStraighteningTransform( resampledCurveNode->SetCurveTypeToLinear(); resampledCurveNode->SetControlPointPositionsWorld(sampledPoints); + vtkPoints * resampledCurvePointsWorld = resampledCurveNode->GetCurvePointsWorld(); + if (resampledCurvePointsWorld == nullptr || resampledCurvePointsWorld->GetNumberOfPoints() < 3) + { + vtkErrorMacro("vtkMRMLSliceLogic::CurvedPlanarReformationComputeStraighteningTransform failed: " + "Not enough resampled curve points"); + return false; + } vtkSmartPointer curveNodePlane = vtkSmartPointer::New(); - vtkSlicerMarkupsLogic::GetBestFitPlane(resampledCurveNode, curveNodePlane); + vtkAddonMathUtilities::FitPlaneToPoints(resampledCurvePointsWorld, curveNodePlane); // Z axis (from first curve point to last, this will be the straightened curve long axis) double curveStartPoint[3] = { 0.0, 0.0, 0.0 };