| 477 | } |
| 478 | |
| 479 | void mitk::SlicedGeometry3D::PreSetSpacing(const mitk::Vector3D &aSpacing) |
| 480 | { |
| 481 | bool hasEvenlySpacedPlaneGeometry = false; |
| 482 | mitk::Point3D origin; |
| 483 | mitk::Vector3D rightDV, bottomDV; |
| 484 | BoundingBox::BoundsArrayType bounds; |
| 485 | |
| 486 | // Check for valid spacing |
| 487 | if (!(aSpacing[0] > 0 && aSpacing[1] > 0 && aSpacing[2] > 0)) |
| 488 | { |
| 489 | mitkThrow() << "You try to set a spacing with at least one element equal or " |
| 490 | "smaller to \"0\". This might lead to a crash during rendering. Please double" |
| 491 | " check your data!"; |
| 492 | } |
| 493 | |
| 494 | // In case of evenly-spaced data: re-initialize instances of PlaneGeometry, |
| 495 | // since the spacing influences them |
| 496 | if ((m_EvenlySpaced) && (m_PlaneGeometries.size() > 0)) |
| 497 | { |
| 498 | const PlaneGeometry *planeGeometry = m_PlaneGeometries[0]; |
| 499 | |
| 500 | if (planeGeometry && !dynamic_cast<const AbstractTransformGeometry *>(planeGeometry)) |
| 501 | { |
| 502 | this->WorldToIndex(planeGeometry->GetOrigin(), origin); |
| 503 | this->WorldToIndex(planeGeometry->GetAxisVector(0), rightDV); |
| 504 | this->WorldToIndex(planeGeometry->GetAxisVector(1), bottomDV); |
| 505 | |
| 506 | bounds = planeGeometry->GetBounds(); |
| 507 | hasEvenlySpacedPlaneGeometry = true; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | BaseGeometry::_SetSpacing(aSpacing); |
| 512 | |
| 513 | mitk::PlaneGeometry::Pointer firstGeometry; |
| 514 | |
| 515 | // In case of evenly-spaced data: re-initialize instances of PlaneGeometry, |
| 516 | // since the spacing influences them |
| 517 | if (hasEvenlySpacedPlaneGeometry) |
| 518 | { |
| 519 | // create planeGeometry according to new spacing |
| 520 | this->IndexToWorld(origin, origin); |
| 521 | this->IndexToWorld(rightDV, rightDV); |
| 522 | this->IndexToWorld(bottomDV, bottomDV); |
| 523 | |
| 524 | mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); |
| 525 | planeGeometry->SetImageGeometry(this->GetImageGeometry()); |
| 526 | |
| 527 | planeGeometry->SetReferenceGeometry(m_ReferenceGeometry); |
| 528 | |
| 529 | // Store spacing, as Initialize... needs a pointer |
| 530 | mitk::Vector3D lokalSpacing = this->GetSpacing(); |
| 531 | planeGeometry->InitializeStandardPlane(rightDV.GetVnlVector(), bottomDV.GetVnlVector(), &lokalSpacing); |
| 532 | planeGeometry->SetOrigin(origin); |
| 533 | planeGeometry->SetBounds(bounds); |
| 534 | |
| 535 | firstGeometry = planeGeometry; |
| 536 | } |
nothing calls this directly
no test coverage detected