Discussion:
[vtkusers] volume mapper error
Franks
2018-11-14 01:09:50 UTC
Permalink
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
2018-11-15 01:07:13 UTC
Permalink
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
Post by Franks
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
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
https://public.kitware.com/mailman/listinfo/vtkusers
--
Abhishek
http://zeroth.me
Franks
2018-11-15 02:06:39 UTC
Permalink
Hi Abhishek

Thank you for getting back to me. I do what you said. But I still get the
"SIGSEGV : Segmentation fault".

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
2018-11-15 03:46:57 UTC
Permalink
Sorry, Frank without the sample data I can't give you a better answer.
Post by Franks
Hi Abhishek
Thank you for getting back to me. I do what you said. But I still get the
"SIGSEGV : Segmentation fault".
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
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
https://public.kitware.com/mailman/listinfo/vtkusers
--
Abhishek
http://zeroth.me
Franks
2018-11-15 04:18:51 UTC
Permalink
mummy.vtk <http://vtk.1045678.n5.nabble.com/file/t342588/mummy.vtk>
Sorry, I forget to upload the file. I used the VTK8.



--
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
2018-11-15 05:20:19 UTC
Permalink
Hi Frank,
I tried running the program with your data. I am getting runtime error.
Generic Warning: In
/home/cellphylab/Code/Projects/VTK-8.1.1/Rendering/Volume/vtkRayCastImageDisplayHelper.cxx,
line 20
Error: no override found for 'vtkRayCastImageDisplayHelper'.

Any idea?
Post by Franks
mummy.vtk <http://vtk.1045678.n5.nabble.com/file/t342588/mummy.vtk>
Sorry, I forget to upload the file. I used the VTK8.
--
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
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
https://public.kitware.com/mailman/listinfo/vtkusers
--
Abhishek
http://zeroth.me
Franks
2018-11-15 05:34:43 UTC
Permalink
I run the following program with my data and get no error. When I uncomment
out the code, I get the error as I said before.


#include <vtkStructuredPointsReader.h>
#include <vtkSmartVolumeMapper.h>
#include <vtkSmartPointer.h>
#include <vtkFloatArray.h>
#include <vtkStructuredPoints.h>
#include <vtkDataSet.h>
#include <vtkPointData.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkVolume.h>
#include <vtkVolumeProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>


int main(int argc, char **argv) {
auto reader = vtkSmartPointer<vtkStructuredPointsReader>::New();
reader->SetFileName("mummy.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->AddViewProp(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();

return 0;
}




--
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
2018-11-15 06:52:44 UTC
Permalink
I am still getting the same error message. can you tell me which version of
VTK are you using?
Post by Franks
I run the following program with my data and get no error. When I uncomment
out the code, I get the error as I said before.
#include <vtkStructuredPointsReader.h>
#include <vtkSmartVolumeMapper.h>
#include <vtkSmartPointer.h>
#include <vtkFloatArray.h>
#include <vtkStructuredPoints.h>
#include <vtkDataSet.h>
#include <vtkPointData.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkVolume.h>
#include <vtkVolumeProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
int main(int argc, char **argv) {
auto reader = vtkSmartPointer<vtkStructuredPointsReader>::New();
reader->SetFileName("mummy.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->AddViewProp(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();
return 0;
}
--
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
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
https://public.kitware.com/mailman/listinfo/vtkusers
--
Abhishek
http://zeroth.me
Franks
2018-11-15 07:32:33 UTC
Permalink
I am using VTK8.1.1 on arch linux. I don't know much about your problem since
I am the beginner of the VTK. I hope my following suggestion would be
beneficial for you.

1. Do you link all required libraries? "vtkSmartVolumeMapper" will call
"vtkOpenGLGPUVolumeRayCastMapper ". Here is my CmakeLists.txt

cmake_minimum_required(VERSION 3.12)
project(test)

set(CMAKE_CXX_STANDARD 11)

#vtk
# the root to find Config
set(VTK_ROOT /opt/VTK/DEBUG)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})

2. this link may help you.
http://vtk.1045678.n5.nabble.com/Error-no-override-found-for-vtkRayCastImageDisplayHelper-td5735445.html
<http://vtk.1045678.n5.nabble.com/Error-no-override-found-for-vtkRayCastImageDisplayHelper-td5735445.html>



--
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
Sankhesh Jhaveri
2018-11-15 21:19:23 UTC
Permalink
Hi Franks,

My guess is the issue lies in the RemoveArray(0) call.

Mind posting the backtrace?

Thanks,
Sankhesh
​
Post by Franks
I am using VTK8.1.1 on arch linux. I don't know much about your problem since
I am the beginner of the VTK. I hope my following suggestion would be
beneficial for you.
1. Do you link all required libraries? "vtkSmartVolumeMapper" will call
"vtkOpenGLGPUVolumeRayCastMapper ". Here is my CmakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(test)
set(CMAKE_CXX_STANDARD 11)
#vtk
# the root to find Config
set(VTK_ROOT /opt/VTK/DEBUG)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})
2. this link may help you.
http://vtk.1045678.n5.nabble.com/Error-no-override-found-for-vtkRayCastImageDisplayHelper-td5735445.html
<
http://vtk.1045678.n5.nabble.com/Error-no-override-found-for-vtkRayCastImageDisplayHelper-td5735445.html>
--
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
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
https://public.kitware.com/mailman/listinfo/vtkusers
--
Sankhesh Jhaveri *Sr. Research & Development Engineer* | Kitware
<http://www.kitware.com/> | (518) 881-4417
​
Franks
2018-11-16 01:18:23 UTC
Permalink
1. When I commet out the the line of 'RemoveArray(0)', I still get the
problem. When I change number of NumberOfComponents to 1, I get no error.
Why the mapper can not handle with the two-components data? The following
code can run with no error.

auto tuples = vtkSmartPointer<vtkFloatArray>::New();
tuples->DeepCopy(reader->GetOutput()->GetPointData()->GetScalars());
tuples->SetNumberOfComponents(1);
for (int i = 0; i < tuples->GetNumberOfTuples(); ++i) {
tuples->SetTuple1(i,80);
}

reader->GetOutput()->GetPointData()->RemoveArray(0);
reader->GetOutput()->GetPointData()->SetScalars(tuples);

2. I am the beginner. I can not understand the meaning of backtrace well.
The console only print "Signal: SIGSEGV (Segmentation fault)" and the clion
debugger display the following picture.
<Loading Image...>



--
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://pu

Continue reading on narkive:
Loading...