ALive-research / Slicer-Liver

3D Slicer extension for liver analysis and therapy planning
Other
17 stars 9 forks source link

Slicer 5.1.0 crash when setting the control points for vtkMRMLLiverResectionNode using SetBezierSurfaceControlPoints(vtkPoints* controlPoints) #193

Open dalbenzioG opened 1 year ago

dalbenzioG commented 1 year ago

Slicer exits abnormally when SetBezierSurfaceControlPoints is called here:

ResectionNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLiverResectionNode")
ResectionNode.SetBezierSurfaceControlPoints(points) # points are  16 control points (vtkPoints)

After debugging, the unexpected behavior is caused here: https://github.com/ALive-research/Slicer-Liver/blob/819813a0feff371987aa75feacd0815e30fdded5/LiverResections/MRML/vtkMRMLLiverResectionNode.cxx#L104

As stated here, "Review the need for this. We already have a pointer to the surface node".

Using the following lines of code for setting my ResectionNode does not cause any crash

# points are the control points represented as vtkPoints
pointPlaceMode = slicer.vtkMRMLMarkupsDisplayNode.SnapModeUnconstrained
BezierNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsBezierSurfaceNode")
BezierNode.SetControlPointPositionsWorld(points)
BezierNode.GetDisplayNode().SetSnapMode(pointPlaceMode)
ResectionNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLiverResectionNode")
ResectionNode.SetTargetOrganModelNode(liverNode)
b = ResectionNode.GetBezierSurfaceNode()
b.RemoveAllControlPoints()
b.SetControlPointPositionsWorld(points)
RafaelPalomar commented 1 year ago

For the record. This seems to be caused by unused (and uninitialized) members of the vtkMRMLLiverResectionNode.

On 23/01/20 10:02AM, dalbenzioG wrote:

Slicer exits abnormally when SetBezierSurfaceControlPoints is called here:

ResectionNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLiverResectionNode")
ResectionNode.SetBezierSurfaceControlPoints(points) # points are  16 control points (vtkPoints)

After debugging, the unexpected behavior is caused [here](https://github.com/ALive-research/Slicer-Liver/blob/819813a0feff371987aa75feacd0815e30fdded5/LiverResections/MRML/vtkMRMLLiverResectionNode.cxx#L104.

As stated here, "Review the need for this. We already have a pointer to the surface node".

Using the following lines of code for setting my ResectionNode does not cause any crash

# points are the control points represented as vtkPoints
pointPlaceMode = slicer.vtkMRMLMarkupsDisplayNode.SnapModeUnconstrained
BezierNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsBezierSurfaceNode")
BezierNode.SetControlPointPositionsWorld(points)
BezierNode.GetDisplayNode().SetSnapMode(pointPlaceMode)
ResectionNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLiverResectionNode")
ResectionNode.SetTargetOrganModelNode(liverNode)
b = ResectionNode.GetBezierSurfaceNode()
b.RemoveAllControlPoints()
b.SetControlPointPositionsWorld(points)

-- Reply to this email directly or view it on GitHub: https://github.com/ALive-research/Slicer-Liver/issues/193 You are receiving this because you are subscribed to this thread.

Message ID: @.***>