# replacement for CylinderSpatialObject?

**URL:** https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771
**Category:** Community
**Created:** [January 17, 2021, 11:48pm UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771 "2021-01-17T23:48:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![KrisThielemans](https://discourse.itk.org/user_avatar/discourse.itk.org/kristhielemans/32/1633_2.png) [@KrisThielemans](https://discourse.itk.org/u/KrisThielemans)
#### Post date: [January 17, 2021, 11:48pm UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771/1 "2021-01-17T23:48:14Z")

</div>

ITK 4 had `CylinderSpatialObject`. However, this was (silently?) removed in [SpatialObject Refactoring for ITKv5 · Pull Request #613](https://github.com/InsightSoftwareConsortium/ITK/pull/613). Is there a replacement for it?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [January 18, 2021, 10:35pm UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771/2 "2021-01-18T22:35:54Z")

</div>

Maybe [TubeSO](https://itk.org/Doxygen/html/classitk_1_1TubeSpatialObject.html)? @Stephen_Aylward can probably advise better.

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [February 17, 2021, 6:56pm UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771/3 "2021-02-17T18:56:50Z")

</div>

Yes - a cylinder is the same as a tube comprised of two points. If this become challenging for you to update your project to this new representation, please let me know. We would easily bring back the cylinder spatial object.

---

<div class="post-metadata">

### Author: ![tnsnz](https://discourse.itk.org/user_avatar/discourse.itk.org/tnsnz/32/3647_2.png) [@tnsnz](https://discourse.itk.org/u/tnsnz)
#### Post date: [August 18, 2023, 4:44am UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771/4 "2023-08-18T04:44:23Z")

</div>

@Stephen_Aylward  
Hello 🙂  
I’m trying migration version to ITKv5 from ITKv4.  
I faced this problem. How to change CylinderSO to TubeSO?  
I can’t use (get/set) Radius and Height in TubeSO.  
please let me know your know how.

---

<div class="post-metadata">

### Author: ![tnsnz](https://discourse.itk.org/user_avatar/discourse.itk.org/tnsnz/32/3647_2.png) [@tnsnz](https://discourse.itk.org/u/tnsnz)
#### Post date: [August 18, 2023, 6:48am UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771/5 "2023-08-18T06:48:01Z")

</div>

Hello 🙂  
I’m trying migration version to ITKv5 from ITKv4.  
I faced this problem. How to change CylinderSO to TubeSO?  
I can’t use (get/set) Radius and Height in TubeSO.  
please let me know your know how.

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [August 19, 2023, 9:11pm UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771/6 "2023-08-19T21:11:31Z")

</div>

Hi,

Sorry for breaking backward compatibility.

A tube and cylinder are conceptually so similar, that I did not keep the cylinder when I updated spatial objects; however, their APIs are quite different. In hindsight, I should have kept cylinder and made it a derived class of Tube, and then I could have kept the API.

If you want, we’d welcome your contribution to ITK, if you wanted to implement a cylinder spatial object as a special case of a tube. The ideas is that a Cylinder is a tube with two points - one at 0,0,0 and the other at 0,0, and both points have a radius of

You can implement this without creating a derived class by the following pseudo-code:

```
TypeType::Pointer tube = TubeType::New();
tube->GetProperty().SetName("Cylinder");
tube->SetId(1);

TubePointListType pointList;
TubePointType p1, p2;
p1.SetPositionInObjectSpace(0,0,0);
p1.SetRadiusInObjectSpace(radius);
pointList.push_back(p1);
p2.SetPositionInObjectSpace(0,0,height);
p2.SetRadiusInObjectSpace(radius);
pointList.push_back(p2);
tube->SetPoints(pointList);
tube->Update();

```

Then you can call functions such as “tube-\>IsInsideInWorldSpace(testpoint);” and it should behave as a cylinder, and you will be able to load/save the object as a MetaTube.

Hope this helps,  
Stephen

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [October 18, 2023, 7:03pm UTC](https://discourse.itk.org/t/replacement-for-cylinderspatialobject/3771/7 "2023-10-18T19:03:51Z")

</div>

Hi,

Just a note that the [ITK 5 Migration Guide Spatial Objects Refactoring](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Documentation/ITK5MigrationGuide.md#spatial-objects-refactoring) Section may be helpful here.
