コード例 #1
0
void
mitk::DICOMGDCMTagScanner
::AddTag(const DICOMTag& tag)
{
  m_ScannedTags.insert(tag);
  m_GDCMScanner.AddTag( gdcm::Tag(tag.GetGroup(), tag.GetElement()) ); // also a set, duplicate calls to AddTag don't hurt
}
コード例 #2
0
mitk::DICOMDatasetFinding
mitk::DICOMGDCMImageFrameInfo
::GetTagValueAsString(const DICOMTag& tag) const
{
  const auto mappedValue = m_TagForValue.find( gdcm::Tag(tag.GetGroup(), tag.GetElement()) );
  DICOMDatasetFinding result;

  if (mappedValue != m_TagForValue.cend())
  {
    result.isValid = true;

    if (mappedValue->second != nullptr)
    {
      std::string s(mappedValue->second);
      try
      {
        result.value = s.erase(s.find_last_not_of(" \n\r\t")+1);
      }
      catch(...)
      {
        result.value = s;
      }
    }
    else
    {
      result.value = "";
    }
  }
  else
  {
    const DICOMTag tagImagePositionPatient = DICOMTag(0x0020,0x0032); // Image Position (Patient)
    const DICOMTag    tagImageOrientation = DICOMTag(0x0020, 0x0037); // Image Orientation

    if (tag == tagImagePositionPatient)
    {
      result.isValid = true;
      result.value = std::string("0\\0\\0");
    }
    else if (tag == tagImageOrientation)
    {
      result.isValid = true;
      result.value = std::string("1\\0\\0\\0\\1\\0");
    }
    else
    {
      result.isValid = false;
      result.value = "";
    }
  }
  return result;
}
コード例 #3
0
std::string
mitk::DICOMGDCMTagScanner
::GetTagValue(DICOMImageFrameInfo* frame, const DICOMTag& tag) const
{
  assert(frame);

  for(auto frameIter = m_ScanResult.begin();
      frameIter != m_ScanResult.end();
      ++frameIter)
  {
    if ( (*frameIter)->GetFrameInfo().IsNotNull() &&
         (*((*frameIter)->GetFrameInfo()) == *frame )
       )
    {
      return (*frameIter)->GetTagValueAsString(tag);
    }

  }

  if ( m_ScannedTags.find(tag) != m_ScannedTags.end() )
  {
    if ( std::find( m_InputFilenames.begin(), m_InputFilenames.end(), frame->Filename ) != m_InputFilenames.end() )
    {
      // precondition of gdcm::Scanner::GetValue() fulfilled
      return m_GDCMScanner.GetValue( frame->Filename.c_str(), gdcm::Tag( tag.GetGroup(), tag.GetElement() ) );
    }
    else
    {
      // callers are required to tell us about the filenames they are interested in
      // this is a helpful reminder for them to inform us
      std::stringstream errorstring;
      errorstring << "Invalid call to DICOMGDCMTagScanner::GetTagValue( "
        << "'" << frame->Filename << "', frame " << frame->FrameNo
        << " ). Filename was never mentioned before!";
      MITK_ERROR << errorstring.str();
      throw std::invalid_argument(errorstring.str());
    }
  }
  else
  {
    // callers are required to tell us about the tags they are interested in
    // this is a helpful reminder for them to inform us
    std::stringstream errorstring;
    errorstring << "Invalid call to DICOMGDCMTagScanner::GetTagValue( ";
    tag.Print(errorstring);
    errorstring << " ). Tag was never mentioned before!";
    MITK_ERROR << errorstring.str();
    throw std::invalid_argument(errorstring.str());
  }
}