45 vtkSmartPointer<vtkAppendPolyData> appendData =
46 vtkSmartPointer<vtkAppendPolyData>::New();
48 for (
int i = 0; i < 5; i++)
50 vtkSmartPointer<vtkSphereSource> sphereSource =
51 vtkSmartPointer<vtkSphereSource>::New();
52 sphereSource->SetThetaResolution(theta);
53 sphereSource->SetPhiResolution(phi);
54 sphereSource->SetRadius(0.5);
59 sphereSource->SetRadius(1);
60 sphereSource->SetCenter(0, 0, 0);
break;
62 sphereSource->SetCenter(1, 0, 0);
break;
64 sphereSource->SetCenter(-1, 0, 0);
break;
66 sphereSource->SetCenter(0, 1, 0);
break;
68 sphereSource->SetCenter(0, -1, 0);
break;
70 sphereSource->Update();
71 appendData->AddInputConnection(sphereSource->GetOutputPort());
89 vtkSmartPointer<vtkRenderWindow> renderWindow,
90 vtkSmartPointer<vtkRenderer> renderer,
int maxNoOfPeels,
91 double occlusionRatio)
93 if (!renderWindow || !renderer)
100 renderWindow->SetAlphaBitPlanes(
true);
104 renderWindow->SetMultiSamples(0);
107 renderer->SetUseDepthPeeling(
true);
111 renderer->SetMaximumNumberOfPeels(maxNoOfPeels);
113 renderer->SetOcclusionRatio(occlusionRatio);
116 renderWindow->Render();
118 bool success = renderer->GetLastRenderingUsedDepthPeeling();
124 vtkSmartPointer<vtkRenderWindow> renderWindow,
125 vtkSmartPointer<vtkRenderer> renderer)
127 if (!renderWindow || !renderer)
135 renderWindow->SetAlphaBitPlanes(
false);
136 renderWindow->SetMultiSamples(8);
137 renderer->SetUseDepthPeeling(
false);
138 renderer->SetMaximumNumberOfPeels(4);
139 renderer->SetOcclusionRatio(0.0);
156 vtkSmartPointer<vtkRenderer> renderer,
bool doItOffScreen)
158 if (!renderWindow || !renderer)
167 bool origOffScreenRendering = renderWindow->GetOffScreenRendering() == 1;
168 bool origAlphaBitPlanes = renderWindow->GetAlphaBitPlanes() == 1;
169 int origMultiSamples = renderWindow->GetMultiSamples();
170 bool origUseDepthPeeling = renderer->GetUseDepthPeeling() == 1;
171 int origMaxPeels = renderer->GetMaximumNumberOfPeels();
172 double origOcclusionRatio = renderer->GetOcclusionRatio();
175 renderWindow->SetOffScreenRendering(doItOffScreen);
182 renderWindow->Render();
185 success = success && renderer->GetLastRenderingUsedDepthPeeling();
188 renderWindow->SetOffScreenRendering(origOffScreenRendering);
189 renderWindow->SetAlphaBitPlanes(origAlphaBitPlanes);
190 renderWindow->SetMultiSamples(origMultiSamples);
191 renderer->SetUseDepthPeeling(origUseDepthPeeling);
192 renderer->SetMaximumNumberOfPeels(origMaxPeels);
193 renderer->SetOcclusionRatio(origOcclusionRatio);
bool IsDepthPeelingSupported(vtkSmartPointer< vtkRenderWindow > renderWindow, vtkSmartPointer< vtkRenderer > renderer, bool doItOffScreen)
vtkSmartPointer< vtkAppendPolyData > GenerateOverlappingBunchOfSpheres(int theta, int phi)
void reportWarning(QString msg)
bool TurnOffDepthPeeling(vtkSmartPointer< vtkRenderWindow > renderWindow, vtkSmartPointer< vtkRenderer > renderer)
Turn off depth peeling.
bool SetupEnvironmentForDepthPeeling(vtkSmartPointer< vtkRenderWindow > renderWindow, vtkSmartPointer< vtkRenderer > renderer, int maxNoOfPeels, double occlusionRatio)