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