------------------------------------------------------------------------------ This method us used by the render method to validate everything before attempting to render. This method returns 0 if something is not right - such as missing input, a null renderer or a null volume, no scalars, etc. In some cases it will produce a vtkErrorMacro message, and in others (for example, in the case of croppi
| 205 | // return with a value of 1. |
| 206 | //------------------------------------------------------------------------------ |
| 207 | int vtkGPUVolumeRayCastMapper::ValidateRender(vtkRenderer* ren, vtkVolume* vol) |
| 208 | { |
| 209 | // Check that we have everything we need to render. |
| 210 | int goodSoFar = 1; |
| 211 | |
| 212 | // Check for a renderer - we MUST have one |
| 213 | if (!ren) |
| 214 | { |
| 215 | goodSoFar = 0; |
| 216 | vtkErrorMacro("Renderer cannot be null."); |
| 217 | } |
| 218 | |
| 219 | // Check for the volume - we MUST have one |
| 220 | if (goodSoFar && !vol) |
| 221 | { |
| 222 | goodSoFar = 0; |
| 223 | vtkErrorMacro("Volume cannot be null."); |
| 224 | } |
| 225 | |
| 226 | // Check the cropping planes. If they are invalid, just silently |
| 227 | // fail. This will happen when an interactive widget is dragged |
| 228 | // such that it defines 0 or negative volume - this can happen |
| 229 | // and should just not render the volume. |
| 230 | // Check the cropping planes |
| 231 | if (goodSoFar && this->Cropping && |
| 232 | (this->CroppingRegionPlanes[0] >= this->CroppingRegionPlanes[1] || |
| 233 | this->CroppingRegionPlanes[2] >= this->CroppingRegionPlanes[3] || |
| 234 | this->CroppingRegionPlanes[4] >= this->CroppingRegionPlanes[5])) |
| 235 | { |
| 236 | // No error message here - we want to be silent |
| 237 | goodSoFar = 0; |
| 238 | } |
| 239 | |
| 240 | if (!goodSoFar) |
| 241 | { |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | auto multiVol = vtkMultiVolume::SafeDownCast(vol); |
| 246 | bool success = true; |
| 247 | for (const auto& port : this->Ports) |
| 248 | { |
| 249 | auto currentVol = multiVol ? multiVol->GetVolume(port) : vol; |
| 250 | success &= this->ValidateInput(currentVol->GetProperty(), port) == 1; |
| 251 | } |
| 252 | return (success ? 1 : 0); |
| 253 | } |
| 254 | |
| 255 | vtkDataSet* vtkGPUVolumeRayCastMapper::FindData(int port, DataMap& container) |
| 256 | { |
no test coverage detected