Mercurial > hg > orthanc-stone
comparison OrthancStone/UnitTestsSources/DicomTests.cpp @ 2169:fe5406abd43f
added separate class Windowing
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Oct 2024 15:40:34 +0200 |
parents | 16c01cc201e7 |
children |
comparison
equal
deleted
inserted
replaced
2168:14d6080660e7 | 2169:fe5406abd43f |
---|---|
64 ASSERT_THROW(p->IsColor(), Orthanc::OrthancException); // Accesses DicomImageInformation | 64 ASSERT_THROW(p->IsColor(), Orthanc::OrthancException); // Accesses DicomImageInformation |
65 ASSERT_FALSE(p->HasRescale()); | 65 ASSERT_FALSE(p->HasRescale()); |
66 ASSERT_THROW(p->GetRescaleIntercept(), Orthanc::OrthancException); | 66 ASSERT_THROW(p->GetRescaleIntercept(), Orthanc::OrthancException); |
67 ASSERT_THROW(p->GetRescaleSlope(), Orthanc::OrthancException); | 67 ASSERT_THROW(p->GetRescaleSlope(), Orthanc::OrthancException); |
68 ASSERT_EQ(0u, p->GetWindowingPresetsCount()); | 68 ASSERT_EQ(0u, p->GetWindowingPresetsCount()); |
69 ASSERT_THROW(p->GetWindowingPresetCenter(0), Orthanc::OrthancException); | 69 ASSERT_THROW(p->GetWindowingPreset(0), Orthanc::OrthancException); |
70 ASSERT_THROW(p->GetWindowingPresetWidth(0), Orthanc::OrthancException); | 70 |
71 | 71 OrthancStone::Windowing w = p->GetWindowingPresetsUnion(); |
72 float c, w; | 72 ASSERT_FLOAT_EQ(128.0f, w.GetCenter()); |
73 p->GetWindowingPresetsUnion(c, w); | 73 ASSERT_FLOAT_EQ(256.0f, w.GetWidth()); |
74 ASSERT_FLOAT_EQ(128.0f, c); | |
75 ASSERT_FLOAT_EQ(256.0f, w); | |
76 | 74 |
77 ASSERT_THROW(p->GetExpectedPixelFormat(), Orthanc::OrthancException); | 75 ASSERT_THROW(p->GetExpectedPixelFormat(), Orthanc::OrthancException); |
78 ASSERT_FALSE(p->HasIndexInSeries()); | 76 ASSERT_FALSE(p->HasIndexInSeries()); |
79 ASSERT_THROW(p->GetIndexInSeries(), Orthanc::OrthancException); | 77 ASSERT_THROW(p->GetIndexInSeries(), Orthanc::OrthancException); |
80 ASSERT_TRUE(p->GetDoseUnits().empty()); | 78 ASSERT_TRUE(p->GetDoseUnits().empty()); |
94 m.SetValue(Orthanc::DICOM_TAG_WINDOW_CENTER, "10\\100\\1000", false); | 92 m.SetValue(Orthanc::DICOM_TAG_WINDOW_CENTER, "10\\100\\1000", false); |
95 m.SetValue(Orthanc::DICOM_TAG_WINDOW_WIDTH, "50\\60\\70", false); | 93 m.SetValue(Orthanc::DICOM_TAG_WINDOW_WIDTH, "50\\60\\70", false); |
96 | 94 |
97 OrthancStone::DicomInstanceParameters p(m); | 95 OrthancStone::DicomInstanceParameters p(m); |
98 ASSERT_EQ(3u, p.GetWindowingPresetsCount()); | 96 ASSERT_EQ(3u, p.GetWindowingPresetsCount()); |
99 ASSERT_FLOAT_EQ(10, p.GetWindowingPresetCenter(0)); | 97 ASSERT_FLOAT_EQ(10, p.GetWindowingPreset(0).GetCenter()); |
100 ASSERT_FLOAT_EQ(100, p.GetWindowingPresetCenter(1)); | 98 ASSERT_FLOAT_EQ(100, p.GetWindowingPreset(1).GetCenter()); |
101 ASSERT_FLOAT_EQ(1000, p.GetWindowingPresetCenter(2)); | 99 ASSERT_FLOAT_EQ(1000, p.GetWindowingPreset(2).GetCenter()); |
102 ASSERT_FLOAT_EQ(50, p.GetWindowingPresetWidth(0)); | 100 ASSERT_FLOAT_EQ(50, p.GetWindowingPreset(0).GetWidth()); |
103 ASSERT_FLOAT_EQ(60, p.GetWindowingPresetWidth(1)); | 101 ASSERT_FLOAT_EQ(60, p.GetWindowingPreset(1).GetWidth()); |
104 ASSERT_FLOAT_EQ(70, p.GetWindowingPresetWidth(2)); | 102 ASSERT_FLOAT_EQ(70, p.GetWindowingPreset(2).GetWidth()); |
105 | 103 |
106 const float a = 10.0f - 50.0f / 2.0f; | 104 const float a = 10.0f - 50.0f / 2.0f; |
107 const float b = 1000.0f + 70.0f / 2.0f; | 105 const float b = 1000.0f + 70.0f / 2.0f; |
108 | 106 |
109 float c, w; | 107 OrthancStone::Windowing w = p.GetWindowingPresetsUnion(); |
110 p.GetWindowingPresetsUnion(c, w); | 108 ASSERT_FLOAT_EQ((a + b) / 2.0f, w.GetCenter()); |
111 ASSERT_FLOAT_EQ((a + b) / 2.0f, c); | 109 ASSERT_FLOAT_EQ(b - a, w.GetWidth()); |
112 ASSERT_FLOAT_EQ(b - a, w); | |
113 } | 110 } |
114 | 111 |
115 | 112 |
116 TEST(DicomSource, Equality) | 113 TEST(DicomSource, Equality) |
117 { | 114 { |