Commit c11de80d authored by Sebastien Jodogne's avatar Sebastien Jodogne
Browse files

New upstream version 1.5.1+dfsg

parent 94c7917f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
repo: 3959d33612ccaadc0d4d707227fbed09ac35e5fe
node: 38b71a1006fd22750bb8f9ada9d2c6085bfe26de
branch: Orthanc-1.5.0
node: 870d19e7ea593126b5e7994cbc870847e09843fa
branch: Orthanc-1.5.1
latesttag: dcmtk-3.6.1
latesttagdistance: 554
changessincelatesttag: 613
latesttagdistance: 580
changessincelatesttag: 644
+18 −12
Original line number Diff line number Diff line
@@ -195,17 +195,23 @@ namespace Orthanc
      numberOfFrames_ = 1;
    }

    if ((bitsAllocated_ != 8 && bitsAllocated_ != 16 && 
         bitsAllocated_ != 24 && bitsAllocated_ != 32) ||
        numberOfFrames_ == 0 ||
        (planarConfiguration != 0 && planarConfiguration != 1))
    if (bitsAllocated_ != 8 && bitsAllocated_ != 16 &&
        bitsAllocated_ != 24 && bitsAllocated_ != 32)
    {
      throw OrthancException(ErrorCode_NotImplemented);
      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: " + boost::lexical_cast<std::string>(bitsAllocated_) + " bits allocated");
    }
    else if (numberOfFrames_ == 0)
    {
      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported (no frames)");
    }
    else if (planarConfiguration != 0 && planarConfiguration != 1)
    {
      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: planar configuration is " + boost::lexical_cast<std::string>(planarConfiguration));
    }

    if (samplesPerPixel_ == 0)
    {
      throw OrthancException(ErrorCode_NotImplemented);
      throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: samples per pixel is 0");
    }

    bytesPerValue_ = bitsAllocated_ / 8;
+106 −0
Original line number Diff line number Diff line
@@ -982,6 +982,112 @@ namespace Orthanc
  }

  
  void DicomMap::FromDicomAsJson(const Json::Value& dicomAsJson)
  {
    Clear();
    
    Json::Value::Members tags = dicomAsJson.getMemberNames();
    for (Json::Value::Members::const_iterator
           it = tags.begin(); it != tags.end(); ++it)
    {
      DicomTag tag(0, 0);
      if (!DicomTag::ParseHexadecimal(tag, it->c_str()))
      {
        throw OrthancException(ErrorCode_CorruptedFile);
      }

      const Json::Value& value = dicomAsJson[*it];

      if (value.type() != Json::objectValue ||
          !value.isMember("Type") ||
          !value.isMember("Value") ||
          value["Type"].type() != Json::stringValue)
      {
        throw OrthancException(ErrorCode_CorruptedFile);
      }

      if (value["Type"] == "String")
      {
        if (value["Value"].type() != Json::stringValue)
        {
          throw OrthancException(ErrorCode_CorruptedFile);
        }
        else
        {
          SetValue(tag, value["Value"].asString(), false /* not binary */);
        }
      }
    }
  }


  void DicomMap::Merge(const DicomMap& other)
  {
    for (Map::const_iterator it = other.map_.begin();
         it != other.map_.end(); ++it)
    {
      assert(it->second != NULL);

      if (map_.find(it->first) == map_.end())
      {
        map_[it->first] = it->second->Clone();
      }
    }
  }


  void DicomMap::ExtractMainDicomTagsInternal(const DicomMap& other,
                                              ResourceType level)
  {
    const DicomTag* tags = NULL;
    size_t size = 0;

    LoadMainDicomTags(tags, size, level);
    assert(tags != NULL && size > 0);

    for (size_t i = 0; i < size; i++)
    {
      Map::const_iterator found = other.map_.find(tags[i]);

      if (found != other.map_.end() &&
          map_.find(tags[i]) == map_.end())
      {
        assert(found->second != NULL);
        map_[tags[i]] = found->second->Clone();
      }
    }
  }
    

  void DicomMap::ExtractMainDicomTags(const DicomMap& other)
  {
    Clear();
    ExtractMainDicomTagsInternal(other, ResourceType_Patient);
    ExtractMainDicomTagsInternal(other, ResourceType_Study);
    ExtractMainDicomTagsInternal(other, ResourceType_Series);
    ExtractMainDicomTagsInternal(other, ResourceType_Instance);
  }    


  bool DicomMap::HasOnlyMainDicomTags() const
  {
    // TODO - Speed up possible by making this std::set a global variable

    std::set<DicomTag> mainDicomTags;
    GetMainDicomTags(mainDicomTags);

    for (Map::const_iterator it = map_.begin(); it != map_.end(); ++it)
    {
      if (mainDicomTags.find(it->first) == mainDicomTags.end())
      {
        return false;
      }
    }

    return true;
  }
    

  void DicomMap::Serialize(Json::Value& target) const
  {
    target = Json::objectValue;
+12 −1
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@ namespace Orthanc
   
    static void GetMainDicomTagsInternal(std::set<DicomTag>& result, ResourceType level);

    void ExtractMainDicomTagsInternal(const DicomMap& other,
                                      ResourceType level);

  public:
    DicomMap()
    {
@@ -217,6 +220,14 @@ namespace Orthanc
    bool ParseDouble(double& result,
                     const DicomTag& tag) const;

    void FromDicomAsJson(const Json::Value& dicomAsJson);

    void Merge(const DicomMap& other);

    void ExtractMainDicomTags(const DicomMap& other);

    bool HasOnlyMainDicomTags() const;
    
    void Serialize(Json::Value& target) const;

    void Unserialize(const Json::Value& source);
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ namespace Orthanc
    if (SystemToolbox::IsRegularFile(p.string()))
    {
      FilesystemHttpSender sender(p);
      sender.SetContentType(SystemToolbox::AutodetectMimeType(p.string()));
      output.Answer(sender);   // TODO COMPRESSION
    }
    else if (listDirectoryContent_ &&
Loading