diff --git a/Modules/Scripted/Endoscopy/Endoscopy.py b/Modules/Scripted/Endoscopy/Endoscopy.py index 45229e924ba..df184d6b120 100644 --- a/Modules/Scripted/Endoscopy/Endoscopy.py +++ b/Modules/Scripted/Endoscopy/Endoscopy.py @@ -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: @@ -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): @@ -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. @@ -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