Esempio n. 1
0
void mitk::SurfaceGLMapper2D::SetDataNode( mitk::DataNode* node )
{
  Superclass::SetDataNode( node );

  bool useCellData;
  if (dynamic_cast<BoolProperty *>(node->GetProperty("deprecated useCellDataForColouring")) == NULL)
    useCellData = false;
  else
    useCellData = dynamic_cast<BoolProperty *>(node->GetProperty("deprecated useCellDataForColouring"))->GetValue();

  if (!useCellData)
  {
    // search min/max point scalars over all time steps
    double dataRange[2] = {0,0};
    double range[2];

    Surface::Pointer input  = const_cast< Surface* >(dynamic_cast<const Surface*>( this->GetDataNode()->GetData() ));
    if(input.IsNull()) return;
    const TimeGeometry::Pointer inputTimeGeometry = input->GetTimeGeometry();
    if(( inputTimeGeometry.IsNull() ) || ( inputTimeGeometry->CountTimeSteps() == 0 ) ) return;
    for (unsigned int timestep=0; timestep<inputTimeGeometry->CountTimeSteps(); timestep++)
    {
      vtkPolyData * vtkpolydata = input->GetVtkPolyData( timestep );
      if((vtkpolydata==NULL) || (vtkpolydata->GetNumberOfPoints() < 1 )) continue;
      vtkDataArray *vpointscalars = vtkpolydata->GetPointData()->GetScalars();
      if (vpointscalars) {
        vpointscalars->GetRange( range, 0 );
        if (dataRange[0]==0 && dataRange[1]==0) {
          dataRange[0] = range[0];
          dataRange[1] = range[1];
        }
        else {
          if (range[0] < dataRange[0]) dataRange[0] = range[0];
          if (range[1] > dataRange[1]) dataRange[1] = range[1];
        }
      }
    }
    if (dataRange[1] - dataRange[0] > 0) {
      m_LUT->SetTableRange( dataRange );
      m_LUT->Build();
    }
  }
}
Esempio n. 2
0
void mitk::Image::Initialize(const mitk::PixelType& type, const mitk::TimeGeometry& geometry, unsigned int channels, int tDim )
{
  unsigned int dimensions[5];
  dimensions[0] = (unsigned int)(geometry.GetGeometryForTimeStep(0)->GetExtent(0)+0.5);
  dimensions[1] = (unsigned int)(geometry.GetGeometryForTimeStep(0)->GetExtent(1)+0.5);
  dimensions[2] = (unsigned int)(geometry.GetGeometryForTimeStep(0)->GetExtent(2)+0.5);
  dimensions[3] = (tDim > 0) ? tDim : geometry.CountTimeSteps();
  dimensions[4] = 0;

  unsigned int dimension = 2;
  if ( dimensions[2] > 1 )
    dimension = 3;
  if ( dimensions[3] > 1 )
    dimension = 4;

  Initialize( type, dimension, dimensions, channels );
  if (geometry.CountTimeSteps() > 1)
  {
    TimeGeometry::Pointer cloned = geometry.Clone();
    SetTimeGeometry(cloned.GetPointer());

    // make sure the image geometry flag is properly set for all time steps
    for (TimeStepType step = 0; step < cloned->CountTimeSteps(); ++step)
    {

      if( ! cloned->GetGeometryCloneForTimeStep(step)->GetImageGeometry() )
      {
        MITK_WARN("Image.3DnT.Initialize") << " Attempt to initialize an image with a non-image geometry. Re-interpretting the initialization geometry for timestep " << step
                                           << " as image geometry, the original geometry remains unchanged.";
        cloned->GetGeometryForTimeStep(step)->ImageGeometryOn();
      }
    }
  }
  else
  {
    // make sure the image geometry coming from outside has proper value of the image geometry flag
    BaseGeometry::Pointer cloned = geometry.GetGeometryCloneForTimeStep(0)->Clone();
    if( ! cloned->GetImageGeometry() )
    {
      MITK_WARN("Image.Initialize") << " Attempt to initialize an image with a non-image geometry. Re-interpretting the initialization geometry as image geometry, the original geometry remains unchanged.";
      cloned->ImageGeometryOn();

    }

    Superclass::SetGeometry( cloned );
  }
/* //Old //TODO_GOETZ Really necessary?
  mitk::BoundingBox::BoundsArrayType bounds = geometry.GetBoundingBoxInWorld()->GetBounds();
  if( (bounds[0] != 0.0) || (bounds[2] != 0.0) || (bounds[4] != 0.0) )
  {
    SlicedGeometry3D* slicedGeometry = GetSlicedGeometry(0);

    mitk::Point3D origin; origin.Fill(0.0);
    slicedGeometry->IndexToWorld(origin, origin);

    bounds[1]-=bounds[0]; bounds[3]-=bounds[2]; bounds[5]-=bounds[4];
    bounds[0] = 0.0;      bounds[2] = 0.0;      bounds[4] = 0.0;
    this->m_ImageDescriptor->Initialize( this->m_Dimensions, this->m_Dimension );
    slicedGeometry->SetBounds(bounds);
    slicedGeometry->GetIndexToWorldTransform()->SetOffset(origin.GetVnlVector().data_block());

    ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
    timeGeometry->Initialize(slicedGeometry, m_Dimensions[3]);
    SetTimeGeometry(timeGeometry);
  }*/
}
Esempio n. 3
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;
  }