Mercurial > hg > orthanc-stone
comparison UnitTestsSources/UnitTestsMain.cpp @ 860:238693c3bc51 am-dev
merge default -> am-dev
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 24 Jun 2019 14:35:00 +0200 |
parents | e8fdf29cd0ca |
children | 118fc5c85d07 |
comparison
equal
deleted
inserted
replaced
856:a6e17a5a39e7 | 860:238693c3bc51 |
---|---|
17 * You should have received a copy of the GNU Affero General Public License | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #include "../Framework/dev.h" | |
23 #include "gtest/gtest.h" | 22 #include "gtest/gtest.h" |
24 | 23 |
25 #include "../Framework/Layers/FrameRenderer.h" | 24 #include "../Framework/Deprecated/Layers/FrameRenderer.h" |
26 #include "../Framework/Toolbox/DownloadStack.h" | 25 #include "../Framework/Deprecated/Toolbox/DownloadStack.h" |
26 #include "../Framework/Deprecated/Toolbox/MessagingToolbox.h" | |
27 #include "../Framework/Deprecated/Toolbox/OrthancSlicesLoader.h" | |
27 #include "../Framework/Toolbox/FiniteProjectiveCamera.h" | 28 #include "../Framework/Toolbox/FiniteProjectiveCamera.h" |
28 #include "../Framework/Toolbox/MessagingToolbox.h" | 29 #include "../Framework/Toolbox/GeometryToolbox.h" |
29 #include "../Framework/Toolbox/OrthancSlicesLoader.h" | |
30 #include "../Framework/Volumes/ImageBuffer3D.h" | 30 #include "../Framework/Volumes/ImageBuffer3D.h" |
31 #include "../Platforms/Generic/OracleWebService.h" | 31 #include "../Platforms/Generic/OracleWebService.h" |
32 | 32 |
33 #include <Core/HttpClient.h> | 33 #include <Core/HttpClient.h> |
34 #include <Core/Images/ImageProcessing.h> | 34 #include <Core/Images/ImageProcessing.h> |
38 | 38 |
39 #include <boost/lexical_cast.hpp> | 39 #include <boost/lexical_cast.hpp> |
40 #include <boost/date_time/posix_time/posix_time.hpp> | 40 #include <boost/date_time/posix_time/posix_time.hpp> |
41 #include <boost/thread/thread.hpp> | 41 #include <boost/thread/thread.hpp> |
42 #include <boost/math/special_functions/round.hpp> | 42 #include <boost/math/special_functions/round.hpp> |
43 | |
44 | |
45 #if 0 | |
46 namespace OrthancStone | |
47 { | |
48 class Tata : public OrthancSlicesLoader::ICallback | |
49 { | |
50 public: | |
51 virtual void NotifyGeometryReady(const OrthancSlicesLoader& loader) | |
52 { | |
53 printf(">> %d\n", (int) loader.GetSliceCount()); | |
54 | |
55 for (size_t i = 0; i < loader.GetSliceCount(); i++) | |
56 { | |
57 const_cast<OrthancSlicesLoader&>(loader).ScheduleLoadSliceImage(i, SliceImageQuality_FullPng); | |
58 } | |
59 } | |
60 | |
61 virtual void NotifyGeometryError(const OrthancSlicesLoader& loader) | |
62 { | |
63 printf("Error\n"); | |
64 } | |
65 | |
66 virtual void NotifySliceImageReady(const OrthancSlicesLoader& loader, | |
67 unsigned int sliceIndex, | |
68 const Slice& slice, | |
69 std::auto_ptr<Orthanc::ImageAccessor>& image, | |
70 SliceImageQuality quality) | |
71 { | |
72 std::auto_ptr<Orthanc::ImageAccessor> tmp(image); | |
73 printf("Slice OK %dx%d\n", tmp->GetWidth(), tmp->GetHeight()); | |
74 } | |
75 | |
76 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader, | |
77 unsigned int sliceIndex, | |
78 const Slice& slice, | |
79 SliceImageQuality quality) | |
80 { | |
81 printf("ERROR 2\n"); | |
82 } | |
83 }; | |
84 } | |
85 | |
86 | |
87 TEST(Toto, DISABLED_Tutu) | |
88 { | |
89 OrthancStone::Oracle oracle(4); | |
90 oracle.Start(); | |
91 | |
92 Orthanc::WebServiceParameters web; | |
93 //OrthancStone::OrthancAsynchronousWebService orthanc(web, 4); | |
94 OrthancStone::OracleWebService orthanc(oracle, web); | |
95 //orthanc.Start(); | |
96 | |
97 OrthancStone::Tata tata; | |
98 OrthancStone::OrthancSlicesLoader loader(tata, orthanc); | |
99 loader.ScheduleLoadSeries("c1c4cb95-05e3bd11-8da9f5bb-87278f71-0b2b43f5"); | |
100 //loader.ScheduleLoadSeries("67f1b334-02c16752-45026e40-a5b60b6b-030ecab5"); | |
101 | |
102 //loader.ScheduleLoadInstance("19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5", 0); | |
103 | |
104 /*printf(">> %d\n", loader.GetSliceCount()); | |
105 loader.ScheduleLoadSliceImage(31);*/ | |
106 | |
107 boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); | |
108 | |
109 //orthanc.Stop(); | |
110 oracle.Stop(); | |
111 } | |
112 | |
113 | |
114 TEST(Toto, Tata) | |
115 { | |
116 OrthancStone::Oracle oracle(4); | |
117 oracle.Start(); | |
118 | |
119 Orthanc::WebServiceParameters web; | |
120 OrthancStone::OracleWebService orthanc(oracle, web); | |
121 OrthancStone::OrthancVolumeImage volume(orthanc, true); | |
122 | |
123 //volume.ScheduleLoadInstance("19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5", 0); | |
124 //volume.ScheduleLoadSeries("318603c5-03e8cffc-a82b6ee1-3ccd3c1e-18d7e3bb"); // COMUNIX PET | |
125 //volume.ScheduleLoadSeries("7124dba7-09803f33-98b73826-33f14632-ea842d29"); // COMUNIX CT | |
126 //volume.ScheduleLoadSeries("5990e39c-51e5f201-fe87a54c-31a55943-e59ef80e"); // Delphine sagital | |
127 volume.ScheduleLoadSeries("6f1b492a-e181e200-44e51840-ef8db55e-af529ab6"); // Delphine ax 2.5 | |
128 | |
129 boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); | |
130 | |
131 oracle.Stop(); | |
132 } | |
133 #endif | |
134 | 43 |
135 | 44 |
136 TEST(GeometryToolbox, Interpolation) | 45 TEST(GeometryToolbox, Interpolation) |
137 { | 46 { |
138 using namespace OrthancStone::GeometryToolbox; | 47 using namespace OrthancStone::GeometryToolbox; |
725 | 634 |
726 TEST(MessagingToolbox, ParseJson) | 635 TEST(MessagingToolbox, ParseJson) |
727 { | 636 { |
728 Json::Value response; | 637 Json::Value response; |
729 std::string source = "{\"command\":\"panel:takeDarkImage\",\"commandType\":\"simple\",\"args\":{}}"; | 638 std::string source = "{\"command\":\"panel:takeDarkImage\",\"commandType\":\"simple\",\"args\":{}}"; |
730 ASSERT_TRUE(OrthancStone::MessagingToolbox::ParseJson(response, source.c_str(), source.size())); | 639 ASSERT_TRUE(Deprecated::MessagingToolbox::ParseJson(response, source.c_str(), source.size())); |
731 } | 640 } |
732 | 641 |
733 TEST(VolumeImageGeometry, Basic) | 642 TEST(VolumeImageGeometry, Basic) |
734 { | 643 { |
735 OrthancStone::VolumeImageGeometry g; | 644 OrthancStone::VolumeImageGeometry g; |
788 for (int p = 0; p < 3; p++) | 697 for (int p = 0; p < 3; p++) |
789 { | 698 { |
790 OrthancStone::VolumeProjection projection = (OrthancStone::VolumeProjection) p; | 699 OrthancStone::VolumeProjection projection = (OrthancStone::VolumeProjection) p; |
791 const OrthancStone::CoordinateSystem3D& s = g.GetProjectionGeometry(projection); | 700 const OrthancStone::CoordinateSystem3D& s = g.GetProjectionGeometry(projection); |
792 | 701 |
702 ASSERT_THROW(g.GetProjectionSlice(projection, g.GetProjectionDepth(projection)), Orthanc::OrthancException); | |
703 | |
793 for (unsigned int i = 0; i < g.GetProjectionDepth(projection); i++) | 704 for (unsigned int i = 0; i < g.GetProjectionDepth(projection); i++) |
794 { | 705 { |
795 OrthancStone::CoordinateSystem3D plane( | 706 OrthancStone::CoordinateSystem3D plane = g.GetProjectionSlice(projection, i); |
796 s.GetOrigin() + static_cast<double>(i) * s.GetNormal() * g.GetVoxelDimensions(projection)[2], | 707 |
797 s.GetAxisX(), | 708 ASSERT_TRUE(IsEqualVector(plane.GetOrigin(), s.GetOrigin() + static_cast<double>(i) * |
798 s.GetAxisY()); | 709 s.GetNormal() * g.GetVoxelDimensions(projection)[2])); |
710 ASSERT_TRUE(IsEqualVector(plane.GetAxisX(), s.GetAxisX())); | |
711 ASSERT_TRUE(IsEqualVector(plane.GetAxisY(), s.GetAxisY())); | |
799 | 712 |
800 unsigned int slice; | 713 unsigned int slice; |
801 OrthancStone::VolumeProjection q; | 714 OrthancStone::VolumeProjection q; |
802 ASSERT_TRUE(g.DetectSlice(q, slice, plane)); | 715 ASSERT_TRUE(g.DetectSlice(q, slice, plane)); |
803 ASSERT_EQ(projection, q); | 716 ASSERT_EQ(projection, q); |
804 ASSERT_EQ(i, slice); | 717 ASSERT_EQ(i, slice); |
805 } | 718 } |
806 } | 719 } |
807 } | 720 } |
808 | 721 |
809 int main(int argc, char **argv) | 722 int main(int argc, char **argv) |