Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/BucketAccumulator2D.h @ 2146:743fa9c74443 dicom-sr tip
integration mainline->dicom-sr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Aug 2024 18:09:53 +0200 |
parents | 16c01cc201e7 |
children |
rev | line source |
---|---|
1891 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
2124
16c01cc201e7
updated copyright, as Osimis is not active on Orthanc anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2114
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1891 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "Internals/BucketMapper.h" | |
27 | |
28 #include <list> | |
1892
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
29 #include <stdio.h> |
1891 | 30 #include <vector> |
31 | |
32 | |
33 namespace OrthancStone | |
34 { | |
35 class BucketAccumulator2D : public boost::noncopyable | |
36 { | |
37 private: | |
38 struct Bucket | |
39 { | |
40 size_t count_; | |
41 std::list<double> valuesX_; | |
42 std::list<double> valuesY_; | |
1892
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
43 |
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
44 Bucket() : |
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
45 count_(0) |
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
46 { |
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
47 } |
1891 | 48 }; |
49 | |
50 Internals::BucketMapper mapperX_; | |
51 Internals::BucketMapper mapperY_; | |
52 std::vector<Bucket> buckets_; | |
53 bool storeValues_; | |
54 | |
55 size_t FindBestInternal() const; | |
56 | |
57 size_t EncodeIndex(size_t x, | |
58 size_t y) const; | |
59 | |
60 void DecodeIndex(size_t& x, | |
61 size_t& y, | |
62 size_t index) const; | |
63 | |
64 public: | |
65 BucketAccumulator2D(double minValueX, | |
66 double maxValueX, | |
67 size_t countBucketsX, | |
68 double minValueY, | |
69 double maxValueY, | |
70 size_t countBucketsY, | |
71 bool storeValues); | |
72 | |
73 void GetSize(size_t& x, | |
74 size_t& y) const; | |
75 | |
76 double GetBucketLowX(size_t i) const | |
77 { | |
78 return mapperX_.GetBucketLow(i); | |
79 } | |
80 | |
81 double GetBucketHighX(size_t i) const | |
82 { | |
83 return mapperX_.GetBucketHigh(i); | |
84 } | |
85 | |
86 double GetBucketCenterX(size_t i) const | |
87 { | |
88 return mapperX_.GetBucketCenter(i); | |
89 } | |
90 | |
91 double GetBucketLowY(size_t i) const | |
92 { | |
93 return mapperY_.GetBucketLow(i); | |
94 } | |
95 | |
96 double GetBucketHighY(size_t i) const | |
97 { | |
98 return mapperY_.GetBucketHigh(i); | |
99 } | |
100 | |
101 double GetBucketCenterY(size_t i) const | |
102 { | |
103 return mapperY_.GetBucketCenter(i); | |
104 } | |
105 | |
106 size_t GetBucketContentSize(size_t x, | |
107 size_t y) const; | |
108 | |
109 void GetBucketIndex(size_t& bucketX, | |
110 size_t& bucketY, | |
111 double valueX, | |
112 double valueY) const; | |
113 | |
114 void AddValue(double valueX, | |
115 double valueY); | |
116 | |
117 void FindBestBucket(size_t& bucketX, | |
118 size_t& bucketY) const | |
119 { | |
120 DecodeIndex(bucketX, bucketY, FindBestInternal()); | |
121 } | |
122 | |
123 void ComputeBestCenter(double& x, | |
124 double& y) const; | |
125 | |
126 void ComputeBestMedian(double& x, | |
127 double& y) const; | |
1892
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
128 |
cdf91ad891a5
estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1891
diff
changeset
|
129 void Print(FILE* fp) const; |
1891 | 130 }; |
131 } |