Mercurial > hg > orthanc
annotate UnitTestsSources/FromDcmtk.cpp @ 786:b6d6b65142e8
DicomModification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 05 May 2014 13:07:10 +0200 |
parents | 7cbed653476f |
children | ecedd89055db |
rev | line source |
---|---|
782 | 1 #include "gtest/gtest.h" |
2 | |
3 #include "../OrthancServer/FromDcmtkBridge.h" | |
4 #include "../OrthancServer/OrthancInitialization.h" | |
786 | 5 #include "../OrthancServer/DicomModification.h" |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
6 #include "../Core/OrthancException.h" |
782 | 7 |
8 using namespace Orthanc; | |
9 | |
10 TEST(DicomFormat, Tag) | |
11 { | |
12 ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010))); | |
13 | |
14 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription"); | |
15 ASSERT_EQ(0x0008, t.GetGroup()); | |
16 ASSERT_EQ(0x103E, t.GetElement()); | |
17 | |
18 t = FromDcmtkBridge::ParseTag("0020-e040"); | |
19 ASSERT_EQ(0x0020, t.GetGroup()); | |
20 ASSERT_EQ(0xe040, t.GetElement()); | |
21 | |
22 // Test ==() and !=() operators | |
23 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020)); | |
24 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020)); | |
25 } | |
26 | |
27 | |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
28 TEST(DicomModification, Basic) |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
29 { |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
30 DicomModification m; |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
31 m.SetupAnonymization(); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
32 //m.SetLevel(DicomRootLevel_Study); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
33 //m.Replace(DICOM_TAG_PATIENT_ID, "coucou"); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
34 //m.Replace(DICOM_TAG_PATIENT_NAME, "coucou"); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
35 |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
36 ParsedDicomFile o; |
785 | 37 o.SaveToFile("anon.dcm"); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
38 |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
39 for (int i = 0; i < 10; i++) |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
40 { |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
41 char b[1024]; |
785 | 42 sprintf(b, "anon%06d.dcm", i); |
784
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
43 std::auto_ptr<ParsedDicomFile> f(o.Clone()); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
44 if (i > 4) |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
45 o.Replace(DICOM_TAG_SERIES_INSTANCE_UID, "coucou"); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
46 m.Apply(*f); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
47 f->SaveToFile(b); |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
48 } |
efd0215736d9
start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
49 } |