[vtk-developers] vtkPolyData->IsEdge fix
Rasmus Reinhold Paulsen
rrp at imm.dtu.dk
Mon Mar 10 13:19:38 EST 2003
I am currently trying to get a deeper understanding of the way VTK handles
topology. I found a strange "feature" in vtkPolyData->IsEdge. Apparently I
am not the first:
Luca, January 2003:
1) vtkPolyData::IsEdge(vtkIdType, vtkIdType) returns 1 if two points are
on the same cell, and 0 otherwise. Quite a handy method indeed, but its
name can be misleading if you work with n-sided polygons (n>3), since to
me polygon edges are cell boundary edges. I think a caveat in IsEdge
documentation would be perfect.
Luca proposes a fix:
inline int vtkPolyData::IsEdge(int p1, int p2)
{
unsigned short int ncells;
int npts;
int i, j;
vtkIdType *cells, *pts;
this->GetPointCells(p1,ncells,cells);
for (i=0; i<ncells; i++)
{
this->GetCellPoints(cells[i],npts,pts);
for (j=0; j<npts; j++)
{
if (p1==pts[j])
if ((pts[(j-1)%npts]==p2)||(pts[(j+1)%npts]==p2))
return 1;
}
}
return 0;
}
Is there a reason for the current IsEdge behavior or should the above fix
be applied?
Regards
Rasmus
More information about the vtk-developers
mailing list