Tapered "cylinder".

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Tapered "cylinder".

M_skov
Hello there.

Disclaimer, I am quite new to using VTK, and even coding in general (which
is done in Python).
I am trying to visualize a tapered hollow cylinder, I have start and
end-coordinates (x,y,z) and a different diameter at each coordinate.
     ___
   /      \
  /        \  This is basically what I want.
 /_____ \  

I have searched, quite a bit, but have yet to find a solution to this.
As of right now, when the diameters are equal, I am visualizing the cylinder
as an extruded disk, transforming it for the orientation, which works
perfectly!

I have been looking at vtktubefilter, but as I see it, I end up losing my
wall thickness using that option.
Is there a radius scaling factor I have overlooked, or other functions that
can help me accomplish this?

Hoping the question is clear and that someone is able to assist me in this.
Have a nice day!

- Martin




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Tapered "cylinder".

kenichiro yoshimi
Hi,

The easiest way to create a tapered hollow cylinder is scaling the
points on top surface of the cylinder created as an extrusion of a
disk. The sample code below shows this:

------
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vtk


def main():
    colors = vtk.vtkNamedColors()

    diskSource = vtk.vtkDiskSource()
    diskSource.SetInnerRadius(0.5);
    diskSource.SetOuterRadius(1.0);
    diskSource.SetRadialResolution(1);
    diskSource.SetCircumferentialResolution(40);

    # Apply linear extrusion
    extrude = vtk.vtkLinearExtrusionFilter()
    extrude.SetInputConnection(diskSource.GetOutputPort())
    extrude.SetExtrusionTypeToNormalExtrusion();
    extrude.SetVector(0, 0, 2)
    extrude.Update()

    # Taper the cylinder
    scale = 0.5
    taperedCylinder = extrude.GetOutput()
    points = taperedCylinder.GetPoints()
    numPts = taperedCylinder.GetNumberOfPoints()
    for ptId in range(numPts/2, numPts):
      point = points.GetPoint(ptId)
      points.SetPoint(ptId, point[0]*scale, point[1]*scale, point[2])

    # Create a mapper and actor.
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputData(taperedCylinder)

    actor = vtk.vtkActor()
    actor.GetProperty().SetColor(colors.GetColor3d("Cornsilk"))
    actor.SetMapper(mapper)

    # Create a renderer, render window, and interactor
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.SetWindowName("TaperedCylinder")
    renderWindow.AddRenderer(renderer)
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    # Add the actors to the scene
    renderer.AddActor(actor)
    renderer.SetBackground(colors.GetColor3d("DarkGreen"))

    # Render and interact
    renderWindow.Render()
    renderWindowInteractor.Start()


if __name__ == '__main__':
    main()
------

Regards
2018年7月12日(木) 21:12 M_skov <[hidden email]>:

>
> Hello there.
>
> Disclaimer, I am quite new to using VTK, and even coding in general (which
> is done in Python).
> I am trying to visualize a tapered hollow cylinder, I have start and
> end-coordinates (x,y,z) and a different diameter at each coordinate.
>      ___
>    /      \
>   /        \  This is basically what I want.
>  /_____ \
>
> I have searched, quite a bit, but have yet to find a solution to this.
> As of right now, when the diameters are equal, I am visualizing the cylinder
> as an extruded disk, transforming it for the orientation, which works
> perfectly!
>
> I have been looking at vtktubefilter, but as I see it, I end up losing my
> wall thickness using that option.
> Is there a radius scaling factor I have overlooked, or other functions that
> can help me accomplish this?
>
> Hoping the question is clear and that someone is able to assist me in this.
> Have a nice day!
>
> - Martin
>
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Tapered "cylinder".

David E DeMarle via vtkusers
Or you could use vtkRotationalExtrusionFilter with an angled line.

Todd Martin, PhD.
Freelance Engineer/Software Architect.



On Friday, July 13, 2018, 1:21:53 PM GMT+12, kenichiro yoshimi <[hidden email]> wrote:


Hi,

The easiest way to create a tapered hollow cylinder is scaling the
points on top surface of the cylinder created as an extrusion of a
disk. The sample code below shows this:

------
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vtk


def main():
    colors = vtk.vtkNamedColors()

    diskSource = vtk.vtkDiskSource()
    diskSource.SetInnerRadius(0.5);
    diskSource.SetOuterRadius(1.0);
    diskSource.SetRadialResolution(1);
    diskSource.SetCircumferentialResolution(40);

    # Apply linear extrusion
    extrude = vtk.vtkLinearExtrusionFilter()
    extrude.SetInputConnection(diskSource.GetOutputPort())
    extrude.SetExtrusionTypeToNormalExtrusion();
    extrude.SetVector(0, 0, 2)
    extrude.Update()

    # Taper the cylinder
    scale = 0.5
    taperedCylinder = extrude.GetOutput()
    points = taperedCylinder.GetPoints()
    numPts = taperedCylinder.GetNumberOfPoints()
    for ptId in range(numPts/2, numPts):
      point = points.GetPoint(ptId)
      points.SetPoint(ptId, point[0]*scale, point[1]*scale, point[2])

    # Create a mapper and actor.
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputData(taperedCylinder)

    actor = vtk.vtkActor()
    actor.GetProperty().SetColor(colors.GetColor3d("Cornsilk"))
    actor.SetMapper(mapper)

    # Create a renderer, render window, and interactor
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.SetWindowName("TaperedCylinder")
    renderWindow.AddRenderer(renderer)
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    # Add the actors to the scene
    renderer.AddActor(actor)
    renderer.SetBackground(colors.GetColor3d("DarkGreen"))

    # Render and interact
    renderWindow.Render()
    renderWindowInteractor.Start()


if __name__ == '__main__':
    main()
------

Regards
2018年7月12日(木) 21:12 M_skov <[hidden email]>:

>
> Hello there.
>
> Disclaimer, I am quite new to using VTK, and even coding in general (which
> is done in Python).
> I am trying to visualize a tapered hollow cylinder, I have start and
> end-coordinates (x,y,z) and a different diameter at each coordinate.
>      ___
>    /      \
>  /        \  This is basically what I want.
>  /_____ \
>
> I have searched, quite a bit, but have yet to find a solution to this.
> As of right now, when the diameters are equal, I am visualizing the cylinder
> as an extruded disk, transforming it for the orientation, which works
> perfectly!
>
> I have been looking at vtktubefilter, but as I see it, I end up losing my
> wall thickness using that option.
> Is there a radius scaling factor I have overlooked, or other functions that
> can help me accomplish this?
>
> Hoping the question is clear and that someone is able to assist me in this.
> Have a nice day!
>
> - Martin
>
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Tapered "cylinder".

M_skov
In reply to this post by kenichiro yoshimi
Hello,

Thank you very much for the answers. The scaling was exactly what I was
looking for. Did not know I could get the circumferential points that way,
thanks a lot for your assistance.

I will have a look at the rotational filter as well. Maybe that is useful in
another situation!

I appreciate your help, I hope you'll have a good day.

- Martin



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers