# A question about vtkOpenGLHardwareSelector::GeneratePolygonSelection

**URL:** https://discourse.vtk.org/t/a-question-about-vtkopenglhardwareselector-generatepolygonselection/9033
**Category:** Support
**Tags:** jobs
**Created:** [July 28, 2022, 8:57am UTC](https://discourse.vtk.org/t/a-question-about-vtkopenglhardwareselector-generatepolygonselection/9033 "2022-07-28T08:57:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![loufear](https://discourse.vtk.org/user_avatar/discourse.vtk.org/loufear/32/3150_2.png) [@loufear](https://discourse.vtk.org/u/loufear)
#### Post date: [July 28, 2022, 8:57am UTC](https://discourse.vtk.org/t/a-question-about-vtkopenglhardwareselector-generatepolygonselection/9033/1 "2022-07-28T08:57:02Z")

</div>

I use this method to get the visible surface of the ticked polygon data, but the output of the result is weird It looks like a part is missing, hope for help,

auto selector = vtkSmartPointer::New();  
selector-\>SetRenderer(this-\>m\_render);  
const int\* wsize = this-\>m\_render-\>GetSize();  
const int\* origin = this-\>m\_render-\>GetOrigin();  
selector-\>SetArea(origin[0], origin[1], origin[0] + wsize[0] - 1, origin[1] + wsize[1] - 1);  
selector-\>SetFieldAssociation(vtkDataObject::FIELD\_ASSOCIATION\_CELLS);  
if (selector-\>CaptureBuffers())  
{  
auto sel = selector-\>GeneratePolygonSelection(polygon.data(), res\_pts.size());

```
  auto extractSelection = vtkSmartPointer<vtkExtractSelection>::New();
  extractSelection->SetInputData(0, this->m_poly_data);
  extractSelection->SetInputData(1, sel);
  extractSelection->Update();

```

}

---

<div class="post-metadata">

### Author: ![loufear](https://discourse.vtk.org/user_avatar/discourse.vtk.org/loufear/32/3150_2.png) [@loufear](https://discourse.vtk.org/u/loufear)
#### Post date: [July 28, 2022, 8:59am UTC](https://discourse.vtk.org/t/a-question-about-vtkopenglhardwareselector-generatepolygonselection/9033/2 "2022-07-28T08:59:03Z")

</div>

The polygon data is the convex hull from opencv The point set used is the trajectory of the mouse

---

<div class="post-metadata">

### Author: ![loufear](https://discourse.vtk.org/user_avatar/discourse.vtk.org/loufear/32/3150_2.png) [@loufear](https://discourse.vtk.org/u/loufear)
#### Post date: [July 28, 2022, 9:04am UTC](https://discourse.vtk.org/t/a-question-about-vtkopenglhardwareselector-generatepolygonselection/9033/3 "2022-07-28T09:04:12Z")

</div>

[Rendering/Core/Testing/Cxx/TestPolygonSelection.cxx · master · VTK / VTK · GitLab (kitware.com)](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/Core/Testing/Cxx/TestPolygonSelection.cxx#L132) This is my reference

---

<div class="post-metadata">

### Author: ![yangyang117](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/da6949/32.png) [@yangyang117](https://discourse.vtk.org/u/yangyang117)
#### Post date: [December 17, 2023, 1:44am UTC](https://discourse.vtk.org/t/a-question-about-vtkopenglhardwareselector-generatepolygonselection/9033/4 "2023-12-17T01:44:15Z")

</div>

Hi, Im using the python code for the selection.  
I see it need to translate the address of data and the lenth of data in using `hardSel->GeneratePolygonSelection`  
But in Python, it cannot translate the data’s address. Is there any way to fix it? or other api?
