vtkDiskSource in JS?

Hi everyone,
I would like to know if there is a vtkDiskSource js resource.
I basically want to make a sphere, use a cutter and a plane to cut the sphere, and use that output (a circle) to make a colored disk, being the output a vtkPolyData

I am using vtk js version 20.4.1
can anyone point me in the right direction?

Many thanks!

A disk is just a very short cylinder. The cylinder source documentation also suggests to use instead a vtkLineSource followed by a vtkTubeFilter when you know the end points of the cylinder.


vtkCircleSource with face=true should do it.

1 Like

thanks Mike and Julien, I will try it!
Best regards!

Hi everyone, it works very well, thank you!
I do have another question.
In c++ I could get the vtkPolydata->getpoints()->insertnextPoint() and
vtkPolydata->GetLines()->InsertNextCell () .

How can I add a cell (or line) to the existing polydata (circle with face) that I get in VTK JS?

Any one?

vtkPolyData use vtkDataArray which use Typed array. Those are fixed in size.
If you want to do the dynamic approach you have several options that will affect performance in different ways.

You can use plain JS array and then convert them back to typed array when updating points/cells/* from the vtk structure.

Or you can over allocate a typed array and just create a view to fit what you are actually using.

At the end it is up to you to provide the data to vtk.js in the proper form, you are just in control of what is more efficient for your use case using JS in its fullest capabilities.

sounds a bit too much for my JS skills.
I will simply add two lines and two actors. Done.

thanks again!