Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkArbitraryTimeGeometryTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 #include "mitkGeometry3D.h"
15 
16 #include "mitkTestFixture.h"
17 #include "mitkTestingMacros.h"
18 #include <limits>
19 
20 class mitkArbitraryTimeGeometryTestSuite : public mitk::TestFixture
21 {
22  CPPUNIT_TEST_SUITE(mitkArbitraryTimeGeometryTestSuite);
23  // Test the append method
24  MITK_TEST(CountTimeSteps);
25  MITK_TEST(GetMinimumTimePoint);
26  MITK_TEST(GetMaximumTimePoint);
27  MITK_TEST(GetTimeBounds);
28  MITK_TEST(IsValidTimePoint);
29  MITK_TEST(TimeStepToTimePoint);
30  MITK_TEST(TimePointToTimeStep);
31  MITK_TEST(GetGeometryCloneForTimeStep);
32  MITK_TEST(GetGeometryForTimeStep);
33  MITK_TEST(GetGeometryForTimePoint);
34  MITK_TEST(IsValid);
35  MITK_TEST(Expand);
36  MITK_TEST(ReplaceTimeStepGeometries);
37  MITK_TEST(ClearAllGeometries);
38  MITK_TEST(AppendNewTimeStep);
39 
40  CPPUNIT_TEST_SUITE_END();
41 
42 private:
43  mitk::Geometry3D::Pointer m_Geometry1;
44  mitk::Geometry3D::Pointer m_Geometry2;
45  mitk::Geometry3D::Pointer m_Geometry3;
46  mitk::Geometry3D::Pointer m_Geometry3_5;
47  mitk::Geometry3D::Pointer m_Geometry4;
48  mitk::Geometry3D::Pointer m_Geometry5;
49  mitk::Geometry3D::Pointer m_InvalidGeometry;
50  mitk::Geometry3D::Pointer m_NewGeometry;
51 
52  mitk::TimePointType m_Geometry1MinTP;
53  mitk::TimePointType m_Geometry2MinTP;
54  mitk::TimePointType m_Geometry3MinTP;
55  mitk::TimePointType m_Geometry3_5MinTP;
56  mitk::TimePointType m_Geometry4MinTP;
57  mitk::TimePointType m_Geometry5MinTP;
58  mitk::TimePointType m_NewGeometryMinTP;
59 
60  mitk::TimePointType m_Geometry1MaxTP;
61  mitk::TimePointType m_Geometry2MaxTP;
62  mitk::TimePointType m_Geometry3MaxTP;
63  mitk::TimePointType m_Geometry3_5MaxTP;
64  mitk::TimePointType m_Geometry4MaxTP;
65  mitk::TimePointType m_Geometry5MaxTP;
66  mitk::TimePointType m_NewGeometryMaxTP;
67 
68  mitk::ArbitraryTimeGeometry::Pointer m_emptyTimeGeometry;
69  mitk::ArbitraryTimeGeometry::Pointer m_initTimeGeometry;
70  mitk::ArbitraryTimeGeometry::Pointer m_12345TimeGeometry;
71  mitk::ArbitraryTimeGeometry::Pointer m_123TimeGeometry;
72 
73 public:
74  void setUp() override
75  {
76  mitk::TimeBounds bounds;
77  m_Geometry1 = mitk::Geometry3D::New();
78  m_Geometry2 = mitk::Geometry3D::New();
79  m_Geometry3 = mitk::Geometry3D::New();
80  m_Geometry3_5 = mitk::Geometry3D::New();
81  m_Geometry4 = mitk::Geometry3D::New();
82  m_Geometry5 = mitk::Geometry3D::New();
83 
84  m_Geometry1MinTP = 1;
85  m_Geometry2MinTP = 2;
86  m_Geometry3MinTP = 3;
87  m_Geometry3_5MinTP = 3.5;
88  m_Geometry4MinTP = 4;
89  m_Geometry5MinTP = 5;
90 
91  m_Geometry1MaxTP = 1.9;
92  m_Geometry2MaxTP = 2.9;
93  m_Geometry3MaxTP = 3.9;
94  m_Geometry3_5MaxTP = 3.9;
95  m_Geometry4MaxTP = 4.9;
96  m_Geometry5MaxTP = 5.9;
97 
98  m_NewGeometry = mitk::Geometry3D::New();
99  m_NewGeometryMinTP = 20;
100  m_NewGeometryMaxTP = 21.9;
101 
102  mitk::Point3D origin(42);
103  m_NewGeometry->SetOrigin(origin);
104 
105  m_emptyTimeGeometry = mitk::ArbitraryTimeGeometry::New();
106  m_emptyTimeGeometry->ClearAllGeometries();
107 
108  m_initTimeGeometry = mitk::ArbitraryTimeGeometry::New();
109  m_initTimeGeometry->Initialize();
110 
111  m_12345TimeGeometry = mitk::ArbitraryTimeGeometry::New();
112  m_12345TimeGeometry->ClearAllGeometries();
113  m_12345TimeGeometry->AppendNewTimeStep(m_Geometry1, m_Geometry1MinTP, m_Geometry1MaxTP);
114  m_12345TimeGeometry->AppendNewTimeStep(m_Geometry2, m_Geometry2MinTP, m_Geometry2MaxTP);
115  m_12345TimeGeometry->AppendNewTimeStep(m_Geometry3, m_Geometry3MinTP, m_Geometry3MaxTP);
116  m_12345TimeGeometry->AppendNewTimeStep(m_Geometry4, m_Geometry4MinTP, m_Geometry4MaxTP);
117  m_12345TimeGeometry->AppendNewTimeStep(m_Geometry5, m_Geometry5MinTP, m_Geometry5MaxTP);
118 
119  m_123TimeGeometry = mitk::ArbitraryTimeGeometry::New();
120  m_123TimeGeometry->ClearAllGeometries();
121  m_123TimeGeometry->AppendNewTimeStep(m_Geometry1, m_Geometry1MinTP, m_Geometry1MaxTP);
122  m_123TimeGeometry->AppendNewTimeStep(m_Geometry2, m_Geometry2MinTP, m_Geometry2MaxTP);
123  m_123TimeGeometry->AppendNewTimeStep(m_Geometry3, m_Geometry3MinTP, m_Geometry3MaxTP);
124  }
125 
126  void tearDown() override {}
127  void CountTimeSteps()
128  {
129  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->CountTimeSteps() == 0,
130  "Testing CountTimeSteps with m_emptyTimeGeometry");
131  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->CountTimeSteps() == 1,
132  "Testing CountTimeSteps with m_initTimeGeometry");
133  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->CountTimeSteps() == 5,
134  "Testing CountTimeSteps with m_12345TimeGeometry");
135  }
136 
137  void GetMinimumTimePoint()
138  {
139  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetMinimumTimePoint() == 0.0,
140  "Testing GetMinimumTimePoint with m_emptyTimeGeometry");
141  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetMinimumTimePoint() == 0.0,
142  "Testing GetMinimumTimePoint with m_initTimeGeometry");
143  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetMinimumTimePoint() == 1.0,
144  "Testing GetMinimumTimePoint with m_12345TimeGeometry");
145 
146  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetMinimumTimePoint(2) == 0.0,
147  "Testing GetMinimumTimePoint(2) with m_emptyTimeGeometry");
148  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetMinimumTimePoint(2) == 0.0,
149  "Testing GetMinimumTimePoint(2) with m_initTimeGeometry");
150  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetMinimumTimePoint(2) == 2.9,
151  "Testing GetMinimumTimePoint(2) with m_12345TimeGeometry");
152  }
153 
154  void GetMaximumTimePoint()
155  {
156  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetMaximumTimePoint() == 0.0,
157  "Testing GetMaximumTimePoint with m_emptyTimeGeometry");
158  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetMaximumTimePoint() == 1.0,
159  "Testing GetMaximumTimePoint with m_initTimeGeometry");
160  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetMaximumTimePoint() == 5.9,
161  "Testing GetMaximumTimePoint with m_12345TimeGeometry");
162 
163  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetMaximumTimePoint(2) == 0.0,
164  "Testing GetMaximumTimePoint(2) with m_emptyTimeGeometry");
165  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetMaximumTimePoint(2) == 0.0,
166  "Testing GetMaximumTimePoint(2) with m_initTimeGeometry");
167  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetMaximumTimePoint(2) == 3.9,
168  "Testing GetMaximumTimePoint(2) with m_12345TimeGeometry");
169  }
170 
171  void GetTimeBounds()
172  {
173  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetMaximumTimePoint(2) == 0.0,
174  "Testing GetMaximumTimePoint(2) with m_emptyTimeGeometry");
175  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetMaximumTimePoint(2) == 0.0,
176  "Testing GetMaximumTimePoint(2) with m_initTimeGeometry");
177  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetMaximumTimePoint(2) == 3.9,
178  "Testing GetMaximumTimePoint(2) with m_12345TimeGeometry");
179 
180  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetTimeBounds()[0] == 0.0,
181  "Testing GetTimeBounds lower part with m_emptyTimeGeometry");
182  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetTimeBounds()[0] == 0.0,
183  "Testing GetTimeBounds lower part with m_initTimeGeometry");
184  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetTimeBounds()[0] == 1.0,
185  "Testing GetTimeBounds lower part with m_12345TimeGeometry");
186 
187  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetTimeBounds()[1] == 0.0,
188  "Testing GetTimeBounds with m_emptyTimeGeometry");
189  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetTimeBounds()[1] == 1.0,
190  "Testing GetTimeBounds with m_initTimeGeometry");
191  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetTimeBounds()[1] == 5.9,
192  "Testing GetTimeBounds with m_12345TimeGeometry");
193 
194  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetTimeBounds(3)[0] == 0.0,
195  "Testing GetTimeBounds(3) lower part with m_emptyTimeGeometry");
196  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetTimeBounds(3)[0] == 0.0,
197  "Testing GetTimeBounds(3) lower part with m_initTimeGeometry");
198  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetTimeBounds(3)[0] == 3.9,
199  "Testing GetTimeBounds(3) lower part with m_12345TimeGeometry");
200 
201  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetTimeBounds(3)[1] == 0.0,
202  "Testing GetTimeBounds(3) with m_emptyTimeGeometry");
203  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetTimeBounds(3)[1] == 0.0,
204  "Testing GetTimeBounds(3) with m_initTimeGeometry");
205  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetTimeBounds(3)[1] == 4.9,
206  "Testing GetTimeBounds(3) with m_12345TimeGeometry");
207  }
208 
209  void IsValidTimePoint()
210  {
211  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimePoint(-1) == false,
212  "Testing IsValidTimePoint(-1) with m_emptyTimeGeometry");
213  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimePoint(-1) == false,
214  "Testing IsValidTimePoint(-1) with m_initTimeGeometry");
215  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimePoint(-1) == false,
216  "Testing IsValidTimePoint(-1) with m_12345TimeGeometry");
217 
218  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimePoint(0) == false,
219  "Testing IsValidTimePoint(0) with m_emptyTimeGeometry");
220  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimePoint(0) == true,
221  "Testing IsValidTimePoint(0) with m_initTimeGeometry");
222  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimePoint(0) == false,
223  "Testing IsValidTimePoint(0) with m_12345TimeGeometry");
224 
225  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimePoint(1) == false,
226  "Testing IsValidTimePoint(1) with m_emptyTimeGeometry");
227  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimePoint(1) == false,
228  "Testing IsValidTimePoint(1) with m_initTimeGeometry");
229  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimePoint(1) == true,
230  "Testing IsValidTimePoint(1) with m_12345TimeGeometry");
231 
232  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimePoint(2.5) == false,
233  "Testing IsValidTimePoint(2.5) with m_emptyTimeGeometry");
234  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimePoint(2.5) == false,
235  "Testing IsValidTimePoint(2.5) with m_initTimeGeometry");
236  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimePoint(2.5) == true,
237  "Testing IsValidTimePoint(2.5) with m_12345TimeGeometry");
238 
239  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimePoint(5.89) == false,
240  "Testing IsValidTimePoint(5.89) with m_emptyTimeGeometry");
241  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimePoint(5.89) == false,
242  "Testing IsValidTimePoint(5.89) with m_initTimeGeometry");
243  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimePoint(5.89) == true,
244  "Testing IsValidTimePoint(5.89) with m_12345TimeGeometry");
245 
246  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimePoint(10) == false,
247  "Testing IsValidTimePoint(10) with m_emptyTimeGeometry");
248  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimePoint(10) == false,
249  "Testing IsValidTimePoint(10) with m_initTimeGeometry");
250  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimePoint(10) == false,
251  "Testing IsValidTimePoint(10) with m_12345TimeGeometry");
252 
253  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimeStep(0) == false,
254  "Testing IsValidTimeStep(0) with m_emptyTimeGeometry");
255  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimeStep(0) == true,
256  "Testing IsValidTimeStep(0) with m_initTimeGeometry");
257  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimeStep(0) == true,
258  "Testing IsValidTimeStep(0) with m_12345TimeGeometry");
259 
260  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimeStep(1) == false,
261  "Testing IsValidTimeStep(1) with m_emptyTimeGeometry");
262  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimeStep(1) == false,
263  "Testing IsValidTimeStep(1) with m_initTimeGeometry");
264  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimeStep(1) == true,
265  "Testing IsValidTimeStep(1) with m_12345TimeGeometry");
266 
267  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValidTimeStep(6) == false,
268  "Testing IsValidTimeStep(6) with m_emptyTimeGeometry");
269  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValidTimeStep(6) == false,
270  "Testing IsValidTimeStep(6) with m_initTimeGeometry");
271  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValidTimeStep(6) == false,
272  "Testing IsValidTimeStep(6) with m_12345TimeGeometry");
273  }
274 
275  void TimeStepToTimePoint()
276  {
277  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->TimeStepToTimePoint(0) == 0.0,
278  "Testing TimeStepToTimePoint(0) with m_emptyTimeGeometry");
279  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->TimeStepToTimePoint(0) == 0.0,
280  "Testing TimeStepToTimePoint(0) with m_initTimeGeometry");
281  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimeStepToTimePoint(0) == 1.0,
282  "Testing TimeStepToTimePoint(0) with m_12345TimeGeometry");
283 
284  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->TimeStepToTimePoint(1) == 0.0,
285  "Testing TimeStepToTimePoint(1) with m_emptyTimeGeometry");
286  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->TimeStepToTimePoint(1) == 0.0,
287  "Testing TimeStepToTimePoint(1) with m_initTimeGeometry");
288  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimeStepToTimePoint(1) == 2.0,
289  "Testing TimeStepToTimePoint(1) with m_12345TimeGeometry");
290 
291  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->TimeStepToTimePoint(6) == 0.0,
292  "Testing TimeStepToTimePoint(6) with m_emptyTimeGeometry");
293  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->TimeStepToTimePoint(6) == 0.0,
294  "Testing TimeStepToTimePoint(6) with m_initTimeGeometry");
295  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimeStepToTimePoint(6) == 0.0,
296  "Testing TimeStepToTimePoint(6) with m_12345TimeGeometry");
297  }
298 
299  void TimePointToTimeStep()
300  {
301  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->TimePointToTimeStep(0.0) == 0,
302  "Testing TimePointToTimeStep(0.0) with m_emptyTimeGeometry");
303  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->TimePointToTimeStep(0.0) == 0,
304  "Testing TimePointToTimeStep(0.0) with m_initTimeGeometry");
305  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimePointToTimeStep(0.0) == 0,
306  "Testing TimePointToTimeStep(0.0) with m_12345TimeGeometry");
307 
308  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->TimePointToTimeStep(0.5) == 0,
309  "Testing TimePointToTimeStep(0.5) with m_emptyTimeGeometry");
310  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->TimePointToTimeStep(0.5) == 0,
311  "Testing TimePointToTimeStep(0.5) with m_initTimeGeometry");
312  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimePointToTimeStep(0.5) == 0,
313  "Testing TimePointToTimeStep(0.5) with m_12345TimeGeometry");
314 
315  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->TimePointToTimeStep(3.5) == 0,
316  "Testing TimePointToTimeStep(3.5) with m_emptyTimeGeometry");
317  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->TimePointToTimeStep(3.5) == m_initTimeGeometry->CountTimeSteps(),
318  "Testing TimePointToTimeStep(3.5) with m_initTimeGeometry");
319  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimePointToTimeStep(3.5) == 2,
320  "Testing TimePointToTimeStep(3.5) with m_12345TimeGeometry");
321 
322  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->TimePointToTimeStep(5.8) == 0,
323  "Testing TimePointToTimeStep(5.8) with m_emptyTimeGeometry");
324  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->TimePointToTimeStep(5.8) == m_initTimeGeometry->CountTimeSteps(),
325  "Testing TimePointToTimeStep(5.8) with m_initTimeGeometry");
326  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimePointToTimeStep(5.8) == 4,
327  "Testing TimePointToTimeStep(5.8) with m_12345TimeGeometry");
328  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->TimePointToTimeStep(5.9) == m_12345TimeGeometry->CountTimeSteps(),
329  "Testing TimePointToTimeStep(5.9) with m_12345TimeGeometry");
330  }
331 
332  void GetGeometryCloneForTimeStep()
333  {
334  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetGeometryCloneForTimeStep(0).IsNull(),
335  "Testing GetGeometryCloneForTimeStep(0) with m_emptyTimeGeometry");
336  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetGeometryCloneForTimeStep(0).IsNotNull(),
337  "Testing GetGeometryCloneForTimeStep(0) with m_initTimeGeometry");
338  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetGeometryCloneForTimeStep(0).IsNotNull(),
339  "Testing GetGeometryCloneForTimeStep(0) with m_12345TimeGeometry");
340  }
341 
342  void GetGeometryForTimeStep()
343  {
344  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetGeometryForTimeStep(0).IsNull(),
345  "Testing GetGeometryForTimePoint(0) with m_emptyTimeGeometry");
346  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetGeometryForTimeStep(0).IsNotNull(),
347  "Testing GetGeometryForTimePoint(0) with m_initTimeGeometry");
348  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetGeometryForTimeStep(1).IsNull(),
349  "Testing GetGeometryForTimePoint(1) with m_initTimeGeometry");
351  m_12345TimeGeometry->GetGeometryForTimeStep(0).GetPointer() == m_Geometry1.GetPointer(),
352  "Testing GetGeometryForTimePoint(0) with m_12345TimeGeometry");
354  m_12345TimeGeometry->GetGeometryForTimeStep(3).GetPointer() == m_Geometry4.GetPointer(),
355  "Testing GetGeometryForTimePoint(3) with m_12345TimeGeometry");
357  m_12345TimeGeometry->GetGeometryForTimeStep(4).GetPointer() == m_Geometry5.GetPointer(),
358  "Testing GetGeometryForTimePoint(4) with m_12345TimeGeometry");
359  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetGeometryForTimeStep(5).IsNull(),
360  "Testing GetGeometryForTimePoint(5) with m_12345TimeGeometry");
361  }
362 
363  void GetGeometryForTimePoint()
364  {
365  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetGeometryForTimePoint(0).IsNull(),
366  "Testing GetGeometryForTimeStep(0) with m_emptyTimeGeometry");
367  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetGeometryForTimePoint(0).IsNotNull(),
368  "Testing GetGeometryForTimeStep(0) with m_initTimeGeometry");
369  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetGeometryForTimePoint(0).IsNull(),
370  "Testing GetGeometryForTimeStep(0) with m_12345TimeGeometry");
371 
372  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetGeometryForTimePoint(1.5).IsNull(),
373  "Testing GetGeometryForTimeStep(1.5) with m_emptyTimeGeometry");
374  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->GetGeometryForTimePoint(1.5).IsNull(),
375  "Testing GetGeometryForTimeStep(1.5) with m_initTimeGeometry");
377  m_12345TimeGeometry->GetGeometryForTimePoint(1.5).GetPointer() == m_Geometry1.GetPointer(),
378  "Testing GetGeometryForTimeStep(1.5) with m_12345TimeGeometry");
380  m_12345TimeGeometry->GetGeometryForTimePoint(3.5).GetPointer() == m_Geometry3.GetPointer(),
381  "Testing GetGeometryForTimeStep(3.5) with m_12345TimeGeometry");
382  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetGeometryForTimePoint(5.9).IsNull(),
383  "Testing GetGeometryForTimeStep(5.9) with m_12345TimeGeometry");
384  }
385 
386  void IsValid()
387  {
388  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->IsValid() == false, "Testing IsValid() with m_emptyTimeGeometry");
389  MITK_TEST_CONDITION_REQUIRED(m_initTimeGeometry->IsValid() == true, "Testing IsValid() with m_initTimeGeometry");
390  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->IsValid() == true, "Testing IsValid() with m_12345TimeGeometry");
391  }
392 
393  void Expand()
394  {
395  m_12345TimeGeometry->Expand(3);
396  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->CountTimeSteps() == 5,
397  "Testing Expand(3) doesn't change m_12345TimeGeometry");
398 
399  m_12345TimeGeometry->Expand(7);
400  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->CountTimeSteps() == 7,
401  "Testing Expand(7) with m_12345TimeGeometry");
402  }
403 
404  void ReplaceTimeStepGeometries()
405  {
406  // Test replace time step geometries
407  m_12345TimeGeometry->ReplaceTimeStepGeometries(m_NewGeometry);
408  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->CountTimeSteps() == 5,
409  "Testing ReplaceTimeStepGeometries() with m_12345TimeGeometry");
411  m_12345TimeGeometry->GetGeometryForTimeStep(0)->GetOrigin() == m_NewGeometry->GetOrigin(),
412  "Testing ReplaceTimeStepGeometries(): check if first geometry of m_12345TimeGeometry "
413  "was replaced m_12345TimeGeometry");
415  m_12345TimeGeometry->GetGeometryForTimeStep(4)->GetOrigin() == m_NewGeometry->GetOrigin(),
416  "Testing ReplaceTimeStepGeometries(): check if last geometry of m_12345TimeGeometry "
417  "was replaced m_12345TimeGeometry");
418  }
419 
420  void ClearAllGeometries()
421  {
422  // Test clear all geometries
423  m_12345TimeGeometry->ClearAllGeometries();
424  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->CountTimeSteps() == 0,
425  "Testing ClearAllGeometries() with m_12345TimeGeometry");
426  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetMinimumTimePoint() == 0,
427  "Testing ClearAllGeometries() with m_12345TimeGeometry");
428  MITK_TEST_CONDITION_REQUIRED(m_12345TimeGeometry->GetMaximumTimePoint() == 0,
429  "Testing ClearAllGeometries() with m_12345TimeGeometry");
430  }
431 
432  void AppendNewTimeStep()
433  {
434  // Test append
435  MITK_TEST_FOR_EXCEPTION(mitk::Exception, m_123TimeGeometry->AppendNewTimeStep(nullptr, 0, 1));
436  MITK_TEST_FOR_EXCEPTION(mitk::Exception, m_123TimeGeometry->AppendNewTimeStep(m_Geometry3_5,m_Geometry3_5MinTP,m_Geometry3_5MaxTP));
437  MITK_TEST_FOR_EXCEPTION(mitk::Exception, m_123TimeGeometry->AppendNewTimeStep(m_Geometry4, m_Geometry4MaxTP, m_Geometry4MinTP)); //valid but inverted bounds
438 
439  m_emptyTimeGeometry->AppendNewTimeStep(m_Geometry4, m_Geometry4MinTP, m_Geometry4MaxTP);
440  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->CountTimeSteps() == 1,
441  "Testing AppendNewTimeStep() with m_emptyTimeGeometry");
442  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetMinimumTimePoint() == 4,
443  "Testing ClearAllGeometries() with m_emptyTimeGeometry");
444  MITK_TEST_CONDITION_REQUIRED(m_emptyTimeGeometry->GetMaximumTimePoint() == 4.9,
445  "Testing ClearAllGeometries() with m_emptyTimeGeometry");
446 
447  MITK_TEST_CONDITION_REQUIRED(m_123TimeGeometry->CountTimeSteps() == 3,
448  "Testing AppendNewTimeStep() with m_emptyTimeGeometry");
449  MITK_TEST_CONDITION_REQUIRED(m_123TimeGeometry->GetMinimumTimePoint() == 1,
450  "Testing ClearAllGeometries() with m_emptyTimeGeometry");
451  MITK_TEST_CONDITION_REQUIRED(m_123TimeGeometry->GetMaximumTimePoint() == 3.9,
452  "Testing ClearAllGeometries() with m_emptyTimeGeometry");
453  m_123TimeGeometry->AppendNewTimeStep(m_Geometry4, m_Geometry4MinTP, m_Geometry4MaxTP);
454  MITK_TEST_CONDITION_REQUIRED(m_123TimeGeometry->CountTimeSteps() == 4,
455  "Testing AppendNewTimeStep() with m_123TimeGeometry");
456  MITK_TEST_CONDITION_REQUIRED(m_123TimeGeometry->GetMinimumTimePoint() == 1,
457  "Testing AppendNewTimeStep() with m_123TimeGeometry");
458  MITK_TEST_CONDITION_REQUIRED(m_123TimeGeometry->GetMaximumTimePoint() == 4.9,
459  "Testing AppendNewTimeStep() with m_123TimeGeometry");
460  MITK_TEST_CONDITION_REQUIRED(m_123TimeGeometry->GetMinimumTimePoint(3) == 3.9,
461  "Testing AppendNewTimeStep() with m_123TimeGeometry");
462  }
463 };
464 
465 MITK_TEST_SUITE_REGISTRATION(mitkArbitraryTimeGeometry)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
itk::FixedArray< ScalarType, 2 > TimeBounds
Standard typedef for time-bounds.
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static Pointer New()
#define MITK_TEST_FOR_EXCEPTION(EXCEPTIONCLASS, STATEMENT)
Simplified version of MITK_TEST_FOR_EXCEPTION_BEGIN / END for a single statement. ...
An object of this class represents an exception of MITK. Please don&#39;t instantiate exceptions manually...
Definition: mitkException.h:45
Test fixture for parameterized tests.
mitk::ScalarType TimePointType