Howe to set vtkSplineFilter to DOUBLE_PRECISION?

Hi All,
I want uniformly resample a polyline using vtkSplineFilter. The input points are built with SetDataTypeToDouble(), however, the output of vtkSplineFilter is float.
Thanks

Hello,

Can you please, post the code of your attempt?

regards,

PC

Dear Carvalho, here is the code snippet:

pts=vtk.vtkPoints()
pts.SetDataTypeToDouble()
pts.InsertNextPoint(1,0,0)
pts.InsertNextPoint(1,1,0)
pts.InsertNextPoint(0,1,1)

sp=vtk.vtkParametricSpline()
sp.SetPoints(pts)
spf=vtk.vtkParametricFunctionSource()
spf.SetParametricFunction(sp)
spf.SetOutputPointsPrecision(vtk.vtkAlgorithm.DOUBLE_PRECISION)
spf.Update()
sf=vtk.vtkSplineFilter()
sf.SetInputData(spf.GetOutput())
sf.SetNumberOfSubdivisions(100)
sf.Update()
w=vtk.vtkPolyDataWriter()
w.SetFileName(ā€˜rsm.vtkā€™)
w.SetFileTypeToBinary()
w.SetInputData(sf.GetOutput())
w.Write()

Check the output of rsm.vtk we would see that it is float precision. Iā€™m using VTK9.2.6/Python 3.10 on Windows 11.

VTK/Filters/General/vtkSplineFilter.cxx at master Ā· Kitware/VTK (github.com)

As you can see here: A vtkPoints object is created which by default creates floats to save memory. There are several classes that have a Parameter named, OutputPointsPrecision, e.g. VTK: vtkClipPolyData Class Reference. Since itā€™s such a simple addition i feel like this would be a nice opportunity for you to contribute to VTK (possibly?) for the first time.

Feel free to create an MR at VTK / VTK Ā· GitLab (kitware.com) and add me as a reviewer.

1 Like

Thank you, Tsalikis.
I will look into the source. As regards the contribution, Iā€™m afraid Iā€™m not up to it/I donā€™t have time in the short future either.

Hello,

If you donā€™t feel like writing C++ code and undertake all that CI/CD workflow, you can at least file an issue requesting a new feature: https://gitlab.kitware.com/vtk/vtk/-/issues . E.g.: ā€œAdd Set/GetOutputPointsPrecion() to vtkSplineFilter classā€, then describe what you need and copy & paste what @spyridon97 said in the issue description.

regards,

PC

Hi,
I am possibly motivated to implement this feature, but here some additional information :

  1. I do not really need this feature
  2. I am not developer. I have experience in Python, but not too much in C++
  3. I had never contribute to any open source project, thus not experience with github/gitlab workflow (apart managing my own projects, which is no more than storing my dotfiles)
  4. I am an occasionally user of VTK/ParaView
  5. I has only compile VTK 2-3 times (just for curiosity) on Linux

ā€¦
but its been a long time that contributing to an open source project hanging around in my mind, and reading @spyridon97 proposition :

Since itā€™s such a simple addition i feel like this would be a nice opportunity for you to contribute to VTK (possibly?) for the first time

I feel that I cannot find better (i.e. simpler) opportunity to start with ā€¦ what do you think ? Is it a good idea ? If yes, do not expect tasks to be done cleanly the first time (may be some correction/adjustments to be done) and not before days/weeks (time to learn, to understand and become familiar with workflow).

I found some ressources within https://gitlab.kitware.com/vtk/vtk/-/blob/master/CONTRIBUTING.md

Is the master branch is the better version to fork or this feature should be implemented in a specific version ?

Regards,

I think that you should ago ahead and try it. I also had to make a couple of corrections for my first MR, so thatā€™s expected, donā€™t worry about it.

You should fork VTK and then create a new branch based on master which includes commits with your changes. Your last commit should be a changelog addition which should be placed in Documentation/release/dev. As i said, feel free to add me as a reviewer, and i will help you out.

Whether you decide to commit or not depends on your motivation. If you treat this as a technical / learning experience I think you will find the process rewarding. The VTK community IMO is very supportive and friendly, as long as you earnestly try to contribute you will receive support. It is expected that the process will take time and require multiple iterations - thatā€™s why there is a review process, even experts significantly benefit from community review and suggestions. Also, as a newcomer you have a valuable role to play: if there is an error or confusing documentation weā€™d like to hear about it so we can make things better.

Yes, start from the master branch.

ok, thanks @spyridon97 and @will.schroeder for your reply and your kindness, I am going to try it (probably start the processus next week).
Regards

issue created : https://gitlab.kitware.com/vtk/vtk/-/issues/19139

1 Like

Many thanks to the hint by @spyridon97 and the work by @gabokamaze . Also, I have modified the vtkLinearSubdivisionFilter and built the python wheel upon vtk9.3.0.rc2. If someone need this wheel, left an address, and I would like to send a copy via email.
Best regards.

1 Like