Kitware / itk-vtk-viewer

2D / 3D web image, mesh, and point set viewer using itk-wasm and vtk.js
https://kitware.github.io/itk-vtk-viewer/
BSD 3-Clause "New" or "Revised" License
210 stars 64 forks source link

Add cropping planes controlled by 3D widget or viewer API #397

Closed thewtex closed 2 years ago

thewtex commented 3 years ago

Volumes, image slices, geometries and point sets are cropped (aka clipped) by a shared box of planes. Adding a new image/geometry will reset the crop box to encompass all data in the scene.

Can set 6 arbitrary clip planes with a function on the viewer object.

const [iMin, iMax, jMin, jMax, kMin, kMax] = [0, 3, 0, 3, 0, 3]
const origin = [iMin, jMin, kMin]
// opposite corner from origin
const corner = [iMax, jMax, kMax]
const planes = [
  // X min/max
  { normal: [1, 0, 0], origin },
  {
    normal: [-1, 0, 0],
    origin: corner,
  },
  // Y min/max
  { normal: [0, 1, 0], origin },
  {
    normal: [0, -1, 0],
    origin: corner,
  },
  // X min/max
  { normal: [0, 0, 1], origin },
  {
    normal: [0, 0, -1],
    origin: corner,
  },
]
viewer.setCroppingPlanes(planes)
thewtex commented 2 years ago

Thanks for the updates.

PaulHax commented 2 years ago

@thewtex This feature is coming together. I've tested with http://localhost:8082/?fileToLoad=https://data.kitware.com/api/v1/file/5a826c198d777f0685782976/download/test_vmtkbranchmetrics_branch_metrics_surf.vtp&image=test-data/HeadMRVolume.nrrd

What should the widgetCroppingPlanesFlip do?

thewtex commented 2 years ago

@PaulHax fantastic!!

widgetCroppingPlanesFlip may just have been a debug state to find out how the crop normal was interpreted by vtk -- we could remove it.

PaulHax commented 2 years ago

@thewtex This should be ready. Maybe a squash and merge?

thewtex commented 2 years ago

@PaulHax thank you!!

Looks good!

History is complicated -- we could forgo a squash in the interest of getting it in.

Only item I noticed in review that debug builds of the wasm modules crept in. I will update to the latest itk-wasm (includes new optimizations), and push Release builds.

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 14.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: