Mercurial > hg > orthanc-stone
annotate UnitTestsSources/ComputationalGeometryTests.cpp @ 1874:08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jan 2022 18:58:37 +0100 |
parents | e0966648ebd0 |
children | b896f20d24ca |
rev | line source |
---|---|
1872 | 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-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero 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 * Affero General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Affero General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #include <gtest/gtest.h> | |
24 | |
1874
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
25 #include "../OrthancStone/Sources/Toolbox/Internals/OrientedIntegerLine2D.h" |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
26 #include "../OrthancStone/Sources/Toolbox/Internals/RectanglesIntegerProjection.h" |
1872 | 27 #include "../OrthancStone/Sources/Toolbox/SegmentTree.h" |
28 | |
29 #include <Logging.h> | |
30 #include <OrthancException.h> | |
31 | |
32 | |
33 namespace | |
34 { | |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
35 typedef Orthanc::SingleValueObject<int> Counter; |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
36 |
1872 | 37 class CounterFactory : public OrthancStone::SegmentTree::IPayloadFactory |
38 { | |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
39 private: |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
40 int value_; |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
41 |
1872 | 42 public: |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
43 CounterFactory(int value) : |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
44 value_(value) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
45 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
46 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
47 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
48 virtual Orthanc::IDynamicObject* Create() ORTHANC_OVERRIDE |
1872 | 49 { |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
50 return new Counter(value_); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
51 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
52 }; |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
53 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
54 class IncrementVisitor : public OrthancStone::SegmentTree::IVisitor |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
55 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
56 private: |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
57 int increment_; |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
58 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
59 public: |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
60 IncrementVisitor(int increment) : |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
61 increment_(increment) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
62 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
63 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
64 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
65 virtual void Visit(const OrthancStone::SegmentTree& node, |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
66 bool fullyInside) ORTHANC_OVERRIDE |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
67 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
68 if (fullyInside) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
69 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
70 Counter& payload = node.GetTypedPayload<Counter>(); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
71 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
72 if (payload.GetValue() + increment_ < 0) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
73 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
74 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
75 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
76 else |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
77 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
78 payload.SetValue(payload.GetValue() + increment_); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
79 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
80 } |
1872 | 81 } |
82 }; | |
83 } | |
84 | |
85 | |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
86 TEST(SegmentTree, Create) |
1872 | 87 { |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
88 CounterFactory factory(42); |
1872 | 89 OrthancStone::SegmentTree root(4u, 15u, factory); // Check out Figure 1.1 (page 14) from textbook |
90 | |
91 ASSERT_EQ(4u, root.GetLowBound()); | |
92 ASSERT_EQ(15u, root.GetHighBound()); | |
93 ASSERT_FALSE(root.IsLeaf()); | |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
94 ASSERT_EQ(42, root.GetTypedPayload<Counter>().GetValue()); |
1872 | 95 ASSERT_EQ(21u, root.CountNodes()); |
96 | |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
97 const OrthancStone::SegmentTree* n = &root.GetLeftChild(); |
1872 | 98 ASSERT_EQ(4u, n->GetLowBound()); |
99 ASSERT_EQ(9u, n->GetHighBound()); | |
100 ASSERT_FALSE(n->IsLeaf()); | |
101 ASSERT_EQ(9u, n->CountNodes()); | |
102 | |
103 n = &root.GetLeftChild().GetLeftChild(); | |
104 ASSERT_EQ(4u, n->GetLowBound()); | |
105 ASSERT_EQ(6u, n->GetHighBound()); | |
106 ASSERT_FALSE(n->IsLeaf()); | |
107 ASSERT_EQ(3u, n->CountNodes()); | |
108 | |
109 n = &root.GetLeftChild().GetLeftChild().GetLeftChild(); | |
110 ASSERT_EQ(4u, n->GetLowBound()); | |
111 ASSERT_EQ(5u, n->GetHighBound()); | |
112 ASSERT_TRUE(n->IsLeaf()); | |
113 ASSERT_THROW(n->GetLeftChild(), Orthanc::OrthancException); | |
114 ASSERT_THROW(n->GetRightChild(), Orthanc::OrthancException); | |
115 ASSERT_EQ(1u, n->CountNodes()); | |
116 | |
117 n = &root.GetLeftChild().GetLeftChild().GetRightChild(); | |
118 ASSERT_EQ(5u, n->GetLowBound()); | |
119 ASSERT_EQ(6u, n->GetHighBound()); | |
120 ASSERT_TRUE(n->IsLeaf()); | |
121 ASSERT_EQ(1u, n->CountNodes()); | |
122 | |
123 n = &root.GetLeftChild().GetRightChild(); | |
124 ASSERT_EQ(6u, n->GetLowBound()); | |
125 ASSERT_EQ(9u, n->GetHighBound()); | |
126 ASSERT_FALSE(n->IsLeaf()); | |
127 ASSERT_EQ(5u, n->CountNodes()); | |
128 | |
129 n = &root.GetLeftChild().GetRightChild().GetLeftChild(); | |
130 ASSERT_EQ(6u, n->GetLowBound()); | |
131 ASSERT_EQ(7u, n->GetHighBound()); | |
132 ASSERT_TRUE(n->IsLeaf()); | |
133 ASSERT_EQ(1u, n->CountNodes()); | |
134 | |
135 n = &root.GetLeftChild().GetRightChild().GetRightChild(); | |
136 ASSERT_EQ(7u, n->GetLowBound()); | |
137 ASSERT_EQ(9u, n->GetHighBound()); | |
138 ASSERT_FALSE(n->IsLeaf()); | |
139 ASSERT_EQ(3u, n->CountNodes()); | |
140 | |
141 n = &root.GetLeftChild().GetRightChild().GetRightChild().GetLeftChild(); | |
142 ASSERT_EQ(7u, n->GetLowBound()); | |
143 ASSERT_EQ(8u, n->GetHighBound()); | |
144 ASSERT_TRUE(n->IsLeaf()); | |
145 ASSERT_EQ(1u, n->CountNodes()); | |
146 | |
147 n = &root.GetLeftChild().GetRightChild().GetRightChild().GetRightChild(); | |
148 ASSERT_EQ(8u, n->GetLowBound()); | |
149 ASSERT_EQ(9u, n->GetHighBound()); | |
150 ASSERT_TRUE(n->IsLeaf()); | |
151 ASSERT_EQ(1u, n->CountNodes()); | |
152 | |
153 n = &root.GetRightChild(); | |
154 ASSERT_EQ(9u, n->GetLowBound()); | |
155 ASSERT_EQ(15u, n->GetHighBound()); | |
156 ASSERT_FALSE(n->IsLeaf()); | |
157 ASSERT_EQ(11u, n->CountNodes()); | |
158 | |
159 n = &root.GetRightChild().GetLeftChild(); | |
160 ASSERT_EQ(9u, n->GetLowBound()); | |
161 ASSERT_EQ(12u, n->GetHighBound()); | |
162 ASSERT_FALSE(n->IsLeaf()); | |
163 ASSERT_EQ(5u, n->CountNodes()); | |
164 | |
165 n = &root.GetRightChild().GetLeftChild().GetLeftChild(); | |
166 ASSERT_EQ(9u, n->GetLowBound()); | |
167 ASSERT_EQ(10u, n->GetHighBound()); | |
168 ASSERT_TRUE(n->IsLeaf()); | |
169 ASSERT_EQ(1u, n->CountNodes()); | |
170 | |
171 n = &root.GetRightChild().GetLeftChild().GetRightChild(); | |
172 ASSERT_EQ(10u, n->GetLowBound()); | |
173 ASSERT_EQ(12u, n->GetHighBound()); | |
174 ASSERT_FALSE(n->IsLeaf()); | |
175 ASSERT_EQ(3u, n->CountNodes()); | |
176 | |
177 n = &root.GetRightChild().GetLeftChild().GetRightChild().GetLeftChild(); | |
178 ASSERT_EQ(10u, n->GetLowBound()); | |
179 ASSERT_EQ(11u, n->GetHighBound()); | |
180 ASSERT_TRUE(n->IsLeaf()); | |
181 ASSERT_EQ(1u, n->CountNodes()); | |
182 | |
183 n = &root.GetRightChild().GetLeftChild().GetRightChild().GetRightChild(); | |
184 ASSERT_EQ(11u, n->GetLowBound()); | |
185 ASSERT_EQ(12u, n->GetHighBound()); | |
186 ASSERT_TRUE(n->IsLeaf()); | |
187 ASSERT_EQ(1u, n->CountNodes()); | |
188 | |
189 n = &root.GetRightChild().GetRightChild(); | |
190 ASSERT_EQ(12u, n->GetLowBound()); | |
191 ASSERT_EQ(15u, n->GetHighBound()); | |
192 ASSERT_FALSE(n->IsLeaf()); | |
193 ASSERT_EQ(5u, n->CountNodes()); | |
194 | |
195 n = &root.GetRightChild().GetRightChild().GetLeftChild(); | |
196 ASSERT_EQ(12u, n->GetLowBound()); | |
197 ASSERT_EQ(13u, n->GetHighBound()); | |
198 ASSERT_TRUE(n->IsLeaf()); | |
199 ASSERT_EQ(1u, n->CountNodes()); | |
200 | |
201 n = &root.GetRightChild().GetRightChild().GetRightChild(); | |
202 ASSERT_EQ(13u, n->GetLowBound()); | |
203 ASSERT_EQ(15u, n->GetHighBound()); | |
204 ASSERT_FALSE(n->IsLeaf()); | |
205 ASSERT_EQ(3u, n->CountNodes()); | |
206 | |
207 n = &root.GetRightChild().GetRightChild().GetRightChild().GetLeftChild(); | |
208 ASSERT_EQ(13u, n->GetLowBound()); | |
209 ASSERT_EQ(14u, n->GetHighBound()); | |
210 ASSERT_TRUE(n->IsLeaf()); | |
211 ASSERT_EQ(1u, n->CountNodes()); | |
212 | |
213 n = &root.GetRightChild().GetRightChild().GetRightChild().GetRightChild(); | |
214 ASSERT_EQ(14u, n->GetLowBound()); | |
215 ASSERT_EQ(15u, n->GetHighBound()); | |
216 ASSERT_TRUE(n->IsLeaf()); | |
217 ASSERT_EQ(1u, n->CountNodes()); | |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
218 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
219 ASSERT_TRUE(root.FindLeaf(3) == NULL); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
220 for (size_t i = 4; i < 15; i++) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
221 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
222 n = root.FindLeaf(i); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
223 ASSERT_TRUE(n != NULL); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
224 ASSERT_TRUE(n->IsLeaf()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
225 ASSERT_EQ(i, n->GetLowBound()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
226 ASSERT_EQ(i + 1, n->GetHighBound()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
227 ASSERT_EQ(42, n->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
228 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
229 ASSERT_TRUE(root.FindLeaf(15) == NULL); |
1872 | 230 } |
1873
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
231 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
232 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
233 static bool CheckCounter(const OrthancStone::SegmentTree& node, |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
234 int expectedValue) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
235 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
236 if (node.GetTypedPayload<Counter>().GetValue() != expectedValue) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
237 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
238 return false; |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
239 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
240 else if (node.IsLeaf()) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
241 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
242 return true; |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
243 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
244 else |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
245 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
246 return (CheckCounter(node.GetLeftChild(), expectedValue) && |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
247 CheckCounter(node.GetRightChild(), expectedValue)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
248 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
249 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
250 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
251 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
252 #if 0 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
253 static void Print(const OrthancStone::SegmentTree& node, |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
254 unsigned int indent) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
255 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
256 for (size_t i = 0; i < indent; i++) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
257 printf(" "); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
258 printf("(%lu,%lu): %d\n", node.GetLowBound(), node.GetHighBound(), node.GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
259 if (!node.IsLeaf()) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
260 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
261 Print(node.GetLeftChild(), indent + 1); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
262 Print(node.GetRightChild(), indent + 1); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
263 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
264 } |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
265 #endif |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
266 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
267 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
268 TEST(SegmentTree, Visit) |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
269 { |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
270 CounterFactory factory(0); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
271 OrthancStone::SegmentTree root(4u, 15u, factory); // Check out Figure 1.1 (page 14) from textbook |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
272 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
273 ASSERT_TRUE(CheckCounter(root, 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
274 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
275 IncrementVisitor plus(1); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
276 IncrementVisitor minus(-1); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
277 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
278 root.VisitSegment(0, 20, plus); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
279 ASSERT_EQ(1, root.GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
280 ASSERT_TRUE(CheckCounter(root.GetLeftChild(), 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
281 ASSERT_TRUE(CheckCounter(root.GetRightChild(), 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
282 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
283 root.VisitSegment(0, 20, plus); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
284 ASSERT_EQ(2, root.GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
285 ASSERT_TRUE(CheckCounter(root.GetLeftChild(), 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
286 ASSERT_TRUE(CheckCounter(root.GetRightChild(), 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
287 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
288 root.VisitSegment(0, 20, minus); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
289 root.VisitSegment(0, 20, minus); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
290 ASSERT_TRUE(CheckCounter(root, 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
291 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
292 root.VisitSegment(8, 11, plus); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
293 ASSERT_EQ(0, root.FindNode(4, 15)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
294 ASSERT_EQ(0, root.FindNode(4, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
295 ASSERT_EQ(0, root.FindNode(4, 6)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
296 ASSERT_EQ(0, root.FindNode(4, 5)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
297 ASSERT_EQ(0, root.FindNode(5, 6)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
298 ASSERT_EQ(0, root.FindNode(6, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
299 ASSERT_EQ(0, root.FindNode(6, 7)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
300 ASSERT_EQ(0, root.FindNode(7, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
301 ASSERT_EQ(0, root.FindNode(7, 8)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
302 ASSERT_EQ(1, root.FindNode(8, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
303 ASSERT_EQ(0, root.FindNode(9, 15)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
304 ASSERT_EQ(0, root.FindNode(9, 12)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
305 ASSERT_EQ(1, root.FindNode(9, 10)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
306 ASSERT_EQ(0, root.FindNode(10, 12)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
307 ASSERT_EQ(1, root.FindNode(10, 11)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
308 ASSERT_EQ(0, root.FindNode(11, 12)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
309 ASSERT_EQ(0, root.FindNode(12, 15)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
310 ASSERT_EQ(0, root.FindNode(12, 13)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
311 ASSERT_EQ(0, root.FindNode(13, 15)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
312 ASSERT_EQ(0, root.FindNode(13, 14)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
313 ASSERT_EQ(0, root.FindNode(14, 15)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
314 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
315 root.VisitSegment(9, 11, minus); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
316 ASSERT_EQ(0, root.FindNode(4, 15)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
317 ASSERT_EQ(0, root.FindNode(4, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
318 ASSERT_EQ(0, root.FindNode(4, 6)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
319 ASSERT_EQ(0, root.FindNode(4, 5)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
320 ASSERT_EQ(0, root.FindNode(5, 6)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
321 ASSERT_EQ(0, root.FindNode(6, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
322 ASSERT_EQ(0, root.FindNode(6, 7)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
323 ASSERT_EQ(0, root.FindNode(7, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
324 ASSERT_EQ(0, root.FindNode(7, 8)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
325 ASSERT_EQ(1, root.FindNode(8, 9)->GetTypedPayload<Counter>().GetValue()); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
326 ASSERT_TRUE(CheckCounter(root.GetRightChild(), 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
327 |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
328 root.VisitSegment(8, 9, minus); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
329 ASSERT_TRUE(CheckCounter(root, 0)); |
e0966648ebd0
unit tests of SegmentTree
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1872
diff
changeset
|
330 } |
1874
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
331 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
332 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
333 TEST(UnionOfRectangles, RectanglesIntegerProjection) |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
334 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
335 std::list<OrthancStone::Extent2D> rectangles; |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
336 rectangles.push_back(OrthancStone::Extent2D(10, 20, 30, 40)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
337 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
338 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
339 OrthancStone::Internals::RectanglesIntegerProjection h(rectangles, true); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
340 ASSERT_EQ(2u, h.GetEndpointsCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
341 ASSERT_EQ(10, h.GetEndpointCoordinate(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
342 ASSERT_EQ(30, h.GetEndpointCoordinate(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
343 ASSERT_EQ(1u, h.GetProjectedRectanglesCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
344 ASSERT_EQ(0u, h.GetProjectedRectangleLow(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
345 ASSERT_EQ(1u, h.GetProjectedRectangleHigh(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
346 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
347 ASSERT_THROW(h.GetEndpointCoordinate(2), Orthanc::OrthancException); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
348 ASSERT_THROW(h.GetProjectedRectangleLow(1), Orthanc::OrthancException); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
349 ASSERT_THROW(h.GetProjectedRectangleHigh(1), Orthanc::OrthancException); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
350 } |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
351 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
352 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
353 OrthancStone::Internals::RectanglesIntegerProjection h(rectangles, false); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
354 ASSERT_EQ(2u, h.GetEndpointsCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
355 ASSERT_EQ(20, h.GetEndpointCoordinate(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
356 ASSERT_EQ(40, h.GetEndpointCoordinate(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
357 ASSERT_EQ(1u, h.GetProjectedRectanglesCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
358 ASSERT_EQ(0u, h.GetProjectedRectangleLow(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
359 ASSERT_EQ(1u, h.GetProjectedRectangleHigh(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
360 } |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
361 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
362 rectangles.push_back(OrthancStone::Extent2D(20, 30, 40, 50)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
363 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
364 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
365 OrthancStone::Internals::RectanglesIntegerProjection h(rectangles, true); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
366 ASSERT_EQ(4u, h.GetEndpointsCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
367 ASSERT_EQ(10, h.GetEndpointCoordinate(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
368 ASSERT_EQ(20, h.GetEndpointCoordinate(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
369 ASSERT_EQ(30, h.GetEndpointCoordinate(2)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
370 ASSERT_EQ(40, h.GetEndpointCoordinate(3)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
371 ASSERT_EQ(2u, h.GetProjectedRectanglesCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
372 ASSERT_EQ(0u, h.GetProjectedRectangleLow(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
373 ASSERT_EQ(2u, h.GetProjectedRectangleHigh(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
374 ASSERT_EQ(1u, h.GetProjectedRectangleLow(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
375 ASSERT_EQ(3u, h.GetProjectedRectangleHigh(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
376 } |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
377 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
378 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
379 OrthancStone::Internals::RectanglesIntegerProjection h(rectangles, false); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
380 ASSERT_EQ(4u, h.GetEndpointsCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
381 ASSERT_EQ(20, h.GetEndpointCoordinate(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
382 ASSERT_EQ(30, h.GetEndpointCoordinate(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
383 ASSERT_EQ(40, h.GetEndpointCoordinate(2)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
384 ASSERT_EQ(50, h.GetEndpointCoordinate(3)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
385 ASSERT_EQ(2u, h.GetProjectedRectanglesCount()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
386 ASSERT_EQ(0u, h.GetProjectedRectangleLow(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
387 ASSERT_EQ(2u, h.GetProjectedRectangleHigh(0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
388 ASSERT_EQ(1u, h.GetProjectedRectangleLow(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
389 ASSERT_EQ(3u, h.GetProjectedRectangleHigh(1)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
390 } |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
391 } |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
392 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
393 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
394 static void Convert(std::vector<size_t>& horizontal, |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
395 std::vector<size_t>& vertical, |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
396 const OrthancStone::Internals::OrientedIntegerLine2D::Chain& chain) |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
397 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
398 horizontal.clear(); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
399 vertical.clear(); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
400 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
401 for (OrthancStone::Internals::OrientedIntegerLine2D::Chain::const_iterator |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
402 it = chain.begin(); it != chain.end(); ++it) |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
403 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
404 horizontal.push_back(it->first); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
405 vertical.push_back(it->second); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
406 } |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
407 } |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
408 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
409 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
410 TEST(UnionOfRectangles, ExtractChains) |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
411 { |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
412 std::vector<OrthancStone::Internals::OrientedIntegerLine2D> edges; |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
413 edges.push_back(OrthancStone::Internals::OrientedIntegerLine2D(0, 0, 10, 0)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
414 edges.push_back(OrthancStone::Internals::OrientedIntegerLine2D(10, 0, 10, 20)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
415 edges.push_back(OrthancStone::Internals::OrientedIntegerLine2D(10, 20, 0, 20)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
416 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
417 std::list<OrthancStone::Internals::OrientedIntegerLine2D::Chain> chains; |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
418 OrthancStone::Internals::OrientedIntegerLine2D::ExtractChains(chains, edges); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
419 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
420 std::vector<size_t> h, v; |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
421 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
422 ASSERT_EQ(1u, chains.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
423 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
424 Convert(h, v, chains.front()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
425 ASSERT_EQ(4u, h.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
426 ASSERT_EQ(0u, h[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
427 ASSERT_EQ(10u, h[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
428 ASSERT_EQ(10u, h[2]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
429 ASSERT_EQ(0u, h[3]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
430 ASSERT_EQ(4u, v.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
431 ASSERT_EQ(0u, v[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
432 ASSERT_EQ(0u, v[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
433 ASSERT_EQ(20u, v[2]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
434 ASSERT_EQ(20u, v[3]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
435 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
436 edges.push_back(OrthancStone::Internals::OrientedIntegerLine2D(5, 5, 10, 5)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
437 OrthancStone::Internals::OrientedIntegerLine2D::ExtractChains(chains, edges); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
438 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
439 ASSERT_EQ(2u, chains.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
440 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
441 Convert(h, v, chains.front()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
442 ASSERT_EQ(4u, h.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
443 ASSERT_EQ(0u, h[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
444 ASSERT_EQ(10u, h[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
445 ASSERT_EQ(10u, h[2]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
446 ASSERT_EQ(0u, h[3]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
447 ASSERT_EQ(4u, v.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
448 ASSERT_EQ(0u, v[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
449 ASSERT_EQ(0u, v[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
450 ASSERT_EQ(20u, v[2]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
451 ASSERT_EQ(20u, v[3]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
452 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
453 Convert(h, v, chains.back()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
454 ASSERT_EQ(2u, h.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
455 ASSERT_EQ(5u, h[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
456 ASSERT_EQ(10u, h[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
457 ASSERT_EQ(2u, v.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
458 ASSERT_EQ(5u, v[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
459 ASSERT_EQ(5u, v[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
460 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
461 edges.push_back(OrthancStone::Internals::OrientedIntegerLine2D(0, 20, 5, 5)); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
462 OrthancStone::Internals::OrientedIntegerLine2D::ExtractChains(chains, edges); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
463 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
464 ASSERT_EQ(1u, chains.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
465 |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
466 Convert(h, v, chains.front()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
467 ASSERT_EQ(6u, h.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
468 ASSERT_EQ(0u, h[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
469 ASSERT_EQ(10u, h[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
470 ASSERT_EQ(10u, h[2]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
471 ASSERT_EQ(0u, h[3]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
472 ASSERT_EQ(5u, h[4]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
473 ASSERT_EQ(10u, h[5]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
474 ASSERT_EQ(6u, v.size()); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
475 ASSERT_EQ(0u, v[0]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
476 ASSERT_EQ(0u, v[1]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
477 ASSERT_EQ(20u, v[2]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
478 ASSERT_EQ(20u, v[3]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
479 ASSERT_EQ(5u, v[4]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
480 ASSERT_EQ(5u, v[5]); |
08f2476e8f5e
added classes OrientedIntegerLine2D and RectanglesIntegerProjection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1873
diff
changeset
|
481 } |