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

feat(polydatacellnormals): compute cell normals #2436

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emil-peters
Copy link
Contributor

Context

closes #2434

Gives the option through setComputeCellNormals to compute the cell normals for polyData using the vtkPolyDataNormals filter.

Results

Changes

  • Added option to include cell normals. These can be accessed through polyData.getCellData().getNormals().getData()
  • STATIC method on the vtkPolyDataNormals filter to compute the cell normals
  • Created an example for the vtkNormals which for now visualizes the cell normals.

image

  • Documentation and TypeScript definitions were updated to match those changes
    -> Question related to this: can you autogenerate TS-def files? Or should these be created manually?

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

TODO

I was thinking it might make sense to either change the publicAPI.vtkPolyDataNormalsExecute to accept only one parameter, which would be vtkPolyData.

Or to merge publicAPI.vtkPolyDataNormalsExecute and publicAPI.vtkPolyDataCellNormalsExecute into one method, as there is quite some duplication in both?

I don't know what would be preferred.

Update the example to switch between cell and vertex normals

@@ -105,6 +153,13 @@ function vtkPolyDataNormals(publicAPI, model) {

output.getPointData().setNormals(outputNormals);

if (model.computeCellNormals) {
const outputCellNormalsData =
publicAPI.vtkPolyDataCellNormalsExecute(input);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's too bad you are recomputing the normals that were computed when doing points normals.

Can you please modify vtkPolyDataNormalsExecute to optionally return cells normals ?

CELL: 'cell',
POINT: ' point',
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not seem used, is it ?

@finetjul
Copy link
Member

Can you please also update index.js.ts with the new set/get accessors ?

numberOfPoints = polysData[c];

if (numberOfPoints < 3) {
continue; // eslint-disable-line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent pb

(v1[2] + v2[2] + v3[2]) / 3,
];

const line = vtkLineSource.newInstance({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about an arrow source instead ?

(alternatively, you can consider vtkGlyphMapper3D)

(v1[0] + v2[0] + v3[0]) / 3,
(v1[1] + v2[1] + v3[1]) / 3,
(v1[2] + v2[2] + v3[2]) / 3,
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good candidate to be exposed publicly in vtkTriangle as a static function.

See vtkTriangle::TriangleCenter in C++

@finetjul
Copy link
Member

Apologies for my comments, I just saw your questions in the PR.

For TODO #1, I would prefer something like: publicAPI.vtkPolyDataNormalsExecute(polyData, computePointNormals = true, computeCellNormals = false)

For TODO #2, it's a good idea to expose a UI to toggle computeCellsNormals

@finetjul
Copy link
Member

finetjul commented Jun 8, 2022

@emil-peters have you had a chance to look at the suggestions ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vtkPolyDataNormals - Cell Normals
2 participants