Esempio n. 1
0
static std::string CreateFileName(mitk::DataNode::Pointer dataNode)
{
  std::string path;
  dataNode->GetStringProperty("path", path);

  std::string name;
  dataNode->GetStringProperty("name", name);

  if (name.length() < 5)
  {
    name += ".scn";
  }
  else
  {
    std::string ext = name.substr(name.length() - 4);
    std::transform(ext.begin(), ext.end(), ext.begin(), tolower);

    if (ext != ".scn" && ext != ".xml")
      name += ".scn";
  }

  return path + "/" + name;
}
Esempio n. 2
0
mitk::NavigationTool::Pointer mitk::NavigationToolReader::ConvertDataNodeToNavigationTool(mitk::DataNode::Pointer node, std::string toolPath)
{
  mitk::NavigationTool::Pointer returnValue = mitk::NavigationTool::New();

  //DateTreeNode with Name and Surface
  returnValue->SetDataNode(node);

  //Identifier
  std::string identifier;
  node->GetStringProperty("identifier", identifier);
  returnValue->SetIdentifier(identifier);

  node->RemoveProperty("identifier");

  //Serial Number
  std::string serial;
  node->GetStringProperty("serial number", serial);
  returnValue->SetSerialNumber(serial);

  node->RemoveProperty("serial number");

  //Tracking Device
  mitk::TrackingDeviceType device_type;
  node->GetStringProperty("tracking device type", device_type);

  //For backward compability with old tool stroages (before 12/2015 device_type was an int value, now it is string)
  if (device_type.size() == 0)
  {
    /*
    This was the old enum. Numbers inserted for better readibility. Don't delete this if-case to allow loading of ols storages...
    enum TrackingDeviceType
    {
    0 NDIPolaris,                 ///< Polaris: optical Tracker from NDI
    1 NDIAurora,                  ///< Aurora: electromagnetic Tracker from NDI
    2 ClaronMicron,               ///< Micron Tracker: optical Tracker from Claron
    3 IntuitiveDaVinci,           ///< Intuitive Surgical: DaVinci Telemanipulator API Interface
    4 AscensionMicroBird,         ///< Ascension microBird / PCIBird family
    5 VirtualTracker,             ///< Virtual Tracking device class that produces random tracking coordinates
    6 TrackingSystemNotSpecified, ///< entry for not specified or initialized tracking system
    7 TrackingSystemInvalid,      ///< entry for invalid state (mainly for testing)
    8 NPOptitrack,                          ///< NaturalPoint: Optitrack optical Tracking System
    9 OpenIGTLinkTrackingDeviceConnection   ///< Device which is connected via open igt link
    };
    */
    int device_type_old;
    node->GetIntProperty("tracking device type", device_type_old);
    switch (device_type_old)
    {
    case 0:device_type = mitk::NDIPolarisTypeInformation::GetTrackingDeviceName(); break;
    case 1:device_type = mitk::NDIAuroraTypeInformation::GetTrackingDeviceName(); break;
    case 2:device_type = mitk::MicronTrackerTypeInformation::GetTrackingDeviceName(); break;
    case 3:device_type = "IntuitiveDaVinci"; break;
    case 4:device_type = "AscensionMicroBird"; break;
    case 5:device_type = mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName(); break;
    case 6:device_type = mitk::UnspecifiedTrackingTypeInformation::GetTrackingDeviceName(); break;
    case 7:device_type = "TrackingSystemInvalid"; break;
    case 8:device_type = mitk::NPOptitrackTrackingTypeInformation::GetTrackingDeviceName(); break;
    case 9:device_type = mitk::OpenIGTLinkTypeInformation::GetTrackingDeviceName(); break;
    default: device_type = mitk::UnspecifiedTrackingTypeInformation::GetTrackingDeviceName(); break; //default... unknown...
    }
  }

  node->RemoveProperty("tracking device type");

  returnValue->SetTrackingDeviceType(static_cast<mitk::TrackingDeviceType>(device_type));

  //Tool Type
  int type;
  node->GetIntProperty("tracking tool type", type);
  returnValue->SetType(static_cast<mitk::NavigationTool::NavigationToolType>(type));

  node->RemoveProperty("tracking tool type");

  //Calibration File Name
  std::string calibration_filename;
  node->GetStringProperty("toolfileName", calibration_filename);
  if (calibration_filename == "none")
  {
    returnValue->SetCalibrationFile("none");
  }
  else
  {
    std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename;
    returnValue->SetCalibrationFile(calibration_filename_with_path);
  }

  node->RemoveProperty("toolfileName");

  //Tool Landmarks
  mitk::PointSet::Pointer ToolRegLandmarks = mitk::PointSet::New();
  mitk::PointSet::Pointer ToolCalLandmarks = mitk::PointSet::New();
  std::string RegLandmarksString;
  std::string CalLandmarksString;
  node->GetStringProperty("ToolRegistrationLandmarks", RegLandmarksString);
  node->GetStringProperty("ToolCalibrationLandmarks", CalLandmarksString);
  ToolRegLandmarks = ConvertStringToPointSet(RegLandmarksString);
  ToolCalLandmarks = ConvertStringToPointSet(CalLandmarksString);
  returnValue->SetToolLandmarks(ToolRegLandmarks);
  returnValue->SetToolControlPoints(ToolCalLandmarks);

  node->RemoveProperty("ToolRegistrationLandmarks");
  node->RemoveProperty("ToolCalibrationLandmarks");

  //Tool Tip
  std::string toolTipPositionString;
  std::string toolTipOrientationString;
  bool positionSet = node->GetStringProperty("ToolTipPosition", toolTipPositionString);
  bool orientationSet = node->GetStringProperty("ToolAxisOrientation", toolTipOrientationString);

  if (positionSet && orientationSet) //only define tooltip if it is set
  {
    returnValue->SetToolTipPosition(ConvertStringToPoint(toolTipPositionString));
    returnValue->SetToolAxisOrientation(ConvertStringToQuaternion(toolTipOrientationString));
  }
  else if (positionSet != orientationSet)
  {
    MITK_WARN << "Tooltip definition incomplete: position and orientation have to be set! Skipping tooltip definition.";
  }

  node->RemoveProperty("ToolTipPosition");
  node->RemoveProperty("ToolAxisOrientation");

  return returnValue;
}
mitk::NavigationTool::Pointer mitk::NavigationToolReader::ConvertDataNodeToNavigationTool(mitk::DataNode::Pointer node, std::string toolPath)
  {
  mitk::NavigationTool::Pointer returnValue = mitk::NavigationTool::New();

  //DateTreeNode with Name and Surface
  mitk::DataNode::Pointer newNode = mitk::DataNode::New();
  newNode->SetName(node->GetName());
  newNode->SetData(node->GetData());
  returnValue->SetDataNode(newNode);

  //Identifier
  std::string identifier;
  node->GetStringProperty("identifier",identifier);
  returnValue->SetIdentifier(identifier);

  //Serial Number
  std::string serial;
  node->GetStringProperty("serial number",serial);
  returnValue->SetSerialNumber(serial);

  //Tracking Device
  int device_type;
  node->GetIntProperty("tracking device type",device_type);
  returnValue->SetTrackingDeviceType(static_cast<mitk::TrackingDeviceType>(device_type));

  //Tool Type
  int type;
  node->GetIntProperty("tracking tool type",type);
  returnValue->SetType(static_cast<mitk::NavigationTool::NavigationToolType>(type));

  //Calibration File Name
  std::string calibration_filename;
  node->GetStringProperty("toolfileName",calibration_filename);
  if (calibration_filename=="none")
    {
    returnValue->SetCalibrationFile("none");
    }
  else
    {
    std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename;
    returnValue->SetCalibrationFile(calibration_filename_with_path);
    }

  //Tool Landmarks
  mitk::PointSet::Pointer ToolRegLandmarks = mitk::PointSet::New();
  mitk::PointSet::Pointer ToolCalLandmarks = mitk::PointSet::New();
  std::string RegLandmarksString;
  std::string CalLandmarksString;
  node->GetStringProperty("ToolRegistrationLandmarks",RegLandmarksString);
  node->GetStringProperty("ToolCalibrationLandmarks",CalLandmarksString);
  ToolRegLandmarks = ConvertStringToPointSet(RegLandmarksString);
  ToolCalLandmarks = ConvertStringToPointSet(CalLandmarksString);
  returnValue->SetToolRegistrationLandmarks(ToolRegLandmarks);
  returnValue->SetToolCalibrationLandmarks(ToolCalLandmarks);

  //Tool Tip
  std::string toolTipPositionString;
  std::string toolTipOrientationString;
  bool positionSet = node->GetStringProperty("ToolTipPosition",toolTipPositionString);
  bool orientationSet = node->GetStringProperty("ToolTipOrientation",toolTipOrientationString);

  if(positionSet && orientationSet) //only define tooltip if it is set
    {
    returnValue->SetToolTipPosition(ConvertStringToPoint(toolTipPositionString));
    returnValue->SetToolTipOrientation(ConvertStringToQuaternion(toolTipOrientationString));
    }
  else if(positionSet != orientationSet)
    {
    MITK_WARN << "Tooltip definition incomplete: position and orientation have to be set! Skipping tooltip definition.";
    }

  return returnValue;
  }