コード例 #1
0
void QmitkIGTTrackingLabView::DestroyInstrumentVisualization(mitk::DataStorage* ds, mitk::TrackingDevice::Pointer tracker)
{
  if(ds == NULL || tracker.IsNull())
    return;

  for(int i=0; i < tracker->GetToolCount(); ++i)
  {
    mitk::DataNode::Pointer dn = ds->GetNamedNode(tracker->GetTool(i)->GetToolName());

    if(dn.IsNotNull())
      ds->Remove(dn);
  }
}
コード例 #2
0
mitk::TrackingDeviceSource::Pointer mitk::TrackingDeviceSourceConfigurator::CreateMicronTrackerTrackingDeviceSource(mitk::TrackingDevice::Pointer trackingDevice, mitk::NavigationToolStorage::Pointer navigationTools)
  {
  mitk::TrackingDeviceSource::Pointer returnValue = mitk::TrackingDeviceSource::New();
  mitk::ClaronTrackingDevice::Pointer thisDevice = dynamic_cast<mitk::ClaronTrackingDevice*>(trackingDevice.GetPointer());
  m_ToolCorrespondencesInToolStorage = std::vector<int>();
  //add the tools to the tracking device
  for (int i=0; i<navigationTools->GetToolCount(); i++)
      {
        mitk::NavigationTool::Pointer thisNavigationTool = m_NavigationTools->GetTool(i);
        m_ToolCorrespondencesInToolStorage.push_back(i);
        bool toolAddSuccess = thisDevice->AddTool(thisNavigationTool->GetToolName().c_str(),thisNavigationTool->GetCalibrationFile().c_str());
        if (!toolAddSuccess)
          {
          //todo error handling
          this->m_ErrorMessage = "Can't add tool, is the toolfile valid?";
          return NULL;
          }
        thisDevice->GetTool(i)->SetToolTip(thisNavigationTool->GetToolTipPosition(),thisNavigationTool->GetToolTipOrientation());
      }
  returnValue->SetTrackingDevice(thisDevice);
  return returnValue;
  }
コード例 #3
0
mitk::TrackingDeviceSource::Pointer mitk::TrackingDeviceSourceConfigurator::CreateNDIAuroraTrackingDeviceSource(mitk::TrackingDevice::Pointer trackingDevice, mitk::NavigationToolStorage::Pointer navigationTools)
  {
  mitk::TrackingDeviceSource::Pointer returnValue = mitk::TrackingDeviceSource::New();
  mitk::NDITrackingDevice::Pointer thisDevice = dynamic_cast<mitk::NDITrackingDevice*>(trackingDevice.GetPointer());

  //connect to aurora to dectect tools automatically
  thisDevice->OpenConnection();

  //now search for automatically detected tools in the tool storage and save them
  mitk::NavigationToolStorage::Pointer newToolStorageInRightOrder = mitk::NavigationToolStorage::New();
  std::vector<int> alreadyFoundTools = std::vector<int>();
  m_ToolCorrespondencesInToolStorage = std::vector<int>();
  for (int i=0; i<thisDevice->GetToolCount(); i++)
      {
      bool toolFound = false;
      for (int j=0; j<navigationTools->GetToolCount(); j++)
        {
          //check if the serial number is the same to identify the tool
          if ((dynamic_cast<mitk::NDIPassiveTool*>(thisDevice->GetTool(i)))->GetSerialNumber() == navigationTools->GetTool(j)->GetSerialNumber())
            {
            //check if this tool was already added to make sure that every tool is only added once (in case of same serial numbers)
            bool toolAlreadyAdded = false;
            for(int k=0; k<alreadyFoundTools.size(); k++) if (alreadyFoundTools.at(k) == j) toolAlreadyAdded = true;

            if(!toolAlreadyAdded)
              {
              //add tool in right order
              newToolStorageInRightOrder->AddTool(navigationTools->GetTool(j));
              m_ToolCorrespondencesInToolStorage.push_back(j);
              //adapt name of tool
              dynamic_cast<mitk::NDIPassiveTool*>(thisDevice->GetTool(i))->SetToolName(navigationTools->GetTool(j)->GetToolName());
              //set tip of tool
              dynamic_cast<mitk::NDIPassiveTool*>(thisDevice->GetTool(i))->SetToolTip(navigationTools->GetTool(j)->GetToolTipPosition(),navigationTools->GetTool(j)->GetToolTipOrientation());
              //rember that this tool was already found
              alreadyFoundTools.push_back(j);

              toolFound = true;
              break;
              }
            }
        }
      if (!toolFound)
        {
        this->m_ErrorMessage = "Error: did not find every automatically detected tool in the loaded tool storage: aborting initialization.";
        return NULL;
        }
      }

  //delete all tools from the tool storage
  navigationTools->DeleteAllTools();

  //and add only the detected tools in the right order
  for (int i=0; i<newToolStorageInRightOrder->GetToolCount(); i++)
      {
      navigationTools->AddTool(newToolStorageInRightOrder->GetTool(i));
      }
  returnValue->SetTrackingDevice(thisDevice);
  return returnValue;
  }
コード例 #4
0
 mitk::TrackingDeviceSource::Pointer PolhemusTrackerTypeInformation::CreateTrackingDeviceSource(
   mitk::TrackingDevice::Pointer trackingDevice,
   mitk::NavigationToolStorage::Pointer navigationTools,
   std::string* errorMessage,
   std::vector<int>* toolCorrespondencesInToolStorage)
 {
   mitk::TrackingDeviceSource::Pointer returnValue = mitk::TrackingDeviceSource::New();
   mitk::PolhemusTrackingDevice::Pointer thisDevice = dynamic_cast<mitk::PolhemusTrackingDevice*>(trackingDevice.GetPointer());
   *toolCorrespondencesInToolStorage = std::vector<int>();
   //add the tools to the tracking device
   for (unsigned int i = 0; i < navigationTools->GetToolCount(); i++)
   {
     mitk::NavigationTool::Pointer thisNavigationTool = navigationTools->GetTool(i);
     toolCorrespondencesInToolStorage->push_back(i);
     bool toolAddSuccess = thisDevice->AddTool(thisNavigationTool->GetToolName().c_str(), std::stoi(thisNavigationTool->GetIdentifier()));
     if (!toolAddSuccess)
     {
       //todo error handling
       errorMessage->append("Can't add tool, is the toolfile valid?");
       return NULL;
     }
     thisDevice->GetTool(i)->SetToolTipPosition(thisNavigationTool->GetToolTipPosition(), thisNavigationTool->GetToolAxisOrientation());
   }
   returnValue->SetTrackingDevice(thisDevice);
   return returnValue;
 }
コード例 #5
0
void mitk::TrackingVolumeGenerator::SetTrackingDevice (mitk::TrackingDevice::Pointer tracker)
{
  this->m_Data = mitk::GetFirstCompatibleDeviceDataForLine(tracker->GetType());
}
mitk::TrackingDeviceSource::Pointer mitk::TrackingDeviceSourceConfigurator::CreateOpenIGTLinkTrackingDeviceSource(mitk::TrackingDevice::Pointer trackingDevice, mitk::NavigationToolStorage::Pointer navigationTools)
{
  mitk::TrackingDeviceSource::Pointer returnValue = mitk::TrackingDeviceSource::New();
  mitk::OpenIGTLinkTrackingDevice::Pointer thisDevice = dynamic_cast<mitk::OpenIGTLinkTrackingDevice*>(trackingDevice.GetPointer());
  thisDevice->DiscoverTools();
  if (thisDevice->GetToolCount() != navigationTools->GetToolCount())
    {
    this->m_ErrorMessage = "The number of tools in the connected device differs from the tool storage, cannot add tools.";
    return NULL;
    }
  returnValue->SetTrackingDevice(thisDevice);
  return returnValue;
}