0

I am building a simple tool for manipulating point clouds. I want to be able to do do a polygonal selection on mouse move. I am working with VTK 5.10 and QVTKWidget in Ubuntu 12.04.

To do this, I built a polygonalSelector class by modifying the test file : TestPolygonSelection.cxx at https://github.com/Kitware/VTK/blob/master/Rendering/Core/Testing/Cxx/TestPolygonSelection.cxx The modifications are those needed to use VTK 5.10 instead of vtk 6 as described here : (note that I need to use the old version) http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput

In the code, a polygonal shape is drawn and then a vtkHardwareSelector object vtkNew<vtkHardwareSelector> hardSel; is used for its method of GeneratePolygonSelection:

The problem I am running into is when the next condition is tested :

if (hardSel->CaptureBuffers())

Internally, CaptureBuffers() contains code that does this:

  vtkRenderWindow *rwin = this->Renderer->GetRenderWindow();
  int rgba[4];
  rwin->GetColorBufferSizes(rgba);
  if (rgba[0] < 8 || rgba[1] < 8 || rgba[2] < 8)
  {
    vtkErrorMacro("Color buffer depth must be atleast 8 bit. "
      "Currently: " << rgba[0] << ", " << rgba[1] << ", " <<rgba[2]);
    return false;
  }

I never get past this point because it always returns false. I have no clue how to set the ColorBufferSizes and I have not been able to find info online to clear this point. This is the error output:

  vtkHardwareSelector (0x168dcd0): Color buffer depth must be atleast 8 bit. Currently: 17727456, 0, 23649488

On debugging, the rgba int is never changed (it stays the same before and after the call to rwin->GetColorBufferSizes(rgba) ).

On the Documentation for vtkRenderWindow it states that :

virtual int vtkRenderWindow::GetColorBufferSizes    (   int *   rgba    )
Get the size of the color buffer. Returns 0 if not able to determine otherwise sets R G B and A into buffer.

Implemented in vtkOpenGLRenderWindow, and vtkOpenGLRenderWindow.

Do I need to use vtkOpenGLRenderWindow? On its Class reference it states that "Application programmers should normally use vtkRenderWindow instead of the OpenGL specific version."

Any ideas?

EDIT

I believe the problem stems from the VTK 5.10 vs VTK 6 differences.

I did manage to implement the polygonal selection using a different approach. If anyone intends to implement some kind of polygonal selection in the future, they might find these steps useful:

I sub-classed vtkInteractorStyleDrawPolygon and implemented the following steps inside the OnLeftButtonUp() method:

  1. Get points on button release: std::vector<vtkVector2i> points = this->GetPolygonPoints();

  2. Insert points to vtkDoubleArray

  3. Insert the vtkDoubleArray into a vtkPolygon

  4. Get the polygon's numPoints, normal and bounds.

  5. Get pointer to the double array inside the polygon data pts.

    pts = static_cast<double*>(polygon->GetPoints()->GetData()->GetVoidPointer(0);
    
  6. For each point P in the vtkPolyData, do :

    inside = polygon->PointInPolygon(P,numPoints, pts, bounds,normal)
    
  7. Add points to a vtkSelection when inside == 1

  • I have not tried, but I see in the documentation a link to vtkScenePicker , where they say: "This class uses a vtkHardwareSelector under the hood. Hence, it will work only for actors that have opaque geomerty and are rendered by a vtkPolyDataMapper." . Could it be the problem? – lib Mar 04 '15 at 07:16
  • You can also try the other tests in http://www.vtk.org/doc/release/5.10/html/c2_vtk_t_7.html#c2_vtk_t_vtkHardwareSelector , the links are broken but you find the same files in your source tree – lib Mar 04 '15 at 07:18
  • I read the note about opaque geometry and the Poly Data requirements. I think what I do should not cause any problem, but thanks!. I'll check the other version of the tests to see if there is any significant difference. – Pablo Frank Mar 04 '15 at 13:48

0 Answers0