コード例 #1
0
ファイル: mitkFiberMapper3DTest.cpp プロジェクト: m4271n/MITK
 void setUp() override
 {
   fib = mitk::IOUtil::Load<mitk::FiberBundle>(GetTestDataFilePath("DiffusionImaging/Rendering/test_fibers.fib"));
   MITK_INFO << fib->GetNumFibers();
   node = mitk::DataNode::New();
   node->SetData(fib);
 }
コード例 #2
0
    void setUp()
    {
        //Create DataNode as a container for our PointSet to be tested
        m_TestPointSetNode = mitk::DataNode::New();

        // Create PointSetData Interactor
        m_DataInteractor = mitk::PointSetDataInteractor::New();
        // Load the according state machine for regular point set interaction
        m_DataInteractor->LoadStateMachine("PointSet.xml");
        // Set the configuration file that defines the triggers for the transitions
        m_DataInteractor->SetEventConfig("PointSetConfig.xml");
        // set the DataNode (which already is added to the DataStorage)
        m_DataInteractor->SetDataNode(m_TestPointSetNode);

        //Create new PointSet which will receive the interaction input
        m_TestPointSet = mitk::PointSet::New();
        m_TestPointSetNode->SetData(m_TestPointSet);
    }
コード例 #3
0
void mitk::USZonesInteractor::UpdateSurface(mitk::DataNode::Pointer dataNode)
{
  if (!dataNode->GetData())
  {
    MITK_WARN("USZonesInteractor")("DataInteractor")
      << "Cannot update surface for node as no data is set to the node.";
    return;
  }

  mitk::Point3D origin = dataNode->GetData()->GetGeometry()->GetOrigin();

  float radius;
  if (!dataNode->GetFloatProperty(DATANODE_PROPERTY_SIZE, radius))
  {
    MITK_WARN("USZonesInteractor")("DataInteractor")
      << "Cannut update surface for node as no radius is specified in the node properties.";
    return;
  }

  mitk::Surface::Pointer zone = mitk::Surface::New();

  // create a vtk sphere with given radius
  vtkSphereSource *vtkData = vtkSphereSource::New();
  vtkData->SetRadius(radius);
  vtkData->SetCenter(0, 0, 0);
  vtkData->SetPhiResolution(20);
  vtkData->SetThetaResolution(20);
  vtkData->Update();
  zone->SetVtkPolyData(vtkData->GetOutput());
  vtkData->Delete();

  // set vtk sphere and origin to data node (origin must be set
  // again, because of the new sphere set as data)
  dataNode->SetData(zone);
  dataNode->GetData()->GetGeometry()->SetOrigin(origin);

  // update the RenderWindow to show the changed surface
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
コード例 #4
0
ファイル: QmitkAutocropAction.cpp プロジェクト: Cdebus/MITK
  foreach ( mitk::DataNode::Pointer node, selectedNodes )
  {
    if (node)
    {
      mitk::Image::Pointer image = dynamic_cast<mitk::Image*>( node->GetData() );
      if (image.IsNull()) return;

      mitk::ProgressBar::GetInstance()->AddStepsToDo(10);
      mitk::ProgressBar::GetInstance()->Progress(2);

      qApp->processEvents();

      mitk::AutoCropImageFilter::Pointer cropFilter = mitk::AutoCropImageFilter::New();
      cropFilter->SetInput( image );
      cropFilter->SetBackgroundValue( 0 );
      cropFilter->SetMarginFactor(1.5);
      try
      {
        cropFilter->Update();

        image = cropFilter->GetOutput();

        if (image.IsNotNull())
        {

          if (image->GetDimension() == 4)
          {
            MITK_INFO << "4D AUTOCROP DOES NOT WORK AT THE MOMENT";
            throw "4D AUTOCROP DOES NOT WORK AT THE MOMENT";

            unsigned int timesteps = image->GetDimension(3);
            for (unsigned int i = 0; i < timesteps; i++)
            {
              mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New();
              imageTimeSelector->SetInput(image);
              imageTimeSelector->SetTimeNr(i);
              imageTimeSelector->UpdateLargestPossibleRegion();

              // We split a long nested code line into separate calls for debugging:
              mitk::ImageSource::OutputImageType *_3dSlice = imageTimeSelector->GetOutput();
              mitk::Image::Pointer _cropped3dSlice = this->IncreaseCroppedImageSize(_3dSlice);

              // +++ BUG +++ BUG +++ BUG +++ BUG +++ BUG +++ BUG +++ BUG +++
              {
                mitk::ImageWriteAccessor writeAccess(_cropped3dSlice);
                void *_data = writeAccess.GetData();

                // <ToBeRemoved>
                // We write some stripes into the image
                if ((i & 1) == 0)
                {
                  int depth = _cropped3dSlice->GetDimension(2);
                  int height = _cropped3dSlice->GetDimension(1);
                  int width = _cropped3dSlice->GetDimension(0);

                  for (int z = 0; z < depth; ++z)
                    for (int y = 0; y < height; ++y)
                      for (int x = 0; x < width; ++x)
                        reinterpret_cast<unsigned char *>(_data)[(width * height * z) + (width * y) + x] = x & 1;
                }
                // </ToBeRemoved>

                image->SetVolume(_data, i);
              }
            }
            node->SetData( image ); // bug fix 3145
          }
          else
          {
            node->SetData( this->IncreaseCroppedImageSize(image) ); // bug fix 3145
          }
          // Reinit node
          mitk::RenderingManager::GetInstance()->InitializeViews(
            node->GetData()->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true );
          mitk::RenderingManager::GetInstance()->RequestUpdateAll();

        }
      }
      catch(...)
      {
        MITK_ERROR << "Cropping image failed...";
      }
      mitk::ProgressBar::GetInstance()->Progress(8);
    }
    else
    {
      MITK_INFO << "   a nullptr node selected";
    }
  }