Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkSceneIOTestScenarioProvider.h
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 
13 #ifndef mitkSceneIOTestScenarioProvider_h_included
14 #define mitkSceneIOTestScenarioProvider_h_included
15 
17 
18 namespace mitk
19 {
37  {
38  public:
41 
51  struct Scenario
52  {
53  std::string key;
54  bool serializable;
58 
61 
71  Scenario(const std::string &_key,
72  const SceneIOTestScenarioProvider *_scenarioProvider,
74  bool _isSerializable,
75  const std::string &_referenceArchiveFilename,
76  bool _isReferenceLoadable,
77  double _comparisonPrecision);
78 
79  private:
80  const SceneIOTestScenarioProvider *m_ScenarioProvider;
82  };
83 
85  typedef std::vector<Scenario> ScenarioList;
86 
88  ScenarioList GetAllScenarios() const;
89 
90  private:
91  ScenarioList m_Scenarios;
92 
94  int m_HowMuchIsMany;
95 
99  void AddScenario(const std::string &key,
100  BuilderMethodPointer creator,
101  bool isSerializable,
102  const std::string &referenceArchiveFilename = std::string(),
103  bool isReferenceLoadable = false,
104  double comparisionPrecision = mitk::eps);
105 
109  DataStorage::Pointer EmptyStorage() const;
110 
114  DataStorage::Pointer OneEmptyNode() const;
115 
119  DataStorage::Pointer OneEmptyNamedNode() const;
120 
132  DataStorage::Pointer ManyTopLevelNodes() const;
133 
145  DataStorage::Pointer LineOfManyOnlyChildren() const;
146 
150  DataStorage::Pointer ComplicatedFamilySituation() const;
151 
155  DataStorage::Pointer Image() const;
156 
161 
166 
171 
175  DataStorage::Pointer SpecialProperties() const;
176 
177  public:
178 // Helper to simplify writing the registration
179 #define AddSaveAndRestoreScenario(name) AddScenario(#name, &mitk::SceneIOTestScenarioProvider::name, true);
180 
181  // this one in the header so it is clearly visible when someone
182  // adds a test to the bottom of the list
183  SceneIOTestScenarioProvider() : m_HowMuchIsMany(50)
184  {
186  AddSaveAndRestoreScenario(EmptyStorage);
187  AddSaveAndRestoreScenario(OneEmptyNode);
188  AddSaveAndRestoreScenario(OneEmptyNamedNode);
189  AddSaveAndRestoreScenario(ManyTopLevelNodes);
190  AddSaveAndRestoreScenario(LineOfManyOnlyChildren);
191  AddSaveAndRestoreScenario(ComplicatedFamilySituation);
192 
196 
197  if (sizeof(size_t) != 4)
198  // this test is deactivated on 32 bit systems since it fails
199  // on the only 32 bit dartclient. To activate it there, one
200  // would have to debug the precision problem on a 32 bit
201  // machine and either adapt expectations or fix a bug.
203 
204  AddSaveAndRestoreScenario(SpecialProperties);
205 
206  // AddScenario("GeometryData", &mitk::SceneIOTestScenarioProvider::GeometryData, true, std::string(), false,
207  // mitk::eps);
208  }
209 
210  }; // class
211 
212 } // namespace
213 
214 #endif
Class for storing surfaces (vtkPolyData).
Definition: mitkSurface.h:28
std::string referenceArchiveFilename
Absolute filename with a reference .mitk file.
#define AddSaveAndRestoreScenario(name)
bool referenceArchiveLoadable
Do we expect that the reference can be loaded without errors?
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
ScenarioList GetAllScenarios() const
Returns all registered scenarios.
double comparisonPrecision
Precision used for floating point comparisons after save/load cycle (eps).
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:75
Image class for storing images.
Definition: mitkImage.h:72
Data class only having a BaseGeometry but not containing any specific data.
DataStorage::Pointer(SceneIOTestScenarioProvider::* BuilderMethodPointer)() const
Typedef for type BuilderMethodPointer which is function pointer to member of SceneIOTestScenarioProvi...
Scenario(const std::string &_key, const SceneIOTestScenarioProvider *_scenarioProvider, SceneIOTestScenarioProvider::BuilderMethodPointer _providerMethod, bool _isSerializable, const std::string &_referenceArchiveFilename, bool _isReferenceLoadable, double _comparisonPrecision)
MITKCORE_EXPORT const ScalarType eps
bool serializable
Do we expect that this can be stored in a .mitk file?
Provides DataStorages that serve as test scenarios.
std::vector< Scenario > ScenarioList
List of Scenarios.
DataStorage::Pointer BuildDataStorage() const
Construct the DataStorage for this scenario.