Skip to content

Commit 9b729e6

Browse files
committed
Adding the image and reformatting
1 parent ab98992 commit 9b729e6

File tree

2 files changed

+55
-52
lines changed

2 files changed

+55
-52
lines changed

src/Cxx/VolumeRendering/OpenVRVolume.cxx

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,61 @@
1111
#include <vtkSmartVolumeMapper.h>
1212
#include <vtkVolumeProperty.h>
1313

14-
int main(int, char* [])
14+
int main(int argc, char* argv[])
1515
{
16-
int dim[3] = { 10, 10, 10 };
17-
double spc[3] = { 0.05, 0.05, 0.05 };
18-
vtkNew<vtkImageData> img;
19-
img->SetDimensions(dim);
20-
img->AllocateScalars(VTK_INT, 1);
21-
img->SetSpacing(spc);
22-
for (int x=0; x<dim[0]; ++x)
23-
for (int y=0; y<dim[1]; ++y)
24-
for (int z=0; z<dim[2]; ++z)
25-
{
26-
img->SetScalarComponentFromDouble(x, y, z, 0, x);
27-
}
28-
vtkNew<vtkColorSeries> colors;
29-
colors->SetColorScheme(vtkColorSeries::BREWER_QUALITATIVE_SET3);
30-
vtkNew<vtkColorTransferFunction> ctf;
31-
for (int x = 0; x < dim[0]; ++x)
32-
{
33-
auto c = colors->GetColor(x);
34-
ctf->AddRGBPoint(x, c.GetRed() / 255.0, c.GetGreen() / 255.0, c.GetBlue() / 255.0);
35-
}
36-
ctf->AddRGBPoint(dim[0], 1.0, 1.0, 1.0);
37-
ctf->Build();
38-
vtkNew<vtkSmartVolumeMapper> volMapper;
39-
vtkNew<vtkVolume> volume;
40-
vtkNew<vtkVolumeProperty> volProp;
41-
volMapper->SetBlendModeToComposite();
42-
volume->SetMapper(volMapper);
43-
volume->SetProperty(volProp);
44-
volume->SetVisibility(true);
45-
volMapper->SetInputData(img);
46-
volProp->SetColor(0, ctf);
47-
vtkNew<vtkPiecewiseFunction> otf;
48-
otf->AddPoint(0.0, 1.0);
49-
otf->AddPoint(dim[0], 1.0);
50-
volProp->SetScalarOpacity(0, otf);
51-
volProp->Modified();
52-
volProp->SetScalarOpacityUnitDistance(1);
16+
int dim[3] = {10, 10, 10};
17+
double spc[3] = {0.05, 0.05, 0.05};
18+
vtkNew<vtkImageData> img;
19+
img->SetDimensions(dim);
20+
img->AllocateScalars(VTK_INT, 1);
21+
img->SetSpacing(spc);
22+
for (int x = 0; x < dim[0]; ++x)
23+
for (int y = 0; y < dim[1]; ++y)
24+
for (int z = 0; z < dim[2]; ++z)
25+
{
26+
img->SetScalarComponentFromDouble(x, y, z, 0, x);
27+
}
28+
vtkNew<vtkColorSeries> colors;
29+
colors->SetColorScheme(vtkColorSeries::BREWER_QUALITATIVE_SET3);
30+
vtkNew<vtkColorTransferFunction> ctf;
31+
for (int x = 0; x < dim[0]; ++x)
32+
{
33+
auto c = colors->GetColor(x);
34+
ctf->AddRGBPoint(x, c.GetRed() / 255.0, c.GetGreen() / 255.0,
35+
c.GetBlue() / 255.0);
36+
}
37+
ctf->AddRGBPoint(dim[0], 1.0, 1.0, 1.0);
38+
ctf->Build();
39+
vtkNew<vtkSmartVolumeMapper> volMapper;
40+
vtkNew<vtkVolume> volume;
41+
vtkNew<vtkVolumeProperty> volProp;
42+
volMapper->SetBlendModeToComposite();
43+
volume->SetMapper(volMapper);
44+
volume->SetProperty(volProp);
45+
volume->SetVisibility(true);
46+
volMapper->SetInputData(img);
47+
volProp->SetColor(0, ctf);
48+
vtkNew<vtkPiecewiseFunction> otf;
49+
otf->AddPoint(0.0, 1.0);
50+
otf->AddPoint(dim[0], 1.0);
51+
volProp->SetScalarOpacity(0, otf);
52+
volProp->Modified();
53+
volProp->SetScalarOpacityUnitDistance(1);
5354

54-
vtkNew<vtkOpenVRRenderWindow> renderWindow;
55-
renderWindow->Initialize();
56-
vtkNew<vtkOpenVRRenderWindowInteractor> renderWindowInteractor;
57-
renderWindowInteractor->SetRenderWindow(renderWindow);
55+
vtkNew<vtkOpenVRRenderWindow> renderWindow;
56+
renderWindow->Initialize();
57+
vtkNew<vtkOpenVRRenderWindowInteractor> renderWindowInteractor;
58+
renderWindowInteractor->SetRenderWindow(renderWindow);
5859

59-
vtkNew<vtkOpenVRRenderer> renderer;
60-
renderWindow->AddRenderer(renderer);
61-
vtkNew<vtkNamedColors> namedColors;
62-
renderer->SetBackground(namedColors->GetColor3d("ForestGreen").GetData());
63-
renderer->AddVolume(volume);
64-
volume->SetPosition(0, 0.5, 0);
60+
vtkNew<vtkOpenVRRenderer> renderer;
61+
renderWindow->AddRenderer(renderer);
62+
vtkNew<vtkNamedColors> namedColors;
63+
renderer->SetBackground(namedColors->GetColor3d("ForestGreen").GetData());
64+
renderer->AddVolume(volume);
65+
volume->SetPosition(0, 0.5, 0);
6566

67+
renderWindow->Render();
68+
renderWindowInteractor->Start();
6669

67-
renderWindow->Render();
68-
renderWindowInteractor->Start();
69-
70-
return EXIT_SUCCESS;
70+
return EXIT_SUCCESS;
7171
}
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)