Esempio n. 1
0
  bool
    RenderingManager
    ::InitializeViews(const TimeGeometry * dataGeometry, RequestType type, bool /*preserveRoughOrientationInWorldSpace*/)
  {
    MITK_DEBUG << "initializing views";

    bool boundingBoxInitialized = false;

    TimeGeometry::ConstPointer timeGeometry = dataGeometry;
    TimeGeometry::Pointer modifiedGeometry = NULL;
    if (dataGeometry != NULL)
    {
      modifiedGeometry = dataGeometry->Clone();
    }

    int warningLevel = vtkObject::GetGlobalWarningDisplay();
    vtkObject::GlobalWarningDisplayOff();

    if ((timeGeometry.IsNotNull()) && (const_cast<mitk::BoundingBox *>(
      timeGeometry->GetBoundingBoxInWorld())->GetDiagonalLength2() > mitk::eps))
    {
      boundingBoxInitialized = true;
    }

    if (timeGeometry.IsNotNull())
    {// make sure bounding box has an extent bigger than zero in any direction
      // clone the input geometry
      //Old Geometry3D::Pointer modifiedGeometry = dynamic_cast<Geometry3D*>( dataGeometry->Clone().GetPointer() );
      assert(modifiedGeometry.IsNotNull());
      for (TimeStepType step = 0; step < modifiedGeometry->CountTimeSteps(); ++step)
      {
        BaseGeometry::BoundsArrayType newBounds = modifiedGeometry->GetGeometryForTimeStep(step)->GetBounds();
        for (unsigned int dimension = 0; (2 * dimension) < newBounds.Size(); dimension++)
        {
          //check for equality but for an epsilon
          if (Equal(newBounds[2 * dimension], newBounds[2 * dimension + 1]))
          {
            newBounds[2 * dimension + 1] += 1;
            if( Equal( newBounds[ 2 * dimension ], newBounds[ 2 * dimension + 1 ] ) ) // newBounds will still be equal if values are beyond double precision
            {
              mitkThrow()<< "One dimension of object data has zero length, please make sure you're not using numbers beyond double precision as coordinates.";
            }
          }
        }
        modifiedGeometry->GetGeometryForTimeStep(step)->SetBounds(newBounds);
      }
    }

    timeGeometry = modifiedGeometry;
    RenderWindowList::const_iterator it;
    for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
    {
      mitk::BaseRenderer *baseRenderer =
        mitk::BaseRenderer::GetInstance(it->first);

      baseRenderer->SetConstrainZoomingAndPanning(m_ConstrainedPanningZooming);

      int id = baseRenderer->GetMapperID();
      if (((type == REQUEST_UPDATE_ALL)
        || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1))
        || ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2)))
        )
      {
        this->InternalViewInitialization(baseRenderer, timeGeometry,
          boundingBoxInitialized, id);
      }
    }

    if (boundingBoxInitialized)
    {
      m_TimeNavigationController->SetInputWorldTimeGeometry(timeGeometry);
    }
    m_TimeNavigationController->Update();

    this->RequestUpdateAll(type);

    vtkObject::SetGlobalWarningDisplay(warningLevel);

    // Inform listeners that views have been initialized
    this->InvokeEvent(mitk::RenderingManagerViewsInitializedEvent());

    return boundingBoxInitialized;
  }