Mercurial > hg > orthanc-stl
comparison Sources/Plugin.cpp @ 38:970994058acd
building O3DV
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Apr 2024 08:19:54 +0200 |
parents | 13698d34e059 |
children | 8a1daa321afe |
comparison
equal
deleted
inserted
replaced
37:2cc9950018ab | 38:970994058acd |
---|---|
56 void ReadStaticAsset(std::string& target, | 56 void ReadStaticAsset(std::string& target, |
57 const std::string& path); | 57 const std::string& path); |
58 | 58 |
59 | 59 |
60 /** | 60 /** |
61 * As the Three.js static assets are gzipped by the | 61 * As the static assets are gzipped by the "EmbedStaticAssets.py" |
62 * "EmbedStaticAssets.py" script, we use a cache to maintain the | 62 * script, we use a cache to maintain the uncompressed assets in order |
63 * uncompressed assets in order to avoid multiple gzip decodings. | 63 * to avoid multiple gzip decodings. |
64 **/ | 64 **/ |
65 class ResourcesCache : public boost::noncopyable | 65 class ResourcesCache : public boost::noncopyable |
66 { | 66 { |
67 private: | 67 private: |
68 typedef std::map<std::string, std::string*> Content; | 68 typedef std::map<std::string, std::string*> Content; |
131 return; | 131 return; |
132 } | 132 } |
133 | 133 |
134 std::string file = request->groups[0]; | 134 std::string file = request->groups[0]; |
135 | 135 |
136 if (file == "three.html") | 136 if (boost::starts_with(file, "libs/")) |
137 { | 137 { |
138 cache_.Answer(output, file.substr(5)); | |
139 } | |
140 else | |
141 { | |
142 Orthanc::EmbeddedResources::FileResourceId resourceId; | |
143 Orthanc::MimeType mimeType; | |
144 | |
145 if (file == "three.html") | |
146 { | |
147 resourceId = Orthanc::EmbeddedResources::THREE_HTML; | |
148 mimeType = Orthanc::MimeType_Html; | |
149 } | |
150 else if (file == "three.js") | |
151 { | |
152 resourceId = Orthanc::EmbeddedResources::THREE_JS; | |
153 mimeType = Orthanc::MimeType_JavaScript; | |
154 } | |
155 else if (file == "o3dv.html") | |
156 { | |
157 resourceId = Orthanc::EmbeddedResources::O3DV_HTML; | |
158 mimeType = Orthanc::MimeType_Html; | |
159 } | |
160 else if (file == "o3dv.js") | |
161 { | |
162 resourceId = Orthanc::EmbeddedResources::O3DV_JS; | |
163 mimeType = Orthanc::MimeType_JavaScript; | |
164 } | |
165 else | |
166 { | |
167 OrthancPluginSendHttpStatusCode(OrthancPlugins::GetGlobalContext(), output, 404); | |
168 return; | |
169 } | |
170 | |
138 std::string s; | 171 std::string s; |
139 Orthanc::EmbeddedResources::GetFileResource(s, Orthanc::EmbeddedResources::THREE_HTML); | 172 Orthanc::EmbeddedResources::GetFileResource(s, resourceId); |
140 OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, s.c_str(), s.size(), Orthanc::EnumerationToString(Orthanc::MimeType_Html)); | 173 OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, s.c_str(), s.size(), Orthanc::EnumerationToString(mimeType)); |
141 } | |
142 else if (file == "three.js") | |
143 { | |
144 std::string s; | |
145 Orthanc::EmbeddedResources::GetFileResource(s, Orthanc::EmbeddedResources::THREE_JS); | |
146 OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, s.c_str(), s.size(), Orthanc::EnumerationToString(Orthanc::MimeType_JavaScript)); | |
147 } | |
148 else if (boost::starts_with(file, "libs/")) | |
149 { | |
150 cache_.Answer(output, file.substr(5)); | |
151 } | 174 } |
152 } | 175 } |
153 | 176 |
154 | 177 |
155 | 178 |