Skip to content

Commit

Permalink
ENH: Remove ununused cameraNode parameter from EndoscopyPathModel.__i…
Browse files Browse the repository at this point in the history
…nit__

STYLE: Use `p` instead of `ctr` for center position of plane
ENH: Don't check for multiple display nodes for newly created model
  • Loading branch information
Leengit committed Nov 27, 2023
1 parent 4ddda8b commit 6e91cff
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Modules/Scripted/Endoscopy/Endoscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def onLastOrientationButtonClicked(self):
def onSaveExportModelButtonClicked(self):
logging.debug("Create Model...")
outputPathNode = self.outputPathNodeSelector.currentNode()
model = EndoscopyPathModel(self.logic.resampledCurve, self.inputCurve, self.cameraNode, outputPathNode)
model = EndoscopyPathModel(self.logic.resampledCurve, self.inputCurve, outputPathNode)
# The use of a model is pretty deprecated at this point. However, if the user wants the old behavior, that also
# includes the cursor and transform.
if self.cursor:
Expand Down Expand Up @@ -980,15 +980,15 @@ def planeFit(points):
Adapted from https://stackoverflow.com/questions/12299540/plane-fitting-to-4-or-more-xyz-points
"""
points = points.reshape((points.shape[0], -1)) # Collapse trailing dimensions
ctr = points.mean(axis=1) if points.size else np.zeros((points.shape[0],))
x = points - ctr[:, np.newaxis] # Recenter on the centroid
p = points.mean(axis=1) if points.size else np.zeros((points.shape[0],))
x = points - p[:, np.newaxis] # Recenter on the centroid
M = np.dot(x, x.T) # Could also use np.cov(x) here.
n = np.linalg.svd(M)[0][:, -1]
# Choose the normal to be in the direction of increasing coordinate value
primary_direction = np.abs(n).argmax()
if n[primary_direction] < 0.0:
n *= -1.0
return ctr, n
return p, n

@staticmethod
def buildCameraMatrix3x3(cameraPosition, focalPoint, viewUp, outputMatrix3x3=None):
Expand Down Expand Up @@ -1025,7 +1025,7 @@ class EndoscopyPathModel:
- Add a single polyline
"""

def __init__(self, resampledCurve, inputCurve, cameraNode, outputPathNode=None):
def __init__(self, resampledCurve, inputCurve, outputPathNode=None):
"""
:param resampledCurve: resampledCurve generated by EndoscopyLogic.
:param inputCurve: input node, just used for naming the output node.
Expand Down Expand Up @@ -1064,8 +1064,7 @@ def __init__(self, resampledCurve, inputCurve, cameraNode, outputPathNode=None):
slicer.mrmlScene.GenerateUniqueName(f"Path-{inputCurve.GetName()}"),
)
model.CreateDefaultDisplayNodes()
for displayNodeIndex in range(model.GetNumberOfDisplayNodes()):
model.GetNthDisplayNode(displayNodeIndex).SetColor(1, 1, 0) # yellow
model.GetDisplayNode().SetColor(1, 1, 0) # yellow

model.SetAndObservePolyData(polyData)
self.model = model

0 comments on commit 6e91cff

Please sign in to comment.