Can I extract the outline/contour of each slice of closed segment and then draw a closed curve from it with code?
Yes, sure. You can retrieve the closed surface representation of the segment, get intersection by using VTK cut filter, sort the points using vtkContourTriangulator, then add the polygon points as curve control points. This code may help: https://github.com/Slicer/Slicer/pull/1075/files
I donnot know how to get intersection and create a closed curve from points after covert the segment to a polygon data with python(just learned python). Could you help me?
segmentId = segmentationNode.GetSegmentation().GetNthSegmentID(0)