[vtkusers] GetPointCells -- number of cells returned not as expected?

Gordon Stevenson gordon.stevenson at lmh.ox.ac.uk
Fri Sep 17 05:28:27 EDT 2010


Hi,

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.

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.

pd->GetPointCells(pointIds->GetId(j),ncells,dummyIDT);

returns ncells as 2. (when I believe it should be one?)

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.

Any help would be greatly appreciated.

Gordon.

vtkSmartPointer<vtkPolyData> CleanMesh(vtkSmartPointer<vtkPolyData> pd){
// want to take in a polydata pd, and remove any cells (triangles) that are
// have vertices that have no links to other cells.
 //show user current EC.
//GetEulerCharacteristic(pd);

//for each cell in the mesh
unsigned short ncells;
int lonevertex,badcellcount;
//variable to store number of cells that are deleted.
badcellcount = 0.0;
int a = 0;
bool cornersfound = true;
while(cornersfound){
//create connectivity list for cells. --required for GetPointCells calls.
pd->BuildLinks();

 cornersfound = false;
 int b;
//for each cell.
for(vtkIdType i = 0; i<pd->GetNumberOfCells(); i++){
 //generate the points each that cell.
vtkSmartPointer<vtkIdList> pointIds = vtkSmartPointer<vtkIdList>::New();
pointIds = pd->GetCell(i)->GetPointIds();
if (pointIds->GetNumberOfIds() > 3) {
std::cout << "Polygon got more than 3 vertices!" << std::endl;
}

vtkIdType *dummyIDT;
lonevertex = 0;
ncells = 0.0;
//so for each point in the triangle, check that the vertex has more than one
cell
//that uses it.
 //loop over each vertex in the cell.
for(vtkIdType j = 0; j < pointIds->GetNumberOfIds(); j++){
//get the number of cells that use this vertex.
b = pointIds->GetId(j);
pd->GetPointCells(pointIds->GetId(j),ncells,dummyIDT);
//if vertex is not used by any other cells then -- including itself.
if (ncells == 1.0){
//vertex is a corner, and therefore a candidate for deletion.
lonevertex++;
}
}

//have we got any lone vertices?
if(lonevertex!=0){
badcellcount++;
//put up cell as candidate for deletion.
pd->DeleteCell(i);
//need to loop back over the cells again checking for more corners
//that may have been revealed.
cornersfound = true;
}
}
pd->RemoveDeletedCells();
pd->Modified();
}
std::cout << "\n Corner cells removed = " << badcellcount << std::endl;
//GetEulerCharacteristic(pd);
return pd;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100917/3ee4bb3a/attachment.htm>


More information about the vtkusers mailing list