[vtk-developers] vtkXYPlotActor clipping issue

Mathieu Coursolle mathieu at rogue-research.com
Wed Nov 11 11:30:30 EST 2009


Hi VTK developers,

I have an issue where my application crashed and/or fails to render a vtkXYPlotActor properly
when the input data needs to be clipped.

After some investigation, I tracked the issue down to vtkXYPlotActor::ClipPlotData(...).

Here is what I think is the code in cause here. The code test if x1 is out of range. If so, it assumes that x2 is in range,
which is not always the case for me. Therefore, I end up with an id of -1 in my cells.

Is that a bug, or some desired behaviour I am not getting here.

Thanks,

Mathieu
_________________________
Mathieu Coursolle, ing.jr., M.Ing.
Rogue Research Inc.
www.rogue-research.com


//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  // << ****************************What if x2 is out of range ??? **********
        {//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;
          }
       }
  }








-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20091111/81d34186/attachment.html>


More information about the vtk-developers mailing list