Mercurial > hg > orthanc-stl
comparison Sources/Plugin.cpp @ 40:8a1daa321afe
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Apr 2024 17:50:06 +0200 |
parents | 970994058acd |
children | 967f947014ac 5117515503bf |
comparison
equal
deleted
inserted
replaced
39:b6910092bcca | 40:8a1daa321afe |
---|---|
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 **/ | 22 **/ |
23 | 23 |
24 | 24 |
25 #include "StructureSetGeometry.h" | 25 #include "StructureSetGeometry.h" |
26 #include "StructureSet.h" | |
27 #include "STLToolbox.h" | 26 #include "STLToolbox.h" |
28 #include "StructurePolygon.h" | |
29 #include "VTKToolbox.h" | 27 #include "VTKToolbox.h" |
30 #include "Vector3D.h" | 28 |
31 #include "Toolbox.h" | 29 #include <EmbeddedResources.h> |
32 #include "Extent2D.h" | |
33 | 30 |
34 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" | 31 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
35 | 32 |
36 #include <EmbeddedResources.h> | |
37 | |
38 #include <DicomFormat/DicomInstanceHasher.h> | |
39 #include <DicomParsing/FromDcmtkBridge.h> | 33 #include <DicomParsing/FromDcmtkBridge.h> |
40 #include <DicomParsing/ParsedDicomFile.h> | |
41 #include <Images/ImageProcessing.h> | 34 #include <Images/ImageProcessing.h> |
42 #include <Logging.h> | 35 #include <Logging.h> |
43 #include <OrthancFramework.h> | |
44 #include <SerializationToolbox.h> | 36 #include <SerializationToolbox.h> |
45 #include <SystemToolbox.h> | 37 #include <SystemToolbox.h> |
46 | 38 |
47 #include <vtkNew.h> | 39 #include <vtkNew.h> |
48 | 40 |
180 #include <dcmtk/dcmdata/dcfilefo.h> | 172 #include <dcmtk/dcmdata/dcfilefo.h> |
181 #include <dcmtk/dcmdata/dcsequen.h> | 173 #include <dcmtk/dcmdata/dcsequen.h> |
182 #include <dcmtk/dcmdata/dcuid.h> | 174 #include <dcmtk/dcmdata/dcuid.h> |
183 | 175 |
184 | 176 |
185 class XorFiller : public Orthanc::ImageProcessing::IPolygonFiller | 177 namespace |
186 { | 178 { |
187 private: | 179 class XorFiller : public Orthanc::ImageProcessing::IPolygonFiller |
188 Orthanc::ImageAccessor& target_; | 180 { |
189 | 181 private: |
190 public: | 182 Orthanc::ImageAccessor& target_; |
191 XorFiller(Orthanc::ImageAccessor& target) : | 183 |
192 target_(target) | 184 public: |
193 { | 185 explicit XorFiller(Orthanc::ImageAccessor& target) : |
194 } | 186 target_(target) |
195 | 187 { |
196 virtual void Fill(int y, | 188 } |
197 int x1, | 189 |
198 int x2) ORTHANC_OVERRIDE | 190 virtual void Fill(int y, |
199 { | 191 int x1, |
200 assert(x1 <= x2); | 192 int x2) ORTHANC_OVERRIDE |
201 | 193 { |
202 if (y >= 0 && | 194 assert(x1 <= x2); |
203 y < static_cast<int>(target_.GetHeight())) | 195 |
204 { | 196 if (y >= 0 && |
205 x1 = std::max(x1, 0); | 197 y < static_cast<int>(target_.GetHeight())) |
206 x2 = std::min(x2, static_cast<int>(target_.GetWidth()) - 1); | |
207 | |
208 uint8_t* p = reinterpret_cast<uint8_t*>(target_.GetRow(y)) + x1; | |
209 | |
210 for (int i = x1; i <= x2; i++, p++) | |
211 { | 198 { |
212 *p = (*p ^ 0xff); | 199 x1 = std::max(x1, 0); |
200 x2 = std::min(x2, static_cast<int>(target_.GetWidth()) - 1); | |
201 | |
202 uint8_t* p = reinterpret_cast<uint8_t*>(target_.GetRow(y)) + x1; | |
203 | |
204 for (int i = x1; i <= x2; i++, p++) | |
205 { | |
206 *p = (*p ^ 0xff); | |
207 } | |
213 } | 208 } |
214 } | 209 } |
215 } | 210 }; |
216 }; | 211 } |
217 | 212 |
218 | 213 |
219 static Orthanc::ParsedDicomFile* LoadInstance(const std::string& instanceId) | 214 static Orthanc::ParsedDicomFile* LoadInstance(const std::string& instanceId) |
220 { | 215 { |
221 std::string dicom; | 216 std::string dicom; |
763 { | 758 { |
764 Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); | 759 Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); |
765 | 760 |
766 std::map<std::string, std::string> dictionary; | 761 std::map<std::string, std::string> dictionary; |
767 dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl_ ? "true" : "false"); | 762 dictionary["HAS_CREATE_DICOM_STL"] = (hasCreateDicomStl_ ? "true" : "false"); |
768 dictionary["SHOW_NIFTI_BUTTON"] = (configuration.GetBooleanValue("NIfTI", false) ? "true" : "false"); | 763 dictionary["SHOW_NIFTI_BUTTON"] = (configuration.GetBooleanValue("EnableNIfTI", false) ? "true" : "false"); |
769 explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); | 764 explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); |
770 | 765 |
771 OrthancPlugins::ExtendOrthancExplorer(ORTHANC_PLUGIN_NAME, explorer); | 766 OrthancPlugins::ExtendOrthancExplorer(ORTHANC_PLUGIN_NAME, explorer); |
772 } | 767 } |
773 | 768 |