replacement for CylinderSpatialObject?

ITK 4 had CylinderSpatialObject. However, this was (silently?) removed in SpatialObject Refactoring for ITKv5 · Pull Request #613. Is there a replacement for it?

Maybe TubeSO? @Stephen_Aylward can probably advise better.

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.

@Stephen_Aylward
Hello :slight_smile:
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.

Hello :slight_smile:
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.

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

2 Likes

Hi,

Just a note that the ITK 5 Migration Guide Spatial Objects Refactoring Section may be helpful here.