[vtk-developers] ARB-Request: Blessing of vtkPolyData->IsEdge fix
Rasmus Reinhold Paulsen
rrp at imm.dtu.dk
Fri Mar 14 12:05:08 EST 2003
Okay. Here we go:
int vtkPolyData::IsEdge(vtkIdType p1, vtkIdType p2)
{
unsigned short int ncells;
vtkIdType cellType;
vtkIdType npts;
vtkIdType i, j;
vtkIdType *cells, *pts;
this->GetPointCells(p1,ncells,cells);
for (i=0; i<ncells; i++)
{
cellType = this->GetCellType(cells[i]);
switch (cellType)
{
case VTK_EMPTY_CELL: case VTK_VERTEX: case VTK_POLY_VERTEX:
break;
case VTK_LINE: case VTK_POLY_LINE:
this->GetCellPoints(cells[i],npts,pts);
for (j=0; j<npts-1; j++)
{
if
(((pts[j]==p1)&&(pts[j+1]==p2))||((pts[j]==p2)&&(pts[j+1]==p1)))
{
return 1;
}
}
break;
case VTK_TRIANGLE_STRIP:
this->GetCellPoints(cells[i],npts,pts);
for (j=0; j<npts-2; j++)
{
if
((((pts[j]==p1)&&(pts[j+1]==p2))||((pts[j]==p2)&&(pts[j+1]==p1)))||
(((pts[j]==p1)&&(pts[j+2]==p2))||((pts[j]==p2)&&(pts[j+2]==p1))))
{
return 1;
}
}
if
(((pts[npts-2]==p1)&&(pts[npts-1]==p2))||((pts[npts-2]==p2)&&(pts[npts-1]==p1)))
{
return 1;
}
break;
default:
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;
}
This fix will be applied to vtkPolyData.cxx monday if no
objections. My mailer is screwing up formatting...it should be compliant.
Regards,
Rasmus (and Luca)
More information about the vtk-developers
mailing list