示例#1
0
bool mitk::CheckUID(const mitk::BaseData* data, const NodeUIDType& uid)
{
  bool result = false;

  BaseProperty::Pointer uidProp = data->GetProperty(mitk::Prop_UID);

  if (uidProp.IsNotNull())
  {
    result = uidProp->GetValueAsString() == uid;
  }

  return result;
};
示例#2
0
mitk::NodeUIDType mitk::EnsureUID(mitk::BaseData* data)
{
  if (!data)
  {
    mitkThrow() << "Cannot ensure node UID. Passed node pointer is nullptr.";
  }

  BaseProperty::Pointer uidProp = data->GetProperty(mitk::Prop_UID);
  std::string propUID = "";

  if (uidProp.IsNotNull())
  {
    propUID = uidProp->GetValueAsString();
  }
  else
  {
    mitk::UIDGenerator generator;
    propUID = generator.GetUID();

    data->SetProperty(mitk::Prop_UID, mitk::StringProperty::New(propUID));
  }

  return propUID;
};