Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vtkCalculator fails with vtkImageData as input #2257

Closed
davidborland opened this issue Jan 31, 2022 · 1 comment · Fixed by #2928
Closed

vtkCalculator fails with vtkImageData as input #2257

davidborland opened this issue Jan 31, 2022 · 1 comment · Fixed by #2928
Labels
good first issue 👋 released Automated label type: bug 🐞 Errors in functionality

Comments

@davidborland
Copy link

davidborland commented Jan 31, 2022

High-level description

vtkCalculator does not work on vtkImageData because vtkImageData does not have a getPoints method.

Steps to reproduce

  1. Use vtkImageData as an input to vtkCalculator.
  2. Call setFormulaSimple, e.g.
calculator.setFormulaSimple(
    FieldDataTypes.POINT,
    ['scalars'],
    'mask',
    value => value > 10 ? 1 : 0
  );

Detailed behavior

getPoints is called in two locations in prepareArrays that cause problems for the above scenario:

  1. line 128: arraysIn.push(inData.getPoints());
    (This is due to the coordinate data that gets added in augmentInputArrays)

  2. line 194: (x) => x.getPoints().getNumberOfPoints(),

Expected behavior

I was able to get it working for my use case (applying a simple threshold to some image data) by placing checks before the getPoints calls:

  1. if (inData.getPoints) arraysIn.push(inData.getPoints());
  2. (x) => x.getPoints ? x.getPoints().getNumberOfPoints() : x.getNumberOfPoints()

Not sure if this is the preferred solution though.

Environment

  • vtk.js: v22.2.2
  • OS: Ubuntu-18.04 VM running on Windows 10
  • Browser: Chrome Version 97.0.4692.99 (Official Build) (64-bit) (Windows)
@davidborland davidborland added the type: bug 🐞 Errors in functionality label Jan 31, 2022
bourdaisj added a commit to bourdaisj/vtk-js that referenced this issue Sep 29, 2023
do not call getPoints on the input dataset if it not necessary

fix Kitware#2257
github-merge-queue bot pushed a commit that referenced this issue Oct 2, 2023
do not call getPoints on the input dataset if it not necessary

fix #2257
@github-actions
Copy link

github-actions bot commented Oct 2, 2023

🎉 This issue has been resolved in version 28.12.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot added the released Automated label label Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue 👋 released Automated label type: bug 🐞 Errors in functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants