<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. &nbsp;First I copied the labels into the polydata's scalar array. &nbsp;Then I used vtkClipPolyData<span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; ">&nbsp;</span>to select points with one label at a time. &nbsp;(My goal is to input these to&nbsp;vtkPolyDataConnectivity to seperate spatially disconnected clusters). &nbsp;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 &lt; 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&lt;vtkClipPolyData&gt;&nbsp;</span>clippersTestLo<span class="Apple-style-span">&nbsp;= vtkSmartPointer&lt;vtkClipPolyData&gt;::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-&gt;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-&gt;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-&gt;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-&gt;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&lt;vtkClipPolyData&gt; clippersTestHi = vtkSmartPointer&lt;vtkClipPolyData&gt;::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-&gt;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-&gt;SetInputConnection(</span>clippersTestLo<span class="Apple-style-span">-&gt;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-&gt;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-&gt;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 &lt;&lt; <span style="color: #c41a16">"Number of points with label "</span>&nbsp;&lt;&lt; i &lt;&lt;&nbsp;<span class="Apple-style-span" style="color: rgb(196, 26, 22); ">": "&nbsp;</span>&lt;&lt; clippersTestHi-&gt;GetOutput()-&gt;GetNumberOfPoints() &lt;&lt; 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; ">&nbsp;19770 points with label 0 instead of the actual&nbsp;</span><span class="Apple-style-span" style="font-family: 'Lucida Grande'; font-size: 12px; ">19783. &nbsp;I'd appreciate any ideas on where this error is coming from. &nbsp;Or is there a better solution for extracting these points so I can input them into&nbsp;</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>