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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #include "gtest/gtest.h"
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 #include "../OrthancServer/FromDcmtkBridge.h"
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 #include "../OrthancServer/OrthancInitialization.h"
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 785
diff changeset
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
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 using namespace Orthanc;
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 TEST(DicomFormat, Tag)
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 {
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010)));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 ASSERT_EQ(0x0008, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 ASSERT_EQ(0x103E, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 t = FromDcmtkBridge::ParseTag("0020-e040");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 ASSERT_EQ(0x0020, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 ASSERT_EQ(0xe040, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 // Test ==() and !=() operators
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 }
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
7cbed653476f path for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 784
diff changeset
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
7cbed653476f path for windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 784
diff changeset
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 }