Sorry for this prior email, the behaviour of the function is as intended. It was actually my mistake, there was a duplicate cell lurking underneath those that where returning an number of cells equaling 2. Doing a quick check of whether for when ncells returns 2 that the point ids of these triangles are the same sorts everything out. <div>
<br></div><div>Some like adding into the function I sent previously...<br><div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre"></span>if(ncells == 2.0){</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//may be a duplicate cell lurking underneath.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if( pd->IsPointUsedByCell(pointIds->GetId(0),dummyIDT[0]) &&</div>
<div> pd->IsPointUsedByCell(pointIds->GetId(1),dummyIDT[0]) &&<span class="Apple-tab-span" style="white-space:pre">                                                </span> pd->IsPointUsedByCell(pointIds->GetId(2),dummyIDT[0]) &&<span class="Apple-tab-span" style="white-space:pre">                                                </span> pd->IsPointUsedByCell(pointIds->GetId(0),dummyIDT[1]) &&<span class="Apple-tab-span" style="white-space:pre">                                                </span> pd->IsPointUsedByCell(pointIds->GetId(1),dummyIDT[1]) &&<span class="Apple-tab-span" style="white-space:pre">                                                </span> pd->IsPointUsedByCell(pointIds->GetId(2),dummyIDT[1]) ){<span class="Apple-tab-span" style="white-space:pre">                                                </span>lonevertex++;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div><div><br></div><div>Bit of a hack, as I could use vtkCleanPolyData, but it works. This code may be of use to anyone who comes accross the same problem.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>G.</div><div><br><div class="gmail_quote">On Fri, Sep 17, 2010 at 10:28 AM, Gordon Stevenson <span dir="ltr"><<a href="mailto:gordon.stevenson@lmh.ox.ac.uk">gordon.stevenson@lmh.ox.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<div><br></div><div>I'm using polydata and the GetPointCells function to return for a given point the number of cells that use that point. I want to mark these point and so the cells where corners exist, so i can remove these cells.<br>
</div><div><br></div><div>This works great in the most part, but for a few given corners (which I can visualise both the cell id and point id in ParaView) I know that it is a vertex that is used solely by one cell.</div>
<div>
<br></div><div>pd->GetPointCells(pointIds->GetId(j),ncells,dummyIDT);</div><div><br></div><div>returns ncells as 2. (when I believe it should be one?)</div><div><br></div><div>Can anyone explain why that may be? Incidentally, I only use data that has been run through vtkTriangleFilter before doing this. I enclose the function I use below.</div>
<div><br></div><div>Any help would be greatly appreciated.</div><div><br></div><div>Gordon.</div><div><br></div><div><div>vtkSmartPointer<vtkPolyData> CleanMesh(vtkSmartPointer<vtkPolyData> pd){</div><div><span style="white-space:pre-wrap">        </span>// want to take in a polydata pd, and remove any cells (triangles) that are</div>
<div><span style="white-space:pre-wrap">        </span>// have vertices that have no links to other cells.</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>//show user current EC.</div>
<div><span style="white-space:pre-wrap">        </span>//GetEulerCharacteristic(pd);</div><div><br></div><div><span style="white-space:pre-wrap">        </span>//for each cell in the mesh</div><div><span style="white-space:pre-wrap">        </span>unsigned short ncells;</div>
<div><span style="white-space:pre-wrap">        </span>int lonevertex,badcellcount;</div><div><span style="white-space:pre-wrap">        </span>//variable to store number of cells that are deleted.</div>
<div><span style="white-space:pre-wrap">        </span>badcellcount = 0.0;</div><div><span style="white-space:pre-wrap">        </span>int a = 0;</div><div><span style="white-space:pre-wrap">        </span>bool cornersfound = true;</div>
<div><span style="white-space:pre-wrap">        </span>while(cornersfound){</div><div><span style="white-space:pre-wrap">                </span>//create connectivity list for cells. --required for GetPointCells calls.</div>
<div><span style="white-space:pre-wrap">                </span>pd->BuildLinks();</div><div><br></div><div><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>cornersfound = false;</div>
<div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">                </span>int b;</div><div><span style="white-space:pre-wrap">                </span>//for each cell.</div>
<div><span style="white-space:pre-wrap">                </span>for(vtkIdType i = 0; i<pd->GetNumberOfCells(); i++){</div><div><span style="white-space:pre-wrap">        </span> <span style="white-space:pre-wrap">                </span>//generate the points each that cell.</div>
<div><span style="white-space:pre-wrap">                        </span>vtkSmartPointer<vtkIdList> pointIds = vtkSmartPointer<vtkIdList>::New();</div><div><span style="white-space:pre-wrap">                        </span>pointIds = pd->GetCell(i)->GetPointIds();<span style="white-space:pre-wrap">                        </span></div>
<div><span style="white-space:pre-wrap">                        </span>if (pointIds->GetNumberOfIds() > 3) {</div><div><span style="white-space:pre-wrap">                                </span>std::cout << "Polygon got more than 3 vertices!" << std::endl;</div>
<div><span style="white-space:pre-wrap">                        </span>}</div><div><br></div><div><span style="white-space:pre-wrap">                        </span>vtkIdType *dummyIDT;</div><div><span style="white-space:pre-wrap">                        </span>lonevertex = 0;</div>
<div><span style="white-space:pre-wrap">                        </span>ncells = 0.0;</div><div><span style="white-space:pre-wrap">                        </span>//so for each point in the triangle, check that the vertex has more than one cell</div>
<div><span style="white-space:pre-wrap">                        </span>//that uses it.</div><div><span style="white-space:pre-wrap">                                </span></div><div><span style="white-space:pre-wrap">                                </span>//loop over each vertex in the cell.</div>
<div><span style="white-space:pre-wrap">                                </span>for(vtkIdType j = 0; j < pointIds->GetNumberOfIds(); j++){<span style="white-space:pre-wrap">                                </span></div><div><span style="white-space:pre-wrap">                                        </span>//get the number of cells that use this vertex.</div>
<div><span style="white-space:pre-wrap">                                        </span>b = pointIds->GetId(j);</div><div><span style="white-space:pre-wrap">                                        </span>pd->GetPointCells(pointIds->GetId(j),ncells,dummyIDT);<span style="white-space:pre-wrap">                                </span></div>
<div><span style="white-space:pre-wrap">                                        </span>//if vertex is not used by any other cells then -- including itself.</div><div><span style="white-space:pre-wrap">                                        </span>if (ncells == 1.0){<span style="white-space:pre-wrap">                                </span></div>
<div><span style="white-space:pre-wrap">                                                </span>//vertex is a corner, and therefore a candidate for deletion.</div><div><span style="white-space:pre-wrap">                                                </span>lonevertex++;</div>
<div><span style="white-space:pre-wrap">                                        </span>}</div><div><span style="white-space:pre-wrap">                                </span>}</div><div><br></div><div><span style="white-space:pre-wrap">                                </span>//have we got any lone vertices?</div>
<div><span style="white-space:pre-wrap">                                </span>if(lonevertex!=0){</div><div><span style="white-space:pre-wrap">                                        </span>badcellcount++;</div><div><span style="white-space:pre-wrap">                                        </span>//put up cell as candidate for deletion.</div>
<div><span style="white-space:pre-wrap">                                        </span>pd->DeleteCell(i);<span style="white-space:pre-wrap">                                        </span></div><div><span style="white-space:pre-wrap">                                        </span>//need to loop back over the cells again checking for more corners</div>
<div><span style="white-space:pre-wrap">                                        </span>//that may have been revealed.</div><div><span style="white-space:pre-wrap">                                        </span>cornersfound = true;</div><div><span style="white-space:pre-wrap">                                </span>}</div>
<div><span style="white-space:pre-wrap">                </span>}</div><div><span style="white-space:pre-wrap">                </span>pd->RemoveDeletedCells();</div><div><span style="white-space:pre-wrap">                </span>pd->Modified();</div>
<div><span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span>std::cout << "\n Corner cells removed = " << badcellcount << std::endl;</div>
<div><span style="white-space:pre-wrap">        </span>//GetEulerCharacteristic(pd);</div><div><span style="white-space:pre-wrap">        </span>return pd;</div><div>}</div></div><div><br></div>
</blockquote></div><br></div></div></div>