# How to create a cylinder implicit with specified height

**URL:** https://discourse.vtk.org/t/how-to-create-a-cylinder-implicit-with-specified-height/681
**Category:** Support
**Created:** [April 4, 2019, 6:00am UTC](https://discourse.vtk.org/t/how-to-create-a-cylinder-implicit-with-specified-height/681 "2019-04-04T06:00:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Frank](https://discourse.vtk.org/user_avatar/discourse.vtk.org/frank/32/43_2.png) [@Frank](https://discourse.vtk.org/u/Frank)
#### Post date: [April 4, 2019, 6:00am UTC](https://discourse.vtk.org/t/how-to-create-a-cylinder-implicit-with-specified-height/681/1 "2019-04-04T06:00:29Z")

</div>

I want to create a implicit cylinder with specified height. From VTK doc, it says **The cylinder is infinite in extent. To truncate the cylinder in modeling operations use the vtkImplicitBoolean in combination with clipping planes.**

So I use the following code to truncate the cylinder.

```auto
auto plane1 = vtkSmartPointer<vtkPlane>::New();
plane1->SetOrigin(point1);
plane1->SetNormal(normal1);
auto plane2 = vtkSmartPointer<vtkPlane>::New();
plane2->SetOrigin(point2);
plane2->SetNormal(normal2);

auto cylinder = vtkSmartPointer<vtkCylinder>::New();
cylinder->SetRadius(radius);
cylinder->SetAxis(normal1);
auto theCylinder = vtkSmartPointer<vtkImplicitBoolean>::New();
theCylinder->SetOperationTypeToIntersection();
theCylinder->AddFunction(cylinder);
theCylinder->AddFunction(plane1);
theCylinder->AddFunction(plane2);

```

But the result has two caps on the cylinder. I only want to get specified height of cylindrical surface that is not closed.

How can I fix it.

---

<div class="post-metadata">

### Author: ![dlrdave](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlrdave/32/111_2.png) [@dlrdave](https://discourse.vtk.org/u/dlrdave)
#### Post date: [April 5, 2019, 9:25pm UTC](https://discourse.vtk.org/t/how-to-create-a-cylinder-implicit-with-specified-height/681/2 "2019-04-05T21:25:42Z")

</div>

Do you need the implicit function part of vtkCylinder, or are you just trying to visualize a cylinder?

If you just need to visualize a cylinder, you may find it easier to use vtkCylinderSource instead. The vtkCylinderSource class has a SetCapping method which allows you to turn capping on or off.

---

<div class="post-metadata">

### Author: ![Frank](https://discourse.vtk.org/user_avatar/discourse.vtk.org/frank/32/43_2.png) [@Frank](https://discourse.vtk.org/u/Frank)
#### Post date: [April 9, 2019, 11:55am UTC](https://discourse.vtk.org/t/how-to-create-a-cylinder-implicit-with-specified-height/681/3 "2019-04-09T11:55:58Z")

</div>

@dlrdave  
I need the **implicit function part of vtkCylinder** which looks like `vtkCylinderSource` with SetCapping(off). Because I will use `vtkImplicitBoolean` with cylinder and other implicit functions later.

---

<div class="post-metadata">

### Author: ![dlrdave](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dlrdave/32/111_2.png) [@dlrdave](https://discourse.vtk.org/u/dlrdave)
#### Post date: [April 13, 2019, 11:07am UTC](https://discourse.vtk.org/t/how-to-create-a-cylinder-implicit-with-specified-height/681/4 "2019-04-13T11:07:40Z")

</div>

The vtkImplicitFunction results have value 0 on the surface, are positive outside the surface, and negative inside the surface. Right now, all the points on the cylinder caps have value 0. Do you care if they get transformed into “inside” or “outside” values? Do the values themselves matter? I’m sure there’s a way to get rid of the caps, but I don’t know whether it’s important for your application to maintain the vtkCylinder values themselves in between the capping planes, or just the sense of “not on the surface”, or whether inside/outside really matters for you. So I’m not sure what to suggest.

Maybe a vtkCylinderSource can get you a polydata which you can use with vtkImplicitPolyDataDistance if you need implicit function capabilities, but with an uncapped cylinder.

If you could explain further what properties of the result you care about, maybe one of us can suggest a next step.

---

<div class="post-metadata">

### Author: ![Frank](https://discourse.vtk.org/user_avatar/discourse.vtk.org/frank/32/43_2.png) [@Frank](https://discourse.vtk.org/u/Frank)
#### Post date: [April 14, 2019, 3:40am UTC](https://discourse.vtk.org/t/how-to-create-a-cylinder-implicit-with-specified-height/681/5 "2019-04-14T03:40:28Z")

</div>

Thank you for your help. ~~Now I get a solution. After use `vtkSampleFunction` and `vtkContourFilter` to make implicit functin to `polydata`, I use `vtkClipPolyData` to cut the caps.~~

I am a newbie. My question is not clearly expressed. I just want to get the **union of several tube(without caps).** But I find that `vtkBooleanOperationPolyDataFilter` perform not well in some cases. So I use `vtkImplicitBoolean` and it perform well. But I do not know how to get an implicit function of a tube that does not have caps.

I used the `vtkImplicitPolyDataDistance`. It did not perform well. It creates tube infinite in extent after `vtkSampleFunction` and `vtkContourFilter`.

I do need the implicit functions because I will throw them in the `vtkImplicitBoolean`.
