[vtk-developers] ARB-Request: Blessing of vtkPolyData->IsEdge fix

Ken Martin ken.martin at kitware.com
Wed Mar 12 09:16:38 EST 2003


I think there are a couple problems with the suggested code.
Specifically three cases come to mind that I think will break it. 

1) For a triangle strip with points p0, p1, p2, p3 ... the points p0 and
p2 do form an edge but would not be correctly reported by the code
below. 

2) for a poly vertex there are no edges but the function could say that
there was one

3) for poly lines if someone checked the first and last point of a poly
line (in either order) it would match.

And a minor formatting issue in that the "if" statements do not have {}
under them. Having said that, the original code was clearly screwed up.
It looks like a valid solution will have to know what type of cell is
being considered. Perhaps a switch (this->GetCellType(cell[i])) with the
current code in the default case but special cases for Tstrips,
polyvert, and polyline. The whole thing should probably be moved into
the cxx file as well, getting a bit long and complicated for an inline.

Thanks
Ken

> Luca Antiga and I would like to apply the following fix to
> vtkPolyData->IsEdge :
> 
> 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)%npts]==p2)||(pts[(j+1)%npts]==p2))
>           return 1;
>     }
>   }
> 
>   return 0;
> }






More information about the vtk-developers mailing list