Clipping Geometry

I’d like to make a widget like the ImageCroppingWidget but for geometry.

These models are generally vtkjs scenes made up of multiple datasets like the one below:
Screen Shot 2022-03-25 at 6.25.44 PM

I was considering a way to use the vtkCutter filter but I’m not sure how to adapt it to cut the scene globally.

I’m thinking something like the following:

const plane = vtkPlane.newInstance()
const cutter = vtkCutter.newInstance()
cutter.setCutFunction(plane)
 
renderer.getActors().forEach((actor) => {
  cutter.setInputConnections(actor.getMapper().getInputData().getOutputPort())
})

Do you have any tips as to how to implement this feature?

Thanks in advance! :pray:

I think you can do it on the GPU directly by adding planes to the mapper.

Hey @Sebastien_Jourdain thanks, that sounds like a much better idea. I’ll give it a go and let you know how it goes.

1 Like

Thanks for the suggestion @Sebastien_Jourdain, it’s working great.

Code:

const xyPlane = vtkPlane.newInstance({
  normal: [0, 0, 1],
  origin: [0, 0, 1]
})

renderer.getActors().forEach((actor) => {
  actor.getMapper().addClippingPlane(xyPlane)
})

1 Like