annotate OrthancStone/Sources/Toolbox/SlicesSorter.h @ 1961:cbf54cd28d59

added CoordinateSystem3D::GetOrientationMarkers()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Oct 2022 18:43:20 +0200
parents 7053b8a0aaec
children 07964689cb0b
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
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * modify it under the terms of the GNU Lesser General Public License
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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
15 * 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
16 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
17 *
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
18 * 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
19 * 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
20 * <http://www.gnu.org/licenses/>.
73
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
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
26 #include "CoordinateSystem3D.h"
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
27
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1279
diff changeset
28 #include <IDynamicObject.h>
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace OrthancStone
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
1642
5cc589bfb385 lazy computation of DicomInstanceParameters::GetImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
32 // TODO - Replace this with "SortedFrames"
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 class SlicesSorter : public boost::noncopyable
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 private:
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 class SliceWithDepth;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 struct Comparator;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 typedef std::vector<SliceWithDepth*> Slices;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 Slices slices_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 bool hasNormal_;
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
44 const SliceWithDepth& GetSlice(size_t i) const;
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
45
648
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
46 void SetNormal(const Vector& normal);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
47
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
48 void SortInternal();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
49
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
50 void FilterNormal(const Vector& normal);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
51
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
52 bool SelectNormal(Vector& normal) const;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
53
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 public:
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 SlicesSorter() : hasNormal_(false)
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
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 ~SlicesSorter();
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 void Reserve(size_t count)
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 slices_.reserve(count);
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
66 void AddSlice(const CoordinateSystem3D& plane)
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
67 {
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
68 AddSlice(plane, NULL);
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
69 }
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
71 void AddSlice(const CoordinateSystem3D& plane,
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
72 Orthanc::IDynamicObject* payload); // Takes ownership
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
73
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
74 size_t GetSlicesCount() const
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 return slices_.size();
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
79 const CoordinateSystem3D& GetSliceGeometry(size_t i) const;
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
81 bool HasSlicePayload(size_t i) const;
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
82
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
83 const Orthanc::IDynamicObject& GetSlicePayload(size_t i) const;
648
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
84
661
970949ff868a fix warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 648
diff changeset
85 // WARNING - Apply the sorting algorithm can reduce the number of
970949ff868a fix warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 648
diff changeset
86 // 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
87 // parallel to the reference normal that will be selected.
648
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
88 bool Sort();
683
dbc1d8bfc68a reorganizing ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 667
diff changeset
89
667
e9339f2b5de7 refactoring of VolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 661
diff changeset
90 // 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
91 bool ComputeSpacingBetweenSlices(double& spacing /* out */) const;
1015
24fecc02bfb1 SlicesSorter::AreAllSlicesDistinct()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
92
24fecc02bfb1 SlicesSorter::AreAllSlicesDistinct()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
93 // WARNING - The slices must have been sorted before calling this method
24fecc02bfb1 SlicesSorter::AreAllSlicesDistinct()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 683
diff changeset
94 bool AreAllSlicesDistinct() const;
73
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 };
ffa6dded91bd reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }