# VTK

**URL:** https://discourse.vtk.org/t/vtk/4276
**Category:** Support
**Created:** [September 22, 2020, 1:42pm UTC](https://discourse.vtk.org/t/vtk/4276 "2020-09-22T13:42:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cyAAA111](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@cyAAA111](https://discourse.vtk.org/u/cyAAA111)
#### Post date: [September 22, 2020, 1:42pm UTC](https://discourse.vtk.org/t/vtk/4276/1 "2020-09-22T13:42:14Z")

</div>

Excuse me, how to use volume data to achieve 10000X10000X1000 resolution drawing, thank you very much.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [September 22, 2020, 3:49pm UTC](https://discourse.vtk.org/t/vtk/4276/2 "2020-09-22T15:49:04Z")

</div>

What are you trying to achieve? What is the problem you are experiencing?

---

<div class="post-metadata">

### Author: ![cyAAA111](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@cyAAA111](https://discourse.vtk.org/u/cyAAA111)
#### Post date: [September 23, 2020, 2:04pm UTC](https://discourse.vtk.org/t/vtk/4276/3 "2020-09-23T14:04:21Z")

</div>

I use VTK to produce a 3-D model with volum data(1024_1024_1024), but I found I cannot deal with volum data(10000_10000_1000). So I want to know how to deal with these big volum data(10000_10000_1000) with VTK. My code are as follows:

#include “vtkSmartPointer.h”  
#include “vtkOpenGLGPUVolumeRayCastMapper.h”

#include “vtkPiecewiseFunction.h”  
#include “vtkColorTransferFunction.h”  
#include “vtkContourValues.h”

#include “vtkInteractorStyleTrackballCamera.h”  
#include “vtkMetaImageReader.h”  
#include “vtkRenderWindow.h”  
#include “vtkRenderWindowInteractor.h”  
#include “vtkRenderer.h”  
#include “vtkCamera.h”  
#include “vtkVolume.h”  
#include “vtkVolumeProperty.h”  
#include “vtkNamedColors.h”

int main(int argc, char\* argv[])  
{  
vtkSmartPointer reader =  
vtkSmartPointer::New();  
reader-\>SetFileName(“FullHead.mhd”); //reader-\>SetFileName(argv[1]);

```
auto colorTransferFunction =
    vtkSmartPointer<vtkColorTransferFunction>::New();
colorTransferFunction->RemoveAllPoints();
colorTransferFunction->AddRGBPoint(2, 1, 0, 0);
colorTransferFunction->AddRGBPoint(1, 0, 1, 0); 
colorTransferFunction->AddRGBPoint(0, 0, 0, 1); 

auto scalarOpacity =
    vtkSmartPointer<vtkPiecewiseFunction>::New();

scalarOpacity->AddPoint(2, 0);
scalarOpacity->AddPoint(1, 0.5); 
scalarOpacity->AddPoint(0, 1); 

auto volumeProperty =
    vtkSmartPointer<vtkVolumeProperty>::New();
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationType(2);

```

volumeProperty-\>SetColor(colorTransferFunction);  
volumeProperty-\>SetScalarOpacity(scalarOpacity);

```
auto mapper =
    vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
mapper->AutoAdjustSampleDistancesOff();
mapper->SetSampleDistance(0.5);
//mapper->SetBlendModeToIsoSurface();

//volumeProperty->GetIsoSurfaceValues()->SetValue(0, 128);
//volumeProperty->GetIsoSurfaceValues()->SetValue(1, 255);

auto volume =
    vtkSmartPointer<vtkVolume>::New();
volume->SetMapper(mapper);
volume->SetProperty(volumeProperty);

auto colors =
    vtkSmartPointer<vtkNamedColors>::New();

auto renderer =
    vtkSmartPointer<vtkRenderer>::New();
renderer->AddVolume(volume);
renderer->SetBackground(colors->GetColor3d("white").GetData());
renderer->ResetCamera();

auto renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(800, 800);
renderWindow->AddRenderer(renderer);

auto style =
    vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();

auto interactor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
interactor->SetInteractorStyle(style);

// Generate a good view
vtkSmartPointer<vtkCamera> aCamera =
    vtkSmartPointer<vtkCamera>::New();
aCamera->SetViewUp(0, 0, -1);
aCamera->SetPosition(0, -1, 0);
aCamera->SetFocalPoint(0, 0, 0);

renderer->SetActiveCamera(aCamera);
renderer->ResetCamera();

aCamera->Azimuth(30.0);
aCamera->Elevation(30.0);
aCamera->Dolly(1.5);
renderer->ResetCameraClippingRange();

renderWindow->Render();

interactor->Start();

return EXIT_SUCCESS;

```

}

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [September 23, 2020, 3:57pm UTC](https://discourse.vtk.org/t/vtk/4276/4 "2020-09-23T15:57:44Z")

</div>

This is a rather large volume for volume rendering. If you find that your graphics card cannot deal with it then you can upgrade your hardware or resample and/or crop the image. If your GPU memory size is big enough and you just exceed the maximum texture size then you can try to adjust partitions size - see this topic: [Volume rendering invalid texture dimensions](https://discourse.vtk.org/t/volume-rendering-invalid-texture-dimensions/3917/8).

---

<div class="post-metadata">

### Author: ![cyAAA111](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@cyAAA111](https://discourse.vtk.org/u/cyAAA111)
#### Post date: [September 24, 2020, 6:30am UTC](https://discourse.vtk.org/t/vtk/4276/5 "2020-09-24T06:30:57Z")

</div>

Thank you very much.
