Vtk-js: Can not render binary encoded stl files

Created on 30 May 2019  路  4Comments  路  Source: Kitware/vtk-js

Hello

I am sorry for repeated questions.

I implemented stlreader. I can load an ascii encoded stl file. However, binary encoded files can not be imported. I wrote the following code. I wrote this by referring to the following link.

https://kitware.github.io/vtk-js/api/IO_Geometry_STLReader.html

const corticalUrl = ThreeDLink + this.props.patientID + "/?type=heatmap_high";
.
.
.

const onCorticalLoad = vtkSTLReader.newInstance();
      const mapper1 = vtkMapper.newInstance({ scalarVisibility: false});
      const actor1 = vtkActor.newInstance({});

onCorticalLoad.setUrl(corticalUrl, { binary:true }).then(() => {
onCorticalLoad.loadData().then((update) => {

renderer.addActor(actor1);
this.renderWindow.render();
renderer.resetCamera();

   });
})

actor1.setMapper(mapper1);
actor1.getProperty().setColor(1.0, 0.0, 0.0);
actor1.rotateX(270);
actor1.setPosition(-3, 0, 208);
actor1.getProperty().setAmbient(0.8);      
mapper1.setInputConnection(onCorticalLoad.getOutputPort());

Can you help me if I missed or misunderstood?

Thank you

Most helpful comment

The XMLPolyDataReader does support ASCII, Binary, Appended, Appended+ZLib.

The legacy one is just ascii and does not support field data.

All 4 comments

Did you try your file with that example? Does it work?

Thank you for your reply.

In the above example, when I input a binary encoded stl file, it can be normally implemented.

I want to have something wrong with my code.

When I used the XMLPolyDataReader, the binary encoded vtp file was successfully implemented.

And,
Does the PolyDataReader support only the ascii format? A binary encoded vtk file is not implemented.

Thank you!

The XMLPolyDataReader does support ASCII, Binary, Appended, Appended+ZLib.

The legacy one is just ascii and does not support field data.

Thanks for the quick answer.

I'll use the XMLPolyDataReader to support the binary. And I'll check to see if I've missed any use of the STLReader.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings