# Creating a finite vtkcylinder and using it extractpolydata

**URL:** <https://discourse.vtk.org/t/creating-a-finite-vtkcylinder-and-using-it-extractpolydata/13465>\
**Category:** Development\
**Created:** [March 6, 2024, 8:08pm UTC](https://discourse.vtk.org/t/creating-a-finite-vtkcylinder-and-using-it-extractpolydata/13465 "2024-03-06T20:08:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafael\_Scatena](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rafael_scatena/32/7820_2.png) [@Rafael\_Scatena](https://discourse.vtk.org/u/Rafael_Scatena)\
**Post date:** [March 6, 2024, 8:08pm UTC](https://discourse.vtk.org/t/creating-a-finite-vtkcylinder-and-using-it-extractpolydata/13465/1 "2024-03-06T20:08:37Z")

</div>

Hello,

I am trying to generate a finete vtkcylinder subtracting 2 planes from a traditional vtkcylinder. The I would like to use this finite to extract cells from a larger polydata. But I don’t get any cells returned…

Thank you

```
double normalized[3];

// Calculate the midpoint
double midpoint[3];for (int i = 0; i < 3; ++i) {midpoint[i] = (point1[i] + point2[i]) / 2.0;}

// The X axis is a vector from start to end
vtkMath::Subtract(point2, point1, normalized); double length = vtkMath::Norm(normalized);
vtkMath::Normalize(normalized);

  vtkNew<vtkCylinder> implicitCylinder;
  implicitCylinder->SetRadius(0.1);
  implicitCylinder->SetAxis(normalized);
  implicitCylinder->SetCenter(midpoint);	  

// Create vtkPlaneSource for the first plane
vtkNew<vtkPlane> planeSource1;
planeSource1->SetOrigin(point1);
planeSource1->SetNormal(normalized);

vtkNew<vtkPlane> planeSource2;
planeSource2->SetOrigin(point2);
planeSource2->SetNormal(normalized);

// combine the two implicit functions
  vtkNew<vtkImplicitBoolean> boolean;
  boolean->AddFunction(implicitCylinder);
  boolean->AddFunction(planeSource1);
      boolean->SetOperationTypeToDifference();

  vtkNew<vtkImplicitBoolean> boolean2;
  boolean2->AddFunction(boolean);	
  boolean2->AddFunction(planeSource2);	
      boolean2->SetOperationTypeToDifference();

    vtkNew<vtkExtractPolyDataGeometry> extractGeometry;
    extractGeometry->SetImplicitFunction(boolean2);
    extractGeometry->SetInputData(globalPolyData);
    extractGeometry->ExtractInsideOn();
    extractGeometry->ExtractBoundaryCellsOn();
    extractGeometry->Update();

```

I get:

```
There are 0 clipped points.
There are 0 clipped cells.

2024-03-06 16:40:17.416 ( 85.907s) [7FDAC5A575C0] vtkOBBTree.cxx:1078 ERR| vtkOBBTree (0x55f2710abb70): Can't build OBB tree - no data available!
Time for Local OBB , Max Level:0 Cells Per Bucket: 25 Data Structure Construction: 3.92847 seconds

```

---

<div class="post-metadata">

**Author:** ![Rafael\_Scatena](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rafael_scatena/32/7820_2.png) [@Rafael\_Scatena](https://discourse.vtk.org/u/Rafael_Scatena)\
**Post date:** [March 6, 2024, 9:03pm UTC](https://discourse.vtk.org/t/creating-a-finite-vtkcylinder-and-using-it-extractpolydata/13465/2 "2024-03-06T21:03:11Z")

</div>

I plotted a line source with the same direction:

![Captura de tela de 2024-03-06 18-02-06](https://discourse.vtk.org/uploads/default/original/2X/6/658b0174d52ccb12c3525c84444b226c7a419307.png)
