vtkXYPlotActor clipping causes crash and/or rendering problems.
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
When a vtkXYPlotActor is use to display data, it clips the values that are out of the specified range.
In the function vtkXYPlotActor::ClipPlotData, it checks all the points are creates new cells for which the points outside the specified range are kept. The ones outside the range are excluded.
One case is not handled. In the following code, if there are no trivial rejection, nor trivial acceptance, than we check if x1 is out of range. If so, we assume that x2 is not, which is not always true.
In that case, an id of -1 will be set to a cell, which may cause a crash at rendering time.
//intersect each segment with the four planes if ( (x1[0] < p1[0] && x2[0] < p1[0]) || (x1[0] > p2[0] && x2[0] > p2[0]) || (x1[1] < p1[1] && x2[1] < p1[1]) || (x1[1] > p2[1] && x2[1] > p2[1]) ) { ;//trivial rejection } else if (x1[0] >= p1[0] && x2[0] >= p1[0] && x1[0] <= p2[0] && x2[0] <= p2[0] && x1[1] >= p1[1] && x2[1] >= p1[1] && x1[1] <= p2[1] && x2[1] <= p2[1] ) {//trivial acceptance newPts[0] = pointMap[pts[i]]; newPts[1] = pointMap[pts[i+1]]; newLines->InsertNextCell(2,newPts); } else { if (x1[0] >= p1[0] && x1[0] <= p2[0] && x1[1] >= p1[1] && x1[1] <= p2[1] ) {//first point in newPts[0] = pointMap[pts[i]]; } else {//second point in newPts[0] = pointMap[pts[i+1]]; } for (j=0; j<4; j++) { this->ClipPlanes->GetPoints()->GetPoint(j, px); this->ClipPlanes->GetNormals()->GetTuple(j, n); if ( vtkPlane::IntersectWithLine(x1,x2,n,px,t,xint) && t >= 0 && t <= 1.0 ) { newPts[1] = newPoints->InsertNextPoint(xint); break; } } newLines->InsertNextCell(2,newPts); }
}