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