[vtkusers] Show whole volume under a slice

David Gobbi david.gobbi at gmail.com
Thu Feb 25 09:16:08 EST 2016


Hi Lonni,

Every mapper has a method called SetClippingPlanes() that you can use to
clip the data.  This will clip the data on the GPU while the data is being
rendered.

 - David

On Thu, Feb 25, 2016 at 6:43 AM, Lonni Besançon <lonni.besancon at gmail.com>
wrote:

> Hello,
>
> I set up all the code to make a cutting plane move the way I want it and I
> can actually get in an other image the actual slice that I'm looking at.
> However, what I'm trying to achieve now is different. Say my slice is in
> the
> middle of my volume I would to see half of that volume on my screen. I
> actually managed to do it a while ago with the simple BUNNY example and
> vtkPolyData but it does not work at all with my volume.
>
> Here is my code (skippin irrelevant parts to simplify reading):
>
> /        Renderer = vtkRenderer::New();
>         Renderer->SetBackground(.3, .6, .3);
>         RenderWindow->AddRenderer(Renderer.Get());
>
>         reader = vtkSmartPointer<vtkDataSetReader>::New();
>         reader->SetFileName(filename.c_str());
>         reader->Update();
>         imageData = vtkSmartPointer<vtkImageData>::New();
>         imageData->ShallowCopy(reader->GetOutput());
>         vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper> volumeMapper =
> vtkOpenGLGPUVolumeRayCastMapper::New();
>         volumeMapper->SetInputData(imageData);
>
>         vtkSmartPointer<vtkVolume> volume =
> vtkSmartPointer<vtkVolume>::New();
>         volume->SetMapper(volumeMapper);
>         volume->SetProperty(volumeProperty);
>         mainActor = volume ; //mainActor is a Prop3D
>         Renderer->AddViewProp(mainActor);
>         Renderer->ResetCamera();
>
>  ....
>
>         plane = vtkSmartPointer<vtkPlane>::New();
>         plane->SetTransform(vtkTransform::New());
>         plane->SetNormal(0,0,1);
>         plane->SetOrigin(0,0,20);
>
>         clipper = vtkSmartPointer<vtkClipDataSet>::New();
>         clipper->SetInputConnection(reader->GetOutputPort());
>         clipper->SetClipFunction(plane);
>         clipper->InsideOutOn();
>
>         mapperSliceData = vtkSmartPointer<vtkPolyDataMapper>::New();
>         mapperSliceData->SetInputConnection(clipper->GetOutputPort());
>
>         slicedActor = vtkSmartPointer<vtkActor>::New();
>         slicedActor->SetMapper(mapperSliceData);
>
>
>         Renderer->AddActor(slicedActor);
>         ctxView->Render();
> /
>
> Not only this piece of code does show me what I'd like to see, but above
> all
> it is extremely slow.
> Would you mind taking a look at the code and help me solve this problem?
>
> Thanks in advance
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160225/9a747aeb/attachment-0001.html>


More information about the vtkusers mailing list