[vtkusers] volume mapper error
Abhishek
abhishekworld at gmail.com
Wed Nov 14 20:07:13 EST 2018
Hi Frank,
I am not entirely sure but looking at the code looks like you have to do
ren->AddViewProp(volume); instead of ren->AddVolume(volume);
have a look at
https://lorensen.github.io/VTKExamples/site/Cxx/Medical/MedicalDemo4/
Cheers,
Abhishek
On Wed, Nov 14, 2018 at 12:09 PM Franks <masterwangzx at gmail.com> wrote:
> Hi,
> I want to test the volume mapper. I read the data from .vtk file and change
> its points attributes(vtkUnsignedCharArray with one component) to the
> vtkFloatArray with two components. Then I volume render it. But I get the
> "Segmentation fault".
>
> auto reader = vtkSmartPointer<vtkStructuredPointsReader>::New();
> reader->SetFileName("../mummy.128.vtk");
> reader->Update();
>
> auto tuples = vtkSmartPointer<vtkFloatArray>::New();
> tuples->DeepCopy(reader->GetOutput()->GetPointData()->GetScalars());
> tuples->SetNumberOfComponents(2);
> for (int i = 0; i < tuples->GetNumberOfTuples(); ++i) {
> tuples->SetTuple2(i,80,80);
> }
>
> reader->GetOutput()->GetPointData()->RemoveArray(0);
> reader->GetOutput()->GetPointData()->SetScalars(tuples);
>
> auto volumeMapper = vtkSmartPointer<vtkSmartVolumeMapper>::New();
> volumeMapper->SetInputConnection(reader->GetOutputPort());
>
> auto volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();
>
> auto compositeOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
> compositeOpacity->AddPoint(40, 0.00);
> compositeOpacity->AddPoint(60, 0.40);
> volumeProperty->SetScalarOpacity(compositeOpacity);
>
> auto color = vtkSmartPointer<vtkColorTransferFunction>::New();
> color->AddRGBPoint(0.000, 0.00, 0.00, 0.00);
> color->AddRGBPoint(64.00, 1.00, 0.52, 0.30);
> volumeProperty->SetColor(color);
>
> auto volume = vtkSmartPointer<vtkVolume>::New();
> volume->SetMapper(volumeMapper);
> volume->SetProperty(volumeProperty);
>
> auto ren = vtkSmartPointer<vtkRenderer>::New();
> ren->AddVolume(volume);
> ren->SetBackground(1, 1, 1);
>
> auto renWin = vtkSmartPointer<vtkRenderWindow>::New();
> renWin->AddRenderer(ren);
>
> auto style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
> auto iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
> iren->SetRenderWindow(renWin);
> iren->SetInteractorStyle(style);
>
> iren->Initialize();
> iren->Start();
>
> Best regards
> Frank
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
>
--
Abhishek
http://zeroth.me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20181115/2cfd1156/attachment.html>
More information about the vtkusers
mailing list