| 185 | } |
| 186 | |
| 187 | void mitk::LabelSetImageVtkMapper2D::GenerateDataForRenderer(mitk::BaseRenderer *renderer) |
| 188 | { |
| 189 | LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); |
| 190 | mitk::DataNode *node = this->GetDataNode(); |
| 191 | auto *segmentation = dynamic_cast<mitk::MultiLabelSegmentation *>(node->GetData()); |
| 192 | assert(segmentation && segmentation->IsInitialized()); |
| 193 | |
| 194 | bool isLookupModified = localStorage->m_LabelLookupTable.IsNull() || |
| 195 | (localStorage->m_LabelLookupTable->GetMTime() < segmentation->GetLookupTable()->GetMTime()) || |
| 196 | PropertyTimeStampIsNewer(node, renderer, "org.mitk.multilabel.labels.highlighted", localStorage->m_LabelLookupTable->GetMTime()) || |
| 197 | PropertyTimeStampIsNewer(node, renderer, "org.mitk.multilabel.highlight_invisible", localStorage->m_LabelLookupTable->GetMTime()) || |
| 198 | PropertyTimeStampIsNewer(node, renderer, "opacity", localStorage->m_LabelLookupTable->GetMTime()) || |
| 199 | this->GetOpacityFactor() != localStorage->m_LastOpacityFactor; |
| 200 | |
| 201 | if (isLookupModified) |
| 202 | { |
| 203 | this->GenerateLookupTable(renderer); |
| 204 | } |
| 205 | |
| 206 | bool isGeometryModified = (localStorage->m_LastDataUpdateTime < renderer->GetCurrentWorldPlaneGeometryUpdateTime()) || |
| 207 | (localStorage->m_LastDataUpdateTime < renderer->GetCurrentWorldPlaneGeometry()->GetMTime()); |
| 208 | |
| 209 | bool rendererGeometryIsValid = true; |
| 210 | |
| 211 | // check if there is a valid worldGeometry |
| 212 | if (isGeometryModified) |
| 213 | { |
| 214 | const PlaneGeometry* worldGeometry = renderer->GetCurrentWorldPlaneGeometry(); |
| 215 | rendererGeometryIsValid = worldGeometry != nullptr |
| 216 | && worldGeometry->IsValid() |
| 217 | && worldGeometry->HasReferenceGeometry(); |
| 218 | |
| 219 | isGeometryModified = rendererGeometryIsValid |
| 220 | && localStorage->m_WorldPlane.IsNotNull() && !Equal(*worldGeometry, *(localStorage->m_WorldPlane.GetPointer())); |
| 221 | |
| 222 | localStorage->m_WorldPlane = rendererGeometryIsValid ? worldGeometry->Clone() : nullptr; |
| 223 | } |
| 224 | |
| 225 | const bool hasValidContent = rendererGeometryIsValid && RenderingGeometryIntersectsImage(localStorage->m_WorldPlane, segmentation->GetSlicedGeometry()); |
| 226 | const bool contentBecameValid = hasValidContent && !localStorage->m_HasValidContent; |
| 227 | const bool contentBecameInvalid = !hasValidContent && localStorage->m_HasValidContent; |
| 228 | |
| 229 | if (contentBecameInvalid) |
| 230 | { |
| 231 | // set image to nullptr, to clear the texture in 3D, because |
| 232 | // the latest image is used there if the plane is out of the geometry |
| 233 | // see bug-13275 |
| 234 | for (unsigned int lidx = 0; lidx < localStorage->m_NumberOfLayers; ++lidx) |
| 235 | { |
| 236 | localStorage->m_ReslicedImageVector[lidx] = nullptr; |
| 237 | localStorage->m_LayerMapperVector[lidx]->SetInputData(localStorage->m_EmptyPolyData); |
| 238 | localStorage->m_OutlineActor->SetVisibility(false); |
| 239 | localStorage->m_OutlineShadowActor->SetVisibility(false); |
| 240 | } |
| 241 | localStorage->m_LastDataUpdateTime.Modified(); |
| 242 | } |
| 243 | |
| 244 | localStorage->m_HasValidContent = hasValidContent; |
no test coverage detected