Skip to content
/ Slicer Public
forked from Slicer/Slicer

Commit

Permalink
ENH: Simplify EndoscopyLogic API introducing getNumberOfControlPoints
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed Dec 8, 2023
1 parent eb73109 commit ef465b4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Modules/Scripted/Endoscopy/Endoscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def onCreatePathButtonClicked(self):

self.setInputCurve(inputCurve)

numberOfControlPoints = self.logic.resampledCurve.GetNumberOfControlPoints()
numberOfControlPoints = self.logic.getNumberOfControlPoints()

# Update frame slider range
self.frameSlider.maximum = max(0, numberOfControlPoints - 2)
Expand Down Expand Up @@ -495,7 +495,7 @@ def onSaveExportModelButtonClicked(self):
def flyToNext(self):
currentStep = int(self.frameSlider.value)
nextStep = currentStep + self.skip + 1
if nextStep > self.logic.resampledCurve.GetNumberOfControlPoints() - 2:
if nextStep > self.logic.getNumberOfControlPoints() - 2:
nextStep = 0
self.frameSlider.value = nextStep

Expand All @@ -504,7 +504,7 @@ def flyTo(self, resampledCurvePointIndex):

if (
self.logic.resampledCurve is None
or not 0 <= resampledCurvePointIndex < self.logic.resampledCurve.GetNumberOfControlPoints()
or not 0 <= resampledCurvePointIndex < self.logic.getNumberOfControlPoints()
):
return

Expand Down Expand Up @@ -620,7 +620,7 @@ class EndoscopyLogic:
Example:
logic = EndoscopyLogic(inputCurve)
print(f"computed path has {logic.resampledCurve.GetNumberOfControlPoints()} elements")
print(f"computed path has {logic.getNumberOfControlPoints()} elements")
Notes:
* `orientation` = (angle, *axis), where angle is in radians and axis is the unit 3D-vector for the axis
Expand All @@ -644,6 +644,9 @@ def cleanup(self):
self.planeNormal = None
self.cameraOrientationResampledCurveIndices = None

def getNumberOfControlPoints(self):
return self.resampledCurve.GetNumberOfControlPoints()

def setControlPoints(self, inputCurve: slicer.vtkMRMLMarkupsCurveNode) -> None:
expectedType = slicer.vtkMRMLMarkupsCurveNode
if not isinstance(inputCurve, expectedType):
Expand Down

0 comments on commit ef465b4

Please sign in to comment.