Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/SlicesSorter.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Toolbox/SlicesSorter.h@30deba7bc8e2 |
children | 4fb8fdf03314 |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
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/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "CoordinateSystem3D.h" | |
25 | |
26 #include <IDynamicObject.h> | |
27 | |
28 namespace OrthancStone | |
29 { | |
30 // TODO - Rename this as "PlanesSorter" | |
31 class SlicesSorter : public boost::noncopyable | |
32 { | |
33 private: | |
34 class SliceWithDepth; | |
35 struct Comparator; | |
36 | |
37 typedef std::vector<SliceWithDepth*> Slices; | |
38 | |
39 Slices slices_; | |
40 bool hasNormal_; | |
41 | |
42 const SliceWithDepth& GetSlice(size_t i) const; | |
43 | |
44 void SetNormal(const Vector& normal); | |
45 | |
46 void SortInternal(); | |
47 | |
48 void FilterNormal(const Vector& normal); | |
49 | |
50 bool SelectNormal(Vector& normal) const; | |
51 | |
52 public: | |
53 SlicesSorter() : hasNormal_(false) | |
54 { | |
55 } | |
56 | |
57 ~SlicesSorter(); | |
58 | |
59 void Reserve(size_t count) | |
60 { | |
61 slices_.reserve(count); | |
62 } | |
63 | |
64 void AddSlice(const CoordinateSystem3D& plane) | |
65 { | |
66 AddSlice(plane, NULL); | |
67 } | |
68 | |
69 void AddSlice(const CoordinateSystem3D& plane, | |
70 Orthanc::IDynamicObject* payload); // Takes ownership | |
71 | |
72 size_t GetSlicesCount() const | |
73 { | |
74 return slices_.size(); | |
75 } | |
76 | |
77 const CoordinateSystem3D& GetSliceGeometry(size_t i) const; | |
78 | |
79 bool HasSlicePayload(size_t i) const; | |
80 | |
81 const Orthanc::IDynamicObject& GetSlicePayload(size_t i) const; | |
82 | |
83 // WARNING - Apply the sorting algorithm can reduce the number of | |
84 // slices. This is notably the case if all the slices are not | |
85 // parallel to the reference normal that will be selected. | |
86 bool Sort(); | |
87 | |
88 // TODO - Remove this | |
89 bool LookupClosestSlice(size_t& index, | |
90 double& distance, | |
91 const CoordinateSystem3D& slice) const; | |
92 | |
93 // WARNING - The slices must have been sorted before calling this method | |
94 bool ComputeSpacingBetweenSlices(double& spacing /* out */) const; | |
95 | |
96 // WARNING - The slices must have been sorted before calling this method | |
97 bool AreAllSlicesDistinct() const; | |
98 }; | |
99 } |