annotate OrthancStone/Sources/Toolbox/SlicesSorter.h @ 1665:f62f685e0eb2

avoid loading instance metadata on RTSTRUCT to avoid JSON parsing that freezes the browser
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 19 Nov 2020 15:39:30 +0100
parents 5cc589bfb385
children 9ac2a65d4172
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1015
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * <http://www.gnu.org/licenses/>.
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
25 #include "CoordinateSystem3D.h"
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
26
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1279
diff changeset
27 #include <IDynamicObject.h>
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
1642
5cc589bfb385 lazy computation of DicomInstanceParameters::GetImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
31 // TODO - Replace this with "SortedFrames"
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class SlicesSorter : public boost::noncopyable
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 private:
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class SliceWithDepth;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 struct Comparator;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 typedef std::vector<SliceWithDepth*> Slices;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 Slices slices_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 bool hasNormal_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
43 const SliceWithDepth& GetSlice(size_t i) const;
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
44
648
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
45 void SetNormal(const Vector& normal);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
46
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
47 void SortInternal();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
48
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
49 void FilterNormal(const Vector& normal);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
50
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
51 bool SelectNormal(Vector& normal) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
52
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 public:
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 SlicesSorter() : hasNormal_(false)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 ~SlicesSorter();
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 void Reserve(size_t count)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 slices_.reserve(count);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
65 void AddSlice(const CoordinateSystem3D& plane)
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
66 {
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
67 AddSlice(plane, NULL);
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
68 }
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
70 void AddSlice(const CoordinateSystem3D& plane,
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
71 Orthanc::IDynamicObject* payload); // Takes ownership
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
72
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
73 size_t GetSlicesCount() const
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 return slices_.size();
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
78 const CoordinateSystem3D& GetSliceGeometry(size_t i) const;
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
80 bool HasSlicePayload(size_t i) const;
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
81
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
82 const Orthanc::IDynamicObject& GetSlicePayload(size_t i) const;
648
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
83
661
970949ff868a fix warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 648
diff changeset
84 // WARNING - Apply the sorting algorithm can reduce the number of
970949ff868a fix warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 648
diff changeset
85 // slices. This is notably the case if all the slices are not
970949ff868a fix warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 648
diff changeset
86 // parallel to the reference normal that will be selected.
648
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
87 bool Sort();
683
dbc1d8bfc68a reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 667
diff changeset
88
dbc1d8bfc68a reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 667
diff changeset
89 // TODO - Remove this
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
90 bool LookupClosestSlice(size_t& index,
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
91 double& distance,
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
92 const CoordinateSystem3D& slice) const;
667
e9339f2b5de7 refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 661
diff changeset
93
e9339f2b5de7 refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 661
diff changeset
94 // WARNING - The slices must have been sorted before calling this method
1156
34ee7204fde3 removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1015
diff changeset
95 bool ComputeSpacingBetweenSlices(double& spacing /* out */) const;
1015
24fecc02bfb1 SlicesSorter::AreAllSlicesDistinct()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
96
24fecc02bfb1 SlicesSorter::AreAllSlicesDistinct()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
97 // WARNING - The slices must have been sorted before calling this method
24fecc02bfb1 SlicesSorter::AreAllSlicesDistinct()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
98 bool AreAllSlicesDistinct() const;
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 };
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 }