Faster way to draw Segmentation?

Hello,

I am trying to draw a segmentation in the slicer scene based on user clicks, but I find that the process of rendering the segment takes too long. I am using the code below to turn my label map into a segmentation, but I find that it runs quite slowly. Does anyone have an idea how I can speed this process up or different methods I could use to accomplish the same goal?

segmentation = segment.GetSegmentation() while segmentation.GetNumberOfSegments() > 0: segmentation.RemoveSegment(segmentation.GetNthSegment(0))

slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(label_map, segment)
segmentation = self.view_seg.GetSegmentation()
segment = segmentation.GetSegment(segmentation.GetNthSegmentID(0))

What is taking too long time? Interactive editing or the code snippet that you included?

You can make interactive editing faster by deleting the closed surface representation disable smoothing (click Update button in the representation list, closed surface representation row, set smoothing to 0).