Skip to content

Commit

Permalink
fix(plywriter): fix vtkPLYWriter normals
Browse files Browse the repository at this point in the history
Also update the example and associated example image for the gallery
  • Loading branch information
finetjul committed Jan 15, 2024
1 parent 3d2ff18 commit 4945167
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Binary file modified Documentation/content/docs/gallery/PLYWriterWithIcon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions Sources/IO/Geometry/PLYWriter/example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ const reader = vtkPolyDataReader.newInstance();
const writerReader = vtkPLYReader.newInstance();

const writer = vtkPLYWriter.newInstance();
writer.setInputConnection(reader.getOutputPort());
reader
.setUrl(`${__BASE_PATH__}/data/legacy/sphere.vtk`, { loadData: true })
.then(() => {
writer.setInputData(reader.getOutputData());

// writer.setTextureFileName('mytexture.jpg');

const fileContents = writer.getOutputData();
writerReader.parseAsText(new TextEncoder().encode(fileContents));
// Can also use a static function to write to PLY:
// const fileContents = vtkPLYWriter.writePLY(reader.getOutputData());
// writerReader.parseAsArrayBuffer(fileContents.buffer);

// Display the resulting PLY
writerReader.parseAsArrayBuffer(fileContents.buffer);
renderer.resetCamera();
renderWindow.render();

Expand Down
6 changes: 3 additions & 3 deletions Sources/IO/Geometry/PLYWriter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ function writePLY(
}

if (normals) {
nx = normals.getData()[i * 2];
ny = normals.getData()[i * 2 + 1];
nz = normals.getData()[i * 2 + 2];
nx = normals.getData()[i * 3];
ny = normals.getData()[i * 3 + 1];
nz = normals.getData()[i * 3 + 2];
}

writer.writeVertice(x, y, z, nx, ny, nz, u, v, r, g, b);
Expand Down

0 comments on commit 4945167

Please sign in to comment.