mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
100.41k stars 35.2k forks source link

VTKLoader: Add support for more dataset format #13386

Open YoneMoreno opened 6 years ago

YoneMoreno commented 6 years ago

I would like to ask for advice because of I have one use case where I need to load VTK file which is a BINARY DATASET STRUCTURED POINTS, which represents a segmented image.

# vtk DataFile Version 3.0
VTK File Generated by Insight Segmentation and Registration Toolkit (ITK)
BINARY
DATASET STRUCTURED_POINTS
DIMENSIONS 1040 1040 1
SPACING 2.6455026988983699e-01 2.6455026988983699e-01 1.0000000000000000e+00
ORIGIN 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00
POINT_DATA 1081600
SCALARS scalars unsigned_short 1
LOOKUP_TABLE default

Binary data

Thank you for your help.

Mugen87 commented 6 years ago

Can you share your VTK file? I'm not sure if VTKLoader supports STRUCTURED_POINTS.

WestLangley commented 6 years ago

Cross-posted from SO.

Mugen87 commented 6 years ago

According to this document, VTK supports five different dataset formats: structured points, structured grid, rectilinear grid, unstructured grid, and polygonal data. After checking the source code, I can say that VTKLoader just supports the last one (POLYDATA).

836257514 commented 5 years ago

Hello, I meet the same issue, how to load the vtk point structure data. If current loader don't support, could we have a walk around, Or I can convert the file to any other format which totally support point data?

I just try read all the points and colors by self, and render it with a BufferGeometry

   let bufferGeometry=new THREE.BufferGeometry();
            bufferGeometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));
            bufferGeometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3));
            bufferGeometry.computeBoundingBox();

But the result seems not good. cloud you help me pls.

@Mugen87 @YoneMoreno

YingjuHan commented 2 years ago

How to load .vtu data? I tried to convert the vtu file to get the real coordinate data written to .json file and read it using BufferGeometryLoader, but the displayed result is wrong.

Mugen87 commented 2 years ago

Merging #23609 in this issue. VTKLoader should also support the "appended" data format.