<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>I am attempting to extract points with the same data value from the output of a K-Means segmentation. First I copied the labels into the polydata's scalar array. Then I used vtkClipPolyData<span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; "> </span>to select points with one label at a time. (My goal is to input these to vtkPolyDataConnectivity to seperate spatially disconnected clusters). I set up the clipping filters as follows:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">for</span> (<span style="color: #aa0d91">int</span> i = <span style="color: #1c00cf">0</span>; i < inRange[<span style="color: #1c00cf">1</span>]+<span style="color: #1c00cf">1</span>; i++)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkClipPolyData> </span>clippersTestLo<span class="Apple-style-span"> = vtkSmartPointer<vtkClipPolyData>::New();</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestLo->SetValue(i);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestLo->SetInput(contourPolydata);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestLo->InsideOutOn();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestLo->Update();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkClipPolyData> clippersTestHi = vtkSmartPointer<vtkClipPolyData>::New();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestHi->SetValue(i-<span style="color: #1c00cf">1</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestHi->SetInputConnection(</span>clippersTestLo<span class="Apple-style-span">->GetOutputPort());</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestHi->InsideOutOff();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>clippersTestHi->Update();</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre">                </span><br class="webkit-block-placeholder"></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>cout << <span style="color: #c41a16">"Number of points with label "</span> << i << <span class="Apple-style-span" style="color: rgb(196, 26, 22); ">": " </span><< clippersTestHi->GetOutput()->GetNumberOfPoints() << endl;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">}</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><font class="Apple-style-span" face="Helvetica" size="3">This output number of points is incorrect but close to the right number, for example,</font><span class="Apple-style-span" style="font-family: 'Lucida Grande'; font-size: 12px; "> 19770 points with label 0 instead of the actual </span><span class="Apple-style-span" style="font-family: 'Lucida Grande'; font-size: 12px; ">19783. I'd appreciate any ideas on where this error is coming from. Or is there a better solution for extracting these points so I can input them into </span><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; ">vtkPolyDataConnectivity?</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; ">Thanks,</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; ">Sara</span></div></body></html>