# HG changeset patch # User Sebastien Jodogne # Date 1399028345 -7200 # Node ID a60040857ce65a24cd3c46446ef2a9fc13960730 # Parent e7eb70772fbed02322d44c94a2779e113a5d7b93 reorganization diff -r e7eb70772fbe -r a60040857ce6 CMakeLists.txt --- a/CMakeLists.txt Fri May 02 11:05:26 2014 +0200 +++ b/CMakeLists.txt Fri May 02 12:59:05 2014 +0200 @@ -263,6 +263,7 @@ ${GTEST_SOURCES} UnitTestsSources/DicomMap.cpp UnitTestsSources/FileStorage.cpp + UnitTestsSources/FromDcmtk.cpp UnitTestsSources/MemoryCache.cpp UnitTestsSources/Png.cpp UnitTestsSources/RestApi.cpp diff -r e7eb70772fbe -r a60040857ce6 OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Fri May 02 11:05:26 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Fri May 02 12:59:05 2014 +0200 @@ -36,19 +36,6 @@ namespace Orthanc { - // Raw access to the DICOM tags of an instance ------------------------------ - - static void GetRawContent(RestApi::GetCall& call) - { - std::string id = call.GetUriComponent("id", ""); - - ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); - - locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri()); - } - - - // Modification of DICOM instances ------------------------------------------ namespace @@ -61,7 +48,6 @@ static void ReplaceInstanceInternal(ParsedDicomFile& toModify, const Removals& removals, const Replacements& replacements, - DicomReplaceMode mode, bool removePrivateTags) { if (removePrivateTags) @@ -78,7 +64,7 @@ for (Replacements::const_iterator it = replacements.begin(); it != replacements.end(); ++it) { - toModify.Replace(it->first, it->second, mode); + toModify.Replace(it->first, it->second, DicomReplaceMode_InsertIfAbsent); } // A new SOP instance UID is automatically generated @@ -336,7 +322,7 @@ ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); std::auto_ptr modified(locker.GetDicom().Clone()); - ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags); + ReplaceInstanceInternal(*modified, removals, replacements, removePrivateTags); modified->Answer(call.GetOutput()); } @@ -460,7 +446,7 @@ **/ std::auto_ptr modified(original.Clone()); - ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags); + ReplaceInstanceInternal(*modified, removals, replacements, removePrivateTags); std::string modifiedInstance; if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success) @@ -680,8 +666,6 @@ void OrthancRestApi::RegisterAnonymizeModify() { - Register("/instances/{id}/content/*", GetRawContent); - Register("/instances/{id}/modify", ModifyInstance); Register("/series/{id}/modify", ModifySeriesInplace); Register("/studies/{id}/modify", ModifyStudyInplace); diff -r e7eb70772fbe -r a60040857ce6 OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Fri May 02 11:05:26 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Fri May 02 12:59:05 2014 +0200 @@ -541,6 +541,17 @@ } + // Raw access to the DICOM tags of an instance ------------------------------ + + static void GetRawContent(RestApi::GetCall& call) + { + std::string id = call.GetUriComponent("id", ""); + + ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); + + locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri()); + } + void OrthancRestApi::RegisterResources() @@ -598,5 +609,7 @@ Register("/{resourceType}/{id}/attachments/{name}/size", GetAttachmentSize); Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment); Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment); + + Register("/instances/{id}/content/*", GetRawContent); } } diff -r e7eb70772fbe -r a60040857ce6 UnitTestsSources/FromDcmtk.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UnitTestsSources/FromDcmtk.cpp Fri May 02 12:59:05 2014 +0200 @@ -0,0 +1,25 @@ +#include "gtest/gtest.h" + +#include "../OrthancServer/FromDcmtkBridge.h" +#include "../OrthancServer/OrthancInitialization.h" + +using namespace Orthanc; + +TEST(DicomFormat, Tag) +{ + ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010))); + + DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription"); + ASSERT_EQ(0x0008, t.GetGroup()); + ASSERT_EQ(0x103E, t.GetElement()); + + t = FromDcmtkBridge::ParseTag("0020-e040"); + ASSERT_EQ(0x0020, t.GetGroup()); + ASSERT_EQ(0xe040, t.GetElement()); + + // Test ==() and !=() operators + ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020)); + ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020)); +} + + diff -r e7eb70772fbe -r a60040857ce6 UnitTestsSources/UnitTestsMain.cpp --- a/UnitTestsSources/UnitTestsMain.cpp Fri May 02 11:05:26 2014 +0200 +++ b/UnitTestsSources/UnitTestsMain.cpp Fri May 02 12:59:05 2014 +0200 @@ -10,7 +10,6 @@ #include "../Core/OrthancException.h" #include "../Core/Toolbox.h" #include "../Core/Uuid.h" -#include "../OrthancServer/FromDcmtkBridge.h" #include "../OrthancServer/OrthancInitialization.h" using namespace Orthanc; @@ -178,24 +177,6 @@ ASSERT_EQ(a["aaa"], ""); } -TEST(DicomFormat, Tag) -{ - ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010))); - - DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription"); - ASSERT_EQ(0x0008, t.GetGroup()); - ASSERT_EQ(0x103E, t.GetElement()); - - t = FromDcmtkBridge::ParseTag("0020-e040"); - ASSERT_EQ(0x0020, t.GetGroup()); - ASSERT_EQ(0xe040, t.GetElement()); - - // Test ==() and !=() operators - ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020)); - ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020)); -} - - TEST(Uri, SplitUriComponents) { UriComponents c;